Browse Source

added example part 2

Denis Muratshin 12 years ago
parent
commit
211aee0591
41 changed files with 957 additions and 15 deletions
  1. 2 2
      .hg_archival.txt
  2. 1 0
      .hgignore
  3. BIN
      doc.zip
  4. 12 2
      examples/Game/CMakeLists.txt
  5. 0 7
      examples/Game/part1/data/xmls/res.xml
  6. 8 0
      examples/Game/part1/src/Game.cpp
  7. 8 0
      examples/Game/part1/src/Joystick.cpp
  8. 12 3
      examples/Game/part1/src/Player.cpp
  9. 3 0
      examples/Game/part1/src/Unit.cpp
  10. 2 0
      examples/Game/part1/src/example.cpp
  11. 2 1
      examples/Game/part1/src/res.cpp
  12. 19 0
      examples/Game/part2/data/app.icf
  13. 107 0
      examples/Game/part2/data/development.icf
  14. BIN
      examples/Game/part2/data/images/asteroid.png
  15. BIN
      examples/Game/part2/data/images/explosion.png
  16. BIN
      examples/Game/part2/data/images/finger.png
  17. BIN
      examples/Game/part2/data/images/joystick.png
  18. BIN
      examples/Game/part2/data/images/rocket.png
  19. BIN
      examples/Game/part2/data/images/ship.png
  20. BIN
      examples/Game/part2/data/images/shipengine.png
  21. BIN
      examples/Game/part2/data/images/sky.jpg
  22. 17 0
      examples/Game/part2/data/xmls/ui.xml
  23. 28 0
      examples/Game/part2/game.mkb
  24. 41 0
      examples/Game/part2/src/Enemy.cpp
  25. 15 0
      examples/Game/part2/src/Enemy.h
  26. 76 0
      examples/Game/part2/src/Game.cpp
  27. 35 0
      examples/Game/part2/src/Game.h
  28. 64 0
      examples/Game/part2/src/Joystick.cpp
  29. 19 0
      examples/Game/part2/src/Joystick.h
  30. 67 0
      examples/Game/part2/src/Player.cpp
  31. 18 0
      examples/Game/part2/src/Player.h
  32. 80 0
      examples/Game/part2/src/Rocket.cpp
  33. 17 0
      examples/Game/part2/src/Rocket.h
  34. 33 0
      examples/Game/part2/src/Unit.cpp
  35. 26 0
      examples/Game/part2/src/Unit.h
  36. 183 0
      examples/Game/part2/src/entry_point.cpp
  37. 29 0
      examples/Game/part2/src/example.cpp
  38. 4 0
      examples/Game/part2/src/example.h
  39. 17 0
      examples/Game/part2/src/res.cpp
  40. 10 0
      examples/Game/part2/src/res.h
  41. 2 0
      oxygine/src/core/UberShaderProgram.cpp

+ 2 - 2
.hg_archival.txt

@@ -1,5 +1,5 @@
 repo: b6d71054df5712e643a0685bc3ba54b123db5729
 repo: b6d71054df5712e643a0685bc3ba54b123db5729
-node: f12360f89c960f4c9c93dac9e8efe4b66fa5973b
+node: f1b9c180182ddb8b81e770b9f28b981b4a36b73f
 branch: default
 branch: default
 latesttag: oldrender
 latesttag: oldrender
-latesttagdistance: 71
+latesttagdistance: 74

+ 1 - 0
.hgignore

@@ -88,5 +88,6 @@ examples/Demo/build_demo_vc11/
 examples/TutorialResources/build_tutorialresources_vc10
 examples/TutorialResources/build_tutorialresources_vc10
 examples/Game/part1/build_game_vc
 examples/Game/part1/build_game_vc
 examples/Game/part1/build_game_vc10/
 examples/Game/part1/build_game_vc10/
+examples/Game/part2/build_game_vc10
 syntax: regexp
 syntax: regexp
 ^build/
 ^build/

BIN
doc.zip


+ 12 - 2
examples/Game/CMakeLists.txt

@@ -1,11 +1,21 @@
 cmake_minimum_required (VERSION 2.6)
 cmake_minimum_required (VERSION 2.6)
 project (Game)
 project (Game)
 
 
-file(GLOB_RECURSE PART1SRC
+file(GLOB_RECURSE PARTSRC
 		part1/src/*.cpp
 		part1/src/*.cpp
 		part1/src/*.h)
 		part1/src/*.h)
 
 
 add_executable(GamePart1
 add_executable(GamePart1
-	${PART1SRC})
+	${PARTSRC})
 
 
 target_link_libraries(GamePart1 ${OXYGINE_CORE_LIBS})
 target_link_libraries(GamePart1 ${OXYGINE_CORE_LIBS})
+
+
+file(GLOB_RECURSE PARTSRC
+		part2/src/*.cpp
+		part2/src/*.h)
+
+add_executable(GamePart2
+	${PARTSRC})
+
+target_link_libraries(GamePart2 ${OXYGINE_CORE_LIBS})

+ 0 - 7
examples/Game/part1/data/xmls/res.xml

@@ -1,7 +0,0 @@
-<?xml version="1.0"?>
-<resources>
-	<set path = "images" />
-	<atlas>
-		<image file="controller.png" />
-	</atlas>
-</resources>

+ 8 - 0
examples/Game/part1/src/Game.cpp

@@ -10,15 +10,19 @@ Game::Game()
 
 
 void Game::init()
 void Game::init()
 {
 {
+	//scene layer would have size of display
 	setSize(getRoot()->getSize());
 	setSize(getRoot()->getSize());
 
 
+	//create background
 	spSprite sky = new Sprite;
 	spSprite sky = new Sprite;
 	sky->setResAnim(res::ui.getResAnim("sky"));
 	sky->setResAnim(res::ui.getResAnim("sky"));
 	sky->attachTo(this);
 	sky->attachTo(this);
 	
 	
+	//create player ship
 	_player = new Player;
 	_player = new Player;
 	_player->init(this);
 	_player->init(this);
 
 
+	//create virtual joystick
 	_move = new Joystick;
 	_move = new Joystick;
 	_move->attachTo(this);
 	_move->attachTo(this);
 	_move->setY(getHeight() - _move->getHeight());
 	_move->setY(getHeight() - _move->getHeight());
@@ -26,5 +30,9 @@ void Game::init()
 
 
 void Game::doUpdate(const UpdateState &us)
 void Game::doUpdate(const UpdateState &us)
 {
 {
+	//doUpdate is virtual method of Actor
+	//it is being called each frame
+
+	//update player each frame
 	_player->update(us);
 	_player->update(us);
 }
 }

+ 8 - 0
examples/Game/part1/src/Joystick.cpp

@@ -6,6 +6,7 @@ Joystick::Joystick():_pressed(false), _dir(0,0)
 	setResAnim(res::ui.getResAnim("joystick"));
 	setResAnim(res::ui.getResAnim("joystick"));
 	setAlpha(128);
 	setAlpha(128);
 
 
+	//handle touch events
 	addEventListener(TouchEvent::TOUCH_DOWN, CLOSURE(this, &Joystick::onEvent));
 	addEventListener(TouchEvent::TOUCH_DOWN, CLOSURE(this, &Joystick::onEvent));
 	addEventListener(TouchEvent::TOUCH_UP, CLOSURE(this, &Joystick::onEvent));
 	addEventListener(TouchEvent::TOUCH_UP, CLOSURE(this, &Joystick::onEvent));
 	addEventListener(TouchEvent::MOVE, CLOSURE(this, &Joystick::onEvent));
 	addEventListener(TouchEvent::MOVE, CLOSURE(this, &Joystick::onEvent));
@@ -21,6 +22,8 @@ Joystick::Joystick():_pressed(false), _dir(0,0)
 void Joystick::onEvent(Event *ev)
 void Joystick::onEvent(Event *ev)
 {
 {
 	TouchEvent *te = safeCast<TouchEvent *>(ev);
 	TouchEvent *te = safeCast<TouchEvent *>(ev);
+
+	//if player touched down
 	if (te->type == TouchEvent::TOUCH_DOWN)
 	if (te->type == TouchEvent::TOUCH_DOWN)
 	{
 	{
 		_finger->setVisible(true);
 		_finger->setVisible(true);
@@ -28,6 +31,7 @@ void Joystick::onEvent(Event *ev)
 		_pressed = true;
 		_pressed = true;
 	}
 	}
 
 
+	//if player touched up
 	if (te->type == TouchEvent::TOUCH_UP)
 	if (te->type == TouchEvent::TOUCH_UP)
 	{
 	{
 		_finger->setVisible(false);
 		_finger->setVisible(false);
@@ -35,6 +39,10 @@ void Joystick::onEvent(Event *ev)
 		_pressed = false;
 		_pressed = false;
 	}
 	}
 
 
+	if (te->type == TouchEvent::MOVE)
+	{
+	}
+
 	Vector2 center = getSize()/2;
 	Vector2 center = getSize()/2;
 	_dir = te->localPosition - center;
 	_dir = te->localPosition - center;
 
 

+ 12 - 3
examples/Game/part1/src/Player.cpp

@@ -5,6 +5,7 @@
 
 
 void Player::_init()
 void Player::_init()
 {
 {
+	//initialize player's ship
 	_view->setPosition(_game->getSize()/2);
 	_view->setPosition(_game->getSize()/2);
 
 
 	_ship = new Sprite;
 	_ship = new Sprite;
@@ -15,22 +16,30 @@ void Player::_init()
 	_engine = new Sprite;
 	_engine = new Sprite;
 	_engine->setResAnim(res::ui.getResAnim("shipengine"));
 	_engine->setResAnim(res::ui.getResAnim("shipengine"));
 	_engine->attachTo(_ship);
 	_engine->attachTo(_ship);
+	//animate engine's fire
 	_engine->addTween(Sprite::TweenColor(Color::Red), 500, -1, true);
 	_engine->addTween(Sprite::TweenColor(Color::Red), 500, -1, true);
+	//by default it is hidden
+	//and would be visible only if ship moves
 	_engine->setVisible(false);
 	_engine->setVisible(false);
 }
 }
 
 
 void Player::_update(const UpdateState &us)
 void Player::_update(const UpdateState &us)
 {
 {
 	_engine->setVisible(false);
 	_engine->setVisible(false);
+
 	Vector2 dir;
 	Vector2 dir;
 	if (_game->_move->getDirection(dir))
 	if (_game->_move->getDirection(dir))
 	{
 	{
-		Vector2 pos = _view->getPosition();
-		float angle = atan2f(dir.y, dir.x);
-		_view->setRotation(angle);
+		//update player position according to delta time and finger direction from virtual joystick
+		Vector2 pos = _view->getPosition();		
 		pos = pos + dir * (us.dt / 1000.0f) * 5;
 		pos = pos + dir * (us.dt / 1000.0f) * 5;
 		_view->setPosition(pos);
 		_view->setPosition(pos);
 
 
+		//rotate it
+		float angle = atan2f(dir.y, dir.x);
+		_view->setRotation(angle);
+
+		//if player moves show engine's fire
 		_engine->setVisible(true);
 		_engine->setVisible(true);
 	}
 	}
 }
 }

+ 3 - 0
examples/Game/part1/src/Unit.cpp

@@ -8,14 +8,17 @@ Unit::Unit():_game(0)
 
 
 void Unit::init(Game *game)
 void Unit::init(Game *game)
 {
 {
+	//initialize base
 	_game = game;
 	_game = game;
 	_view = new Actor;
 	_view = new Actor;
 	_view->attachTo(game);
 	_view->attachTo(game);
 
 
+	//virtual method was overload in Player
 	_init();
 	_init();
 }
 }
 
 
 void Unit::update(const UpdateState &us)
 void Unit::update(const UpdateState &us)
 {
 {
+	//virtual method was overload in Player
 	_update(us);
 	_update(us);
 }
 }

+ 2 - 0
examples/Game/part1/src/example.cpp

@@ -9,8 +9,10 @@ void example_preinit()
 
 
 void example_init()
 void example_init()
 {
 {
+	//load resources
 	res::load();
 	res::load();
 	
 	
+	//create scene with game
 	spGame game = new Game;
 	spGame game = new Game;
 	game->init();
 	game->init();
 	game->attachTo(getRoot());
 	game->attachTo(getRoot());

+ 2 - 1
examples/Game/part1/src/res.cpp

@@ -6,12 +6,13 @@ namespace res
 
 
 	void load()
 	void load()
 	{
 	{
+		//load our resources
 		ui.loadXML("xmls/ui.xml");
 		ui.loadXML("xmls/ui.xml");
 	}
 	}
 
 
 	void free()
 	void free()
 	{
 	{
+		//unload
 		ui.free();
 		ui.free();
-
 	}
 	}
 }
 }

+ 19 - 0
examples/Game/part2/data/app.icf

@@ -0,0 +1,19 @@
+[S3E]
+MemSize = 64777216
+DispFixRot=Landscape
+SysGlesVersion=2
+SysStackSize=131072
+
+[Trace]
+ALL=0
+EXT=0
+NONE=0
+DEVICE=0
+FIBRE=0
+THREAD=0
+LOADER=0
+SOUND=0
+FILE=0
+SURFACE=0
+MEMORY=0
+ERROR=0

+ 107 - 0
examples/Game/part2/data/development.icf

@@ -0,0 +1,107 @@
+# Settings ICF file automatically generated by S3E development environment
+
+AccelEnabled                   = Type=bool, Default="true", Value = "true"
+AudioAAC                       = Type=bool, Default="false", Value = "false"
+AudioAACPlus                   = Type=bool, Default="false", Value = "false"
+AudioMIDI                      = Type=bool, Default="true", Value = "true"
+AudioMP3                       = Type=bool, Default="true", Value = "true"
+AudioPCM                       = Type=bool, Default="true", Value = "true"
+AudioQCP                       = Type=bool, Default="false", Value = "false"
+AudioVolumeDefault             = Type=int, Min=0.000000, Max=256.000000, Default="256", Value = "256"
+BacklightTimeout               = Type=int, Min=0.000000, Max=120000.000000, Default="10000", Value = "10000"
+CompassEnabled                 = Type=bool, Default="true", Value = "true"
+ContactsFromAddrBook           = Type=bool, Default="false", Value = "false"
+DeviceAdvanceSoftkeyPosition   = Type=string, Allowed="Bottom Left" "Bottom Right" "Top Right" "Top Left", Default="Bottom Left", Value = "Bottom Left"
+DeviceArch                     = Type=string, Allowed="<Use Native Architecture>" "ARM4T" "ARM4" "ARM5T" "ARM5TE" "ARM5TEJ" "ARM6" "ARM6K" "ARM6T2" "ARM6Z" "X86" "PPC" "AMD64" "ARM7", Default="<Use Native Architecture>", Value = "<Use Native Architecture>"
+DeviceBackSoftkeyPosition      = Type=string, Allowed="Bottom Left" "Bottom Right" "Top Right" "Top Left", Default="Bottom Right", Value = "Bottom Right"
+DeviceBatteryLevel             = Type=int, Min=0.000000, Max=100.000000, Default="50", Value = "50"
+DeviceClass                    = Type=string, Allowed="UNKNOWN" "SYMBIAN_GENERIC" "SYMBIAN_SERIES60" "SYMBIAN_SERIES60_EMULATOR" "SYMBIAN_UIQ" "SYMBIAN_UIQ_EMULATOR" "BREW_GENERIC" "BREW_QCIF_3D" "BREW_QCIF_25G" "BREW_SQCIF_256" "BREW_QVGA_3G" "WINDOWS_GENERIC" "WINMOBILE_GENERIC" "WINMOBILE_SP" "WINMOBILE_PPC" "LINUX_GENERIC" "LINUX_DESKTOP" "LINUX_EMBED" "WIPI_GENERIC" "NDS_GENERIC" "ARM_SEMIH_GENERIC" "NULCUES_GENERIC" "NGI_GENERIC", Default="WINDOWS_GENERIC", Value = "WINDOWS_GENERIC"
+DeviceFPU                      = Type=string, Allowed="None" "VFP Present", Default="VFP Present", Value = "VFP Present"
+DeviceFreeRAM                  = Type=int, Min=0.000000, Max=2097151.000000, Default="1048576", Value = "1048576"
+DeviceIDInt                    = Type=int, Default="0", Value = "0"
+DeviceIDString                 = Type=string, Default="", Value = ""
+DeviceIMSI                     = Type=string, Default="SIMULATOR_IMSI", Value = "SIMULATOR_IMSI"
+DeviceLSKIsBack                = Type=bool, Default="false", Value = "false"
+DeviceLanguage                 = Type=string, Allowed="UNKNOWN" "ENGLISH" "FRENCH" "GERMAN" "SPANISH" "ITALIAN" "PORTUGUESE" "DUTCH" "TURKISH" "CROATIAN" "CZECH" "DANISH" "FINNISH" "HUNGARIAN" "NORWEGIAN" "POLISH" "RUSSIAN" "SERBIAN" "SLOVAK" "SLOVENIAN" "SWEDISH" "UKRAINIAN" "GREEK" "JAPANESE" "SIMPL_CHINESE" "TRAD_CHINESE" "KOREAN" "ICELANDIC" "FLEMISH" "THAI" "AFRIKAANS" "ALBANIAN" "AMHARIC" "ARABIC" "ARMENIAN" "AZERBAIJANI" "TAGALOG" "BELARUSSIAN" "BENGALI" "BULGARIAN" "BURMESE" "CATALAN" "ESTONIAN" "FARSI" "GAELIC" "GEORGIAN" "GUJARATI" "HEBREW" "HINDI" "INDONESIAN" "IRISH" "KANNADA" "KAZAKH" "KHMER" "LAO" "LATVIAN" "LITHUANIAN" "MACEDONIAN" "MALAY" "MALAYALAM" "MARATHI" "MOLDOVIAN" "MONGOLIAN" "PUNJABI" "ROMANIAN" "SINHALESE" "SOMALI" "SWAHILI" "TAJIK" "TAMIL" "TELUGU" "TIBETAN" "TIGRINYA" "TURKMEN" "URDU" "UZBEK" "VIETNAMESE" "WELSH" "ZULU" "<Use Native Language>", Default="<Use Native Language>", Value = "<Use Native Language>"
+DeviceMainsPower               = Type=bool, Default="false", Value = "false"
+DeviceName                     = Type=string, Default="My Computer", Value = "My Computer"
+DeviceOS                       = Type=string, Allowed="NONE" "SYMBIAN" "BREW" "WINDOWS" "WINMOBILE" "LINUX" "WIPI" "NDS" "ARM_SEMIH" "NUCLEUS" "NGI" "WINCE" "SHARPEMP" "OSX" "IPHONE" "UIQ" "PS3" "X360" "ANDROID" "WEBOS" "QNX", Default="NONE", Value = "NONE"
+DeviceOSVersion                = Type=string, Default="", Value = ""
+DeviceOSVersionNumber          = Type=int, Default="0", Value = "0"
+DevicePhoneNumber              = Type=string, Default="0044123456789", Value = "0044123456789"
+DeviceTimezone                 = Type=string, Default="SYSTEM", Value = "SYSTEM"
+DeviceTotalRAM                 = Type=int, Min=0.000000, Max=2097151.000000, Default="1048576", Value = "1048576"
+DeviceUniqueID                 = Type=string, Default="SIMULATOR_ID", Value = "SIMULATOR_ID"
+DeviceUniqueIDInt              = Type=int, Default="01234567890", Value = "01234567890"
+FileTotalStorageSize           = Type=int, Min=0.000000, Max=2147483648.000000, Default="67108864", Value = "67108864"
+FileUseSeparateRomRam          = Type=bool, Default="true", Value = "true"
+FileUseTotalStorageSize        = Type=bool, Default="false", Value = "false"
+GLAPI                          = Type=string, Allowed="None" "GLES 1.0 Common-Lite Profile from Imagination POWERVR(TM)" "GLES 1.1 Common-Lite Profile from Imagination POWERVR(TM)" "GLES 1.0 Common Profile from Imagination POWERVR(TM)" "GLES 1.1 Common Profile from Imagination POWERVR(TM)" "GLES 2.0 from Imagination POWERVR(TM)" "Obey [S3E] SysGlesVersion .icf setting" "GLES 1.1 Common Profile from Qualcomm Snapdragon(TM)" "GLES 2.0 from Qualcomm Snapdragon(TM)" "GLES 2.0 ANGLE" "GLES 2.0 ANGLE DirectX 11", Default="Obey [S3E] SysGlesVersion .icf setting", Value = "Obey [S3E] SysGlesVersion .icf setting"
+GLDontUseHiddenWindow          = Type=bool, Default="false", Value = "false"
+GLTerminateOnSuspend           = Type=bool, Default="false", Value = "false"
+GLUsePVRVFrame                 = Type=bool, Default="false", Value = "false"
+KeyboardHasAlpha               = Type=bool, Default="true", Value = "true"
+KeyboardHasDirection           = Type=bool, Default="true", Value = "true"
+KeyboardHasKeypad              = Type=bool, Default="true", Value = "true"
+KeyboardNumpadRotation         = Type=string, Allowed="Rot0" "Rot90" "Rot180" "Rot270", Default="Rot0", Value = "Rot0"
+LicenseExpiryDate              = Type=int, Min=0.000000, Max=999999995904.000000, Default="0", Value = "0"
+LicenseMinutesRemaining        = Type=int, Min=0.000000, Max=10000000.000000, Default="0", Value = "0"
+LicenseStatus                  = Type=string, Allowed="EXPIRED" "DEMO" "USECOUNT" "EXPIRYDATE" "EXPIRYMINSUSE" "PURCHASE" "SUBSCRIPTION" "UPGRADE" "NONCOMMERCIAL", Default="NONCOMMERCIAL", Value = "NONCOMMERCIAL"
+LicenseUsesRemaining           = Type=int, Min=0.000000, Max=10000000.000000, Default="0", Value = "0"
+LocationAltitude               = Type=float, Min=-2000.000000, Max=100000.000000, Default="60.0", Value = "60.0"
+LocationAvailable              = Type=bool, Default="true", Value = "true"
+LocationHeading                = Type=float, Min=0.000000, Max=359.000000, Default="0.0", Value = "0.0"
+LocationHorizontalAccuracy     = Type=float, Min=0.000000, Max=100000.000000, Default="20.0", Value = "20.0"
+LocationLatitude               = Type=float, Min=-90.000000, Max=90.000000, Default="51.511791", Value = "51.511791"
+LocationLongitude              = Type=float, Min=-180.000000, Max=180.000000, Default="-0.191084", Value = "-0.191084"
+LocationSpeed                  = Type=float, Min=0.000000, Max=10000.000000, Default="0", Value = "0"
+LocationVerticalAccuracy       = Type=float, Min=0.000000, Max=100000.000000, Default="100.0", Value = "100.0"
+MacOSSimulatorCustomSettings   = Type=string, Default="", Value = ""
+MacOSSimulatorDevices_ANDROID  = Type=string, Allowed="Samsung Galaxy S:480x800:512" "HTC Sensation XL:480x800:768" "Samsung Galaxy Note:800x1280:1024" "Motorola Droid Razr:540x960:1024" "Kindle Fire:1024x600:512" "Samsung Galaxy Tab:1024x600:512", Default="Samsung Galaxy S:480x800:512", Value = "Samsung Galaxy S:480x800:512"
+MacOSSimulatorDevices_IPHONE   = Type=string, Allowed="iPhone 3GS:320x480:256" "iPhone 4:640x960:512" "iPhone 5:640x1136:1024" "iPad:768x1024:256" "iPad 2:768x1024:512" "iPad 3:1536x2048:1024", Default="iPhone 3GS:320x480:256", Value = "iPhone 3GS:320x480:256"
+MacOSSimulatorPlatforms        = Type=string, Allowed="IPHONE" "ANDROID", Default="IPHONE", Value = "IPHONE"
+MacOSSimulatorUseCustomSettings = Type=bool, Default="true", Value = "true"
+MemoryPoison                   = Type=bool, Default="true", Value = "true"
+MemoryPoisonAlloc              = Type=int, Min=0.000000, Max=255.000000, Default="170", Value = "170"
+MemoryPoisonFree               = Type=int, Min=0.000000, Max=255.000000, Default="221", Value = "221"
+MemoryPoisonInit               = Type=int, Min=0.000000, Max=255.000000, Default="204", Value = "204"
+PointerAvailable               = Type=bool, Default="true", Value = "true"
+PointerMultiSimulationMode     = Type=bool, Default="false", Value = "false"
+PointerMultiTouchAvailable     = Type=bool, Default="false", Value = "false"
+PointerStylusType              = Type=string, Allowed="INVALID" "STYLUS" "FINGER", Default="INVALID", Value = "INVALID"
+PointerType                    = Type=string, Allowed="INVALID" "MOUSE" "STYLUS", Default="MOUSE", Value = "MOUSE"
+SMSEnabled                     = Type=bool, Default="true", Value = "true"
+SMSReceiveEnabled              = Type=bool, Default="true", Value = "true"
+SocketDNSDelay                 = Type=int, Min=0.000000, Max=30000.000000, Default="0", Value = "0"
+SocketHTTPProxy                = Type=string, Default="", Value = ""
+SocketHostName                 = Type=string, Default="", Value = ""
+SocketNetworkAvailable         = Type=bool, Default="true", Value = "true"
+SocketNetworkLoss              = Type=bool, Default="false", Value = "false"
+SocketNetworkType              = Type=string, Allowed="NONE" "UNKNOWN" "LAN" "WLAN" "GPRS" "UMTS" "EVDO" "CDMA2000" "HSDPA" "WIMAX" "BLUETOOTH" "EDGE" "CDMA" "IDEN" "LTE" "EHRPD" "HSPAPLUS", Default="LAN", Value = "LAN"
+SocketRecvLimit                = Type=int, Min=0.000000, Max=1000000.000000, Default="0", Value = "0"
+SocketSendLimit                = Type=int, Min=0.000000, Max=1000000.000000, Default="0", Value = "0"
+SoundEnabled                   = Type=bool, Default="true", Value = "true"
+SoundRecordEnabled             = Type=bool, Default="true", Value = "true"
+SoundSampleRate                = Type=int, Allowed="8192" "11025" "16000" "22050" "44100", Default="22050", Value = "22050"
+SoundStereo                    = Type=bool, Default="true", Value = "true"
+SoundVolumeDefault             = Type=int, Min=0.000000, Max=256.000000, Default="256", Value = "256"
+SurfaceDisableWhenGLIsActive   = Type=bool, Default="false", Value = "false"
+SurfaceDoubleBuffer            = Type=bool, Default="false", Value = "false"
+SurfaceHeight                  = Type=int, Min=128.000000, Max=4096.000000, Default="480", Value = "640"
+SurfacePitch                   = Type=int, Min=0.000000, Max=8192.000000, Default="0", Value = "0"
+SurfacePixelType               = Type=string, Allowed="RGB444" "RGB555" "RGB565" "RGB666" "RGB888" "BGR444" "BGR555" "BGR565" "BGR666" "BGR888", Default="RGB565", Value = "RGB565"
+SurfacePredefinedResolution    = Type=string, Allowed="176x200" "176x208" "240x320 (QVGA Portrait)" "240x400" "320x240 (QVGA Landscape)" "320x400" "320x480 (iPhone Portrait)" "400x240" "480x320 (iPhone Landscape)" "360x640 (qHD Portrait)" "640x360 (qHD Landscape)" "480x640 (VGA Portrait)" "480x800 (WVGA Portrait)" "640x480 (VGA Landscape)" "800x400" "800x480 (WVGA Landscape)" "640x960 (iPhone 4 Portrait)" "960x640 (iPhone 4 Landscape)" "640x1136 (iPhone 5 Portrait)" "1136x640 (iPhone 5 Landscape)" "1024x600 (Playbook Landscape)" "600x1024 (Playbook Portrait)" "768x1024 (iPad Portrait)" "1024x768 (iPad Landscape)" "2048x1536 (iPad Retina Landscape)" "1536x2048 (iPad Retina Portrait)", Default="320x480 (iPhone Portrait)", Value = "176x200"
+SurfaceRotation                = Type=string, Allowed="Rot0" "Rot90" "Rot180" "Rot270", Default="Rot0", Value = "Rot0"
+SurfaceUnalign                 = Type=bool, Default="true", Value = "true"
+SurfaceUseMultiBuffers         = Type=bool, Default="true", Value = "true"
+SurfaceWidth                   = Type=int, Min=128.000000, Max=4096.000000, Default="320", Value = "960"
+SymbianSoundLatency            = Type=int, Min=20.000000, Max=1400.000000, Default="120", Value = "120"
+ThreadEnabled                  = Type=bool, Default="true", Value = "true"
+TimerAccuracy                  = Type=int, Min=0.000000, Max=1000.000000, Default="0", Value = "0"
+TimerHiRes                     = Type=bool, Default="false", Value = "false"
+TimerLocaltimeOffsetHours      = Type=string, Allowed="-12" "-11" "-10" "-9" "-8" "-7" "-6" "-5" "-4" "-3" "-2" "-1" "0" "+1" "+2" "+3" "+4" "+5" "+6" "+7" "+8" "+9" "+10" "+11" "+12" "+13" "SYSTEM", Default="SYSTEM", Value = "SYSTEM"
+VibraEnabled                   = Type=bool, Default="true", Value = "true"
+Video3GPP                      = Type=bool, Default="false", Value = "false"
+VideoJPEG                      = Type=bool, Default="true", Value = "true"
+VideoMPEG4                     = Type=bool, Default="true", Value = "true"
+VideoVolumeDefault             = Type=int, Min=0.000000, Max=256.000000, Default="256", Value = "256"

BIN
examples/Game/part2/data/images/asteroid.png


BIN
examples/Game/part2/data/images/explosion.png


BIN
examples/Game/part2/data/images/finger.png


BIN
examples/Game/part2/data/images/joystick.png


BIN
examples/Game/part2/data/images/rocket.png


BIN
examples/Game/part2/data/images/ship.png


BIN
examples/Game/part2/data/images/shipengine.png


BIN
examples/Game/part2/data/images/sky.jpg


+ 17 - 0
examples/Game/part2/data/xmls/ui.xml

@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+<resources>
+	<set path = "images" />
+	<atlas>
+		<image file="joystick.png" />
+		<image file="finger.png" />
+	</atlas>
+
+	<atlas>
+		<image file="sky.jpg" />
+		<image file="ship.png" />
+		<image file="shipengine.png" />
+		<image file="rocket.png" />
+		<image file="explosion.png" cols="12"/>
+		<image file="asteroid.png"/>
+	</atlas>
+</resources>

+ 28 - 0
examples/Game/part2/game.mkb

@@ -0,0 +1,28 @@
+#!/usr/bin/env mkb
+
+options
+{
+	module_path="../../../oxygine/marmalade/"
+	enable-exceptions=1
+}
+
+includepath src
+
+files
+{
+	[src]
+	(src)
+	"*.h"
+	"*.cpp"
+}
+
+subprojects
+{
+	oxygine-framework
+	iwgl 
+}
+
+assets
+{
+	(data)
+}

+ 41 - 0
examples/Game/part2/src/Enemy.cpp

@@ -0,0 +1,41 @@
+#include "Enemy.h"
+#include "res.h"
+
+void Enemy::_init()
+{
+	//you could hit enemy 3 times
+	_hp = 3;
+
+	spSprite sprite = new Sprite;
+	sprite->setResAnim(res::ui.getResAnim("asteroid"));
+	sprite->attachTo(_view);
+	sprite->setAnchor(Vector2(0.5f, 0.5f));
+
+	//it random scale and rotation
+	sprite->setRotation(scalar::randFloat(0, MATH_PI * 2));
+	sprite->setScale(scalar::randFloat(0.5f, 1.0f));
+
+	//it is rotating by tween with random speed
+	float dest = MATH_PI * 2;
+	if (rand() % 2 == 0)
+		dest *= -1;
+	dest += sprite->getRotation();
+	sprite->addTween(Sprite::TweenRotation(dest), rand() % 15000 + 15000, -1);
+}
+
+void Enemy::_update(const UpdateState &us)
+{
+	//nothing to do
+}
+
+void Enemy::explode()
+{
+	//hit by rocket
+	_hp--;
+	if (_hp == 0)
+	{
+		//dead, hide it with alpha tween
+		_dead = true;
+		_view->addTween(Actor::TweenAlpha(0), 300)->setDetachActor(true);
+	}
+}

+ 15 - 0
examples/Game/part2/src/Enemy.h

@@ -0,0 +1,15 @@
+#pragma once
+#include "Unit.h"
+
+DECLARE_SMART(Enemy, spEnemy);
+class Enemy: public Unit
+{
+public:
+
+	void explode();
+
+private:
+	void _init();
+	void _update(const UpdateState &us);
+	int _hp;
+};

+ 76 - 0
examples/Game/part2/src/Game.cpp

@@ -0,0 +1,76 @@
+#include "Game.h"
+#include "Joystick.h"
+#include "Player.h"
+#include "res.h"
+#include "Enemy.h"
+
+Game::Game()
+{
+	
+}
+
+Game::~Game()
+{
+
+}
+
+void Game::init()
+{
+	//scene layer would have size of display
+	setSize(getRoot()->getSize());
+
+	//create background
+	spSprite sky = new Sprite;
+	sky->setResAnim(res::ui.getResAnim("sky"));
+	sky->attachTo(this);
+	
+	//create player ship
+	_player = new Player;
+	_player->init(getSize()/2, this);
+
+	//create separate layer for elements virtual joystick and other UI in future
+	_ui = new Actor;
+	_ui->attachTo(this);
+	//it would be higher than other actors with default priority = 0
+	_ui->setPriority(1);
+
+	//create virtual joystick and attach it to UI
+	_move = new Joystick;
+	_move->attachTo(_ui);
+	_move->setY(getHeight() - _move->getHeight());
+
+	//create virtual joystick and attach it to UI
+	_fire = new Joystick;
+	_fire->attachTo(_ui);
+	_fire->setX(getWidth() - _fire->getWidth());
+	_fire->setY(getHeight() - _fire->getHeight());
+
+
+	//create enemies
+	for (int i = 0; i < 10; ++i)
+	{
+		spEnemy enemy = new Enemy;
+		enemy->init(Vector2(scalar::randFloat(0, getWidth()), scalar::randFloat(0, getHeight())), this);
+	}	
+}
+
+void Game::doUpdate(const UpdateState &us)
+{
+	//update all units
+	//ship, rocket and enemies are in this list
+	for (units::iterator i = _units.begin(); i != _units.end(); )
+	{
+		spUnit unit = *i;
+		unit->update(us);
+
+		if (unit->isDead())
+		{
+			//it is dead. Time to remove it from list
+			i = _units.erase(i);
+		}
+		else
+		{
+			++i;
+		}
+	}
+}

+ 35 - 0
examples/Game/part2/src/Game.h

@@ -0,0 +1,35 @@
+#pragma once
+#include "oxygine-framework.h"
+#include <list>
+using namespace oxygine;
+
+DECLARE_SMART(Player, spPlayer);
+DECLARE_SMART(Joystick, spJoystick);
+DECLARE_SMART(Game, spGame);
+DECLARE_SMART(Rocket, spRocket);
+DECLARE_SMART(Unit, spUnit);
+
+class Game: public Actor
+{
+public:
+	Game();
+	~Game();
+
+	void init();
+
+protected:
+	friend class Rocket;
+	friend class Player;
+	friend class Unit;
+
+	void doUpdate(const UpdateState &us);
+
+	spActor _ui;
+	spJoystick _move;
+	spJoystick _fire;
+
+	spPlayer _player;
+
+	typedef std::list<spUnit> units;
+	units _units;
+};

+ 64 - 0
examples/Game/part2/src/Joystick.cpp

@@ -0,0 +1,64 @@
+#include "Joystick.h"
+#include "res.h"
+
+Joystick::Joystick():_pressed(false), _dir(0,0)
+{
+	setResAnim(res::ui.getResAnim("joystick"));
+	setAlpha(128);
+
+	//handle touch events
+	addEventListener(TouchEvent::TOUCH_DOWN, CLOSURE(this, &Joystick::onEvent));
+	addEventListener(TouchEvent::TOUCH_UP, CLOSURE(this, &Joystick::onEvent));
+	addEventListener(TouchEvent::MOVE, CLOSURE(this, &Joystick::onEvent));
+
+	_finger = new Sprite;
+	_finger->setResAnim(res::ui.getResAnim("finger"));
+	_finger->attachTo(this);
+	_finger->setVisible(false);
+	_finger->setAnchor(Vector2(0.5f, 0.5f));
+	_finger->setInputEnabled(false);
+}
+
+void Joystick::onEvent(Event *ev)
+{
+	TouchEvent *te = safeCast<TouchEvent *>(ev);
+
+	//if player touched down
+	if (te->type == TouchEvent::TOUCH_DOWN)
+	{
+		_finger->setVisible(true);
+		setColor(Color::Red);
+		_pressed = true;
+	}
+
+	//if player touched up
+	if (te->type == TouchEvent::TOUCH_UP)
+	{
+		_finger->setVisible(false);
+		setColor(Color::White);
+		_pressed = false;
+	}
+
+	if (te->type == TouchEvent::MOVE)
+	{
+	}
+
+	Vector2 center = getSize()/2;
+	_dir = te->localPosition - center;
+
+	if (_dir.length() > 100)
+		_dir.normalizeTo(100);
+
+	_finger->setPosition(center + _dir);
+
+	if (!_pressed)
+	{
+		_dir = Vector2(0,0);
+	}
+}
+
+bool Joystick::getDirection(Vector2 &dir) const
+{
+	dir = _dir;
+	return _pressed;
+}

+ 19 - 0
examples/Game/part2/src/Joystick.h

@@ -0,0 +1,19 @@
+#pragma once
+#include "oxygine-framework.h"
+using namespace oxygine;
+
+DECLARE_SMART(Joystick, spController);
+class Joystick: public Sprite
+{
+public:
+	Joystick();
+	
+	bool getDirection(Vector2 &dir) const;
+
+private:
+	void onEvent(Event *ev);
+	bool _pressed;
+	Vector2 _dir;
+
+	spSprite _finger;
+};

+ 67 - 0
examples/Game/part2/src/Player.cpp

@@ -0,0 +1,67 @@
+#include "Player.h"
+#include "Game.h"
+#include "res.h"
+#include "Joystick.h"
+#include "Rocket.h"
+
+Player::Player():_lastRocketSpawn(0)
+{
+
+}
+
+void Player::_init()
+{
+	//initialize player's ship
+	_view->setPosition(_game->getSize()/2);
+
+	_ship = new Sprite;
+	_ship->setResAnim(res::ui.getResAnim("ship"));
+	_ship->attachTo(_view);
+	_ship->setAnchor(Vector2(0.5f, 0.5f));
+
+	_engine = new Sprite;
+	_engine->setResAnim(res::ui.getResAnim("shipengine"));
+	_engine->attachTo(_ship);
+	//animate engine's fire
+	_engine->addTween(Sprite::TweenColor(Color::Red), 500, -1, true);
+	//by default it is hidden
+	//and would be visible only if ship moves
+	_engine->setVisible(false);
+}
+
+void Player::_update(const UpdateState &us)
+{
+	_engine->setVisible(false);
+
+	Vector2 dir;
+	if (_game->_move->getDirection(dir))
+	{
+		//update player position according to delta time and finger direction from virtual joystick
+		Vector2 pos = _view->getPosition();		
+		pos = pos + dir * (us.dt / 1000.0f) * 5;
+		_view->setPosition(pos);
+
+		//rotate it
+		float angle = atan2f(dir.y, dir.x);
+		_view->setRotation(angle);
+
+		//if player moves show engine's fire
+		_engine->setVisible(true);
+	}
+
+
+	if (_game->_fire->getDirection(dir))
+	{
+		//fire rockets each 300 ms
+		if (_lastRocketSpawn + 300 < us.time)
+		{
+			_lastRocketSpawn = us.time;
+
+			dir.normalize();
+
+			//create rocket
+			spRocket rocket = new Rocket(dir);
+			rocket->init(_view->getPosition(), _game);
+		}		
+	}
+}

+ 18 - 0
examples/Game/part2/src/Player.h

@@ -0,0 +1,18 @@
+#pragma once
+#include "Unit.h"
+
+DECLARE_SMART(Player, spPlayer);
+class Player: public Unit
+{
+public:
+	Player();
+
+	
+protected:
+	void _init();
+	void _update(const UpdateState &us);
+
+	spSprite _engine;	
+	spSprite _ship;	
+	timeMS _lastRocketSpawn;
+};

+ 80 - 0
examples/Game/part2/src/Rocket.cpp

@@ -0,0 +1,80 @@
+#include "Rocket.h"
+#include "res.h"
+#include "Game.h"
+#include "Enemy.h"
+
+Rocket::Rocket(const Vector2 &dir):_dir(dir)
+{	
+}
+
+void Rocket::_init()
+{
+	//initialize rocket's sprite
+	spSprite sp = new Sprite;
+	sp->setResAnim(res::ui.getResAnim("rocket"));
+	sp->setAnchor(Vector2(0.5f, 0.5f));
+	sp->setScale(0);
+	sp->addTween(Sprite::TweenScale(1.0f), 500);
+
+	_view->addChild(sp);
+	_view->setRotation(atan2f(_dir.y, _dir.x));	
+}
+
+void Rocket::_update(const UpdateState &us)
+{
+	//move rocket by it's direction each frame
+	Vector2 pos = _view->getPosition();
+	pos += _dir * (us.dt / 1000.0f) * 500.0f;
+	_view->setPosition(pos);
+
+	//find intersection with Enemies and explode them
+	for (Game::units::iterator i = _game->_units.begin(); i != _game->_units.end(); ++i)
+	{
+		spUnit unit = *i;
+		//list of units has everything, but we need only Enemies
+		spEnemy enemy = dynamic_cast<Enemy*>(unit.get());
+		if (!enemy)
+			continue;
+		
+		Vector2 d = unit->getPosition() - pos;		
+		if (d.length() < 20)
+		{
+			//if rocket is too close to Enemy then try to explode it and explode rocket
+			enemy->explode();
+			explode();
+
+			return;
+		}
+	}
+
+
+	//if rocked out of bounds then explode it
+	RectF bounds(0, 0, _game->getWidth(), _game->getHeight());
+	if (!bounds.pointIn(pos))
+	{
+		explode();
+	}
+}
+
+void Rocket::explode()
+{
+	//we are dead
+	//set this flag to true and it this rocket would be removed from units list in Game::doUpdate
+	_dead = true;
+
+	//create explode sprite
+	spSprite anim = new Sprite;
+	anim->attachTo(_game);
+	anim->setBlendMode(blend_add);
+	anim->setPosition(_view->getPosition());
+	anim->setAnchor(Vector2(0.5f, 0.5f));
+	
+	//run tween with explosion animation
+	spTween tween = anim->addTween(TweenAnim(res::ui.getResAnim("explosion")), 1000);
+	//auto detach sprite when tween is done
+	tween->setDetachActor(true);
+
+	//hide rocket and then detach it
+	tween = _view->addTween(Actor::TweenAlpha(0), 500);
+	tween->setDetachActor(true);
+}

+ 17 - 0
examples/Game/part2/src/Rocket.h

@@ -0,0 +1,17 @@
+#pragma once
+#include "oxygine-framework.h"
+#include "Unit.h"
+
+DECLARE_SMART(Rocket, spRocket);
+class Rocket: public Unit
+{
+public:
+	Rocket(const Vector2 &dir);
+	
+protected:
+	void _init();
+	void _update(const UpdateState &us);
+	void explode();
+
+	Vector2 _dir;
+};

+ 33 - 0
examples/Game/part2/src/Unit.cpp

@@ -0,0 +1,33 @@
+#include "Unit.h"
+#include "Game.h"
+
+Unit::Unit():_game(0), _dead(false)
+{
+
+}
+
+void Unit::init(const Vector2 &pos, Game *game)
+{
+	//initialize base
+	_game = game;
+	_view = new Actor;
+	_view->attachTo(game);
+	_view->setPosition(pos);
+
+	//adds to global units list
+	_game->_units.push_back(this);
+
+	//should be overloaded in inherited classes
+	_init();
+}
+
+const Vector2& Unit::getPosition() const
+{
+	return _view->getPosition();
+}
+
+void Unit::update(const UpdateState &us)
+{
+	//should be overloaded in inherited classes
+	_update(us);
+}

+ 26 - 0
examples/Game/part2/src/Unit.h

@@ -0,0 +1,26 @@
+#pragma once
+#include "oxygine-framework.h"
+using namespace oxygine;
+
+class Game;
+DECLARE_SMART(Unit, spUnit);
+class Unit: public Object
+{
+public:
+	Unit();
+
+	void init(const Vector2 &pos, Game *game);
+
+	const Vector2& getPosition() const;
+
+	void update(const UpdateState &us);
+	bool isDead() const {return _dead;}
+
+protected:
+	virtual void _init(){}
+	virtual void _update(const UpdateState &us){}
+
+	spActor _view;
+	Game *_game;
+	bool _dead;
+};

+ 183 - 0
examples/Game/part2/src/entry_point.cpp

@@ -0,0 +1,183 @@
+/**
+Attention!
+This file has Oxygine initialization stuff.
+If you just started you don't need to understand it exactly you could check it later. 
+You could start from example.cpp and example.h it has main functions being called from there
+*/
+#include <stdio.h>
+#include "core/Renderer.h"
+#include "RootActor.h"
+#include "DebugActor.h"
+
+#include "example.h"
+
+
+using namespace oxygine;
+
+Renderer renderer;
+Rect viewport;
+
+
+class ExampleRootActor: public RootActor
+{
+public:
+	ExampleRootActor()
+	{
+		//each mobile application should handle focus lost
+		//and free/restore GPU resources
+		addEventListener(RootActor::DEACTIVATE, CLOSURE(this, &ExampleRootActor::onDeactivate));
+		addEventListener(RootActor::ACTIVATE, CLOSURE(this, &ExampleRootActor::onActivate));
+	}
+
+	void onDeactivate(Event *)
+	{
+		core::reset();
+	}
+
+	void onActivate(Event *)
+	{
+		core::restore();
+	}
+};
+
+//called each frame
+int mainloop()
+{
+	example_update();
+	//update our rootActor
+	//Actor::update would be called also for children
+	getRoot()->update();
+
+	Color clear(33, 33, 33, 255);
+	//start rendering and clear viewport
+	if (renderer.begin(0, viewport, &clear))
+	{
+		//begin rendering from RootActor. 
+		getRoot()->render(renderer);
+		//rendering done
+		renderer.end();
+
+		core::swapDisplayBuffers();
+	}
+	
+
+	//update internal components
+	//all input events would be passed to RootActor::instance.handleEvent
+	//if done is true then User requests quit from app.
+	bool done = core::update();
+
+	return done ? 1 : 0;
+}
+
+//it is application entry point
+void run()
+{	
+	//initialize oxygine's internal stuff
+	core::init_desc desc;
+
+#if OXYGINE_SDL
+	//we could setup initial window size on SDL builds
+	//desc.w = 960;
+	//desc.h = 660;
+	//marmalade settings could be changed from emulator's menu
+#endif
+
+	core::init(&desc);	
+	example_preinit();
+	
+	//create RootActor. RootActor is a root node
+	RootActor::instance = new ExampleRootActor();	
+	Point size = core::getDisplaySize();
+	getRoot()->init(size, size);
+	
+	//DebugActor is a helper node it shows FPS and memory usage and other useful stuff
+	DebugActor::initialize();
+
+	//create and add new DebugActor to root actor as child
+	getRoot()->addChild(new DebugActor());
+
+
+	
+	Matrix view = makeViewMatrix(size.x, size.y); 
+
+	viewport = Rect(0, 0, size.x, size.y);
+
+	Matrix proj;
+	//initialize projection matrix
+	Matrix::orthoLH(proj, (float)size.x, (float)size.y, 0, 1);
+	
+	//Renderer is class helper for rendering primitives and batching them
+	//Renderer is lightweight class you could create it many of times
+	renderer.setDriver(IVideoDriver::instance);
+
+	//initialization view and projection matrix 	
+	//where Left Top corner is (0, 0), and right bottom is (width, height)
+	renderer.initCoordinateSystem(size.x, size.y);
+
+	//initialize this example stuff. see example.cpp
+	example_init();
+
+	bool done = false;	
+
+	//here is main game loop
+    while (1)
+    {
+		int done = mainloop();
+		if (done)
+			break;
+    }
+	//so user want to leave application...
+	
+	//lets dump all created objects into log
+	//all created and not freed resources would be displayed
+	ObjectBase::dumpCreatedObjects();
+
+	//lets cleanup everything right now and call ObjectBase::dumpObjects() again
+	//we need to free all allocated resources and delete all created actors
+	//all actors/sprites are smart pointer objects and actually you don't need it remove them by hands
+	//but now we want delete it by hands
+
+	//check example.cpp
+	example_destroy();	
+	
+
+	renderer.cleanup();
+
+	/**releases all internal components and RootActor*/
+	core::release();
+
+	//dump list should be empty now
+	//we deleted everything and could be sure that there aren't any memory leaks
+	ObjectBase::dumpCreatedObjects();
+	//end
+}
+
+#ifdef __S3E__
+int main(int argc, char* argv[])
+{
+    run();
+    return 0;
+}
+#endif
+
+
+#ifdef OXYGINE_SDL
+#include "SDL_main.h"
+extern "C"
+{
+	int main(int argc, char* argv[])
+	{
+		run();
+		return 0;
+	}
+};
+#endif
+
+#ifdef __FLASHPLAYER__
+int main(int argc, char* argv[])
+{
+	printf("test\n");
+	run();
+	return 0;
+}
+#endif

+ 29 - 0
examples/Game/part2/src/example.cpp

@@ -0,0 +1,29 @@
+#include "oxygine-framework.h"
+#include "res.h"
+#include "Game.h"
+using namespace oxygine;
+
+void example_preinit()
+{
+}
+
+void example_init()
+{
+	//load resources
+	res::load();
+
+	//create scene with game
+	spGame game = new Game;
+	game->init();
+	game->attachTo(getRoot());
+}
+
+void example_update()
+{
+
+}
+
+void example_destroy()
+{
+	res::free();
+}

+ 4 - 0
examples/Game/part2/src/example.h

@@ -0,0 +1,4 @@
+void example_preinit();
+void example_init();
+void example_destroy();
+void example_update();

+ 17 - 0
examples/Game/part2/src/res.cpp

@@ -0,0 +1,17 @@
+#include "res.h"
+
+namespace res
+{
+	Resources ui;
+
+	void load()
+	{
+		ui.loadXML("xmls/ui.xml");
+	}
+
+	void free()
+	{
+		ui.free();
+
+	}
+}

+ 10 - 0
examples/Game/part2/src/res.h

@@ -0,0 +1,10 @@
+#pragma once
+#include "oxygine-framework.h"
+using namespace oxygine;
+
+namespace res
+{
+	extern Resources ui;
+	void load();
+	void free();
+}

+ 2 - 0
oxygine/src/core/UberShaderProgram.cpp

@@ -52,6 +52,8 @@ namespace oxygine
 				s.program = 0;
 				s.program = 0;
 			}			
 			}			
 		}
 		}
+
+		unreg();
 	}
 	}
 
 
 	UberShaderProgram::shader *UberShaderProgram::getShaderProgram(int flags)
 	UberShaderProgram::shader *UberShaderProgram::getShaderProgram(int flags)