Browse Source

minor fixes, updated Match3 example

dmuratshin 11 years ago
parent
commit
e605f130f0

+ 2 - 2
.hg_archival.txt

@@ -1,5 +1,5 @@
 repo: b6d71054df5712e643a0685bc3ba54b123db5729
-node: 3ce2e34af01f3b61d2e1e1473ea82728506d761c
+node: b31f72c03aaf7bed6f7262af6f9192287b1920ac
 branch: default
 latesttag: oldrender
-latesttagdistance: 715
+latesttagdistance: 718

+ 0 - 2
examples/Match3/credits.txt

@@ -1,2 +0,0 @@
-thanks to Denis "qVadro" Sachkov for Match3 example source code
-email: [email protected]

BIN
examples/Match3/data/images/bg.png


+ 1 - 1
examples/Match3/data/resources.xml

@@ -7,7 +7,7 @@
 	<atlas>
 		<image file="bg.png"/>			
 
-		<set path = "images\jewels" scale_factor="0.5"/>	
+		<set path = "images\jewels"/>	
 
 		<image id="jewel1" file="air.png" />
 		<image id="jewel2" file="coin.png" />

+ 1 - 1
examples/Match3/proj.android/jni/src/Android.mk

@@ -6,7 +6,7 @@ LOCAL_MODULE := main
 #SDK_ROOT points to folder with SDL and oxygine-framework
 LOCAL_SRC_FILES := ../../../../../..//SDL/src/main/android/SDL_android_main.c
 
-LOCAL_SRC_FILES += ../../../src/entry_point.cpp ../../../src/example.cpp ../../../src/gameframe.cpp ../../../src/jewels.cpp ../../../src/shared.cpp 
+LOCAL_SRC_FILES += ../../../src/Board.cpp ../../../src/Jewel.cpp ../../../src/entry_point.cpp ../../../src/example.cpp ../../../src/shared.cpp 
 
 
 LOCAL_STATIC_LIBRARIES := oxygine-framework_static

+ 1 - 1
examples/Match3/proj.cmake/CMakeLists.txt

@@ -7,7 +7,7 @@ include_directories(${OXYGINE_INCLUDE_DIRS})
 link_directories(${OXYGINE_LIBRARY_DIRS})
 
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
-add_executable(Match3 ../src/entry_point.cpp ../src/example.cpp ../src/gameframe.cpp ../src/jewels.cpp ../src/shared.cpp  ../src/example.h ../src/gameframe.h ../src/jewels.h ../src/shared.h )
+add_executable(Match3 ../src/Board.cpp ../src/Jewel.cpp ../src/entry_point.cpp ../src/example.cpp ../src/shared.cpp  ../src/Board.h ../src/Jewel.h ../src/example.h ../src/shared.h )
 
 if (WIN32) #disable console mode for VC++
 	set_target_properties(Match3 PROPERTIES WIN32_EXECUTABLE TRUE)

+ 1 - 1
examples/Match3/proj.cmake/run.sh

@@ -13,4 +13,4 @@ make
 cd ../../data
 
 #run executable
-./../proj.cmake/build/Match3
+./../proj.cmake/build/${PROJECT}

+ 1 - 1
examples/Match3/proj.emscripten/CMakeLists.txt

@@ -9,7 +9,7 @@ link_directories(${OXYGINE_LIBRARY_DIRS})
 SET(CMAKE_EXECUTABLE_SUFFIX ".html")
 set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-Wno-warn-absolute-paths -std=c++11")
 
-add_executable(Match3 ../src/entry_point.cpp ../src/example.cpp ../src/gameframe.cpp ../src/jewels.cpp ../src/shared.cpp  ../src/example.h ../src/gameframe.h ../src/jewels.h ../src/shared.h )
+add_executable(Match3 ../src/Board.cpp ../src/Jewel.cpp ../src/entry_point.cpp ../src/example.cpp ../src/shared.cpp  ../src/Board.h ../src/Jewel.h ../src/example.h ../src/shared.h )
 
 if (CMAKE_BUILD_TYPE STREQUAL Debug)
 	SET(linkFlags "-g4 ")

+ 22 - 22
examples/Match3/proj.ios/Match3_ios.xcodeproj/project.pbxproj

@@ -22,10 +22,10 @@
 		04998EF817F8B6F3003441C3 /* libjpeg.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 04998EF617F8B6F3003441C3 /* libjpeg.a */; };
 		049B52B11871EBFA00EF3C66 /* liboxygine_ios.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 049B52AD1871EBBA00EF3C66 /* liboxygine_ios.a */; };
 		04E9AD3F1876FE84006A7317 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 04E9AD3E1876FE84006A7317 /* Images.xcassets */; };
-		2DC477AC10D6C07B3FE008F6 /* ../src/entry_point.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 360377333740D8A2FD15BBE6 /* ../src/entry_point.cpp */; };
-		DA49ED8903C628BA578C8670 /* ../src/example.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0BF9628FC8D38F9748F0CDEB /* ../src/example.cpp */; };
-		C8860D93875589970329DCCD /* ../src/gameframe.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DA100C319512824B7570663 /* ../src/gameframe.cpp */; };
-		1E839D002B2BA83FC83A695A /* ../src/jewels.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 04FE4D4FB640E0DF92DFB865 /* ../src/jewels.cpp */; };
+		2DC477AC10D6C07B3FE008F6 /* ../src/Board.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 360377333740D8A2FD15BBE6 /* ../src/Board.cpp */; };
+		DA49ED8903C628BA578C8670 /* ../src/Jewel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0BF9628FC8D38F9748F0CDEB /* ../src/Jewel.cpp */; };
+		C8860D93875589970329DCCD /* ../src/entry_point.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DA100C319512824B7570663 /* ../src/entry_point.cpp */; };
+		1E839D002B2BA83FC83A695A /* ../src/example.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 04FE4D4FB640E0DF92DFB865 /* ../src/example.cpp */; };
 		3A631A475DE035FC53ADE5EA /* ../src/shared.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7F3B12E3C9D554D9FE28101D /* ../src/shared.cpp */; };
 		CD59C69314E9E74CD0A11E03 /* ../data/fonts in Sources */ = {isa = PBXBuildFile; fileRef = F6123B1E6FE4471A00F49751 /* ../data/fonts */; };
 		EFF139F8BA484314F7AAF645 /* ../data/images in Sources */ = {isa = PBXBuildFile; fileRef = 5DE458993031811A4C7D28C1 /* ../data/images */; };
@@ -80,14 +80,14 @@
 		04998EF517F8B6F3003441C3 /* libpng.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libpng.a; path = "../../..//oxygine/third_party/ios/libraries/libpng.a"; sourceTree = "<group>"; };
 		04998EF617F8B6F3003441C3 /* libjpeg.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libjpeg.a; path = "../../..//oxygine/third_party/ios/libraries/libjpeg.a"; sourceTree = "<group>"; };
 		04E9AD3E1876FE84006A7317 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name =Images.xcassets; path = Match3/Images.xcassets; sourceTree = "<group>"; };
-		360377333740D8A2FD15BBE6 /* ../src/entry_point.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = entry_point.cpp; path = ../src/entry_point.cpp; sourceTree = "<group>"; };
-		0BF9628FC8D38F9748F0CDEB /* ../src/example.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = example.cpp; path = ../src/example.cpp; sourceTree = "<group>"; };
-		4DA100C319512824B7570663 /* ../src/gameframe.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = gameframe.cpp; path = ../src/gameframe.cpp; sourceTree = "<group>"; };
-		04FE4D4FB640E0DF92DFB865 /* ../src/jewels.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = jewels.cpp; path = ../src/jewels.cpp; sourceTree = "<group>"; };
+		360377333740D8A2FD15BBE6 /* ../src/Board.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Board.cpp; path = ../src/Board.cpp; sourceTree = "<group>"; };
+		0BF9628FC8D38F9748F0CDEB /* ../src/Jewel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Jewel.cpp; path = ../src/Jewel.cpp; sourceTree = "<group>"; };
+		4DA100C319512824B7570663 /* ../src/entry_point.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = entry_point.cpp; path = ../src/entry_point.cpp; sourceTree = "<group>"; };
+		04FE4D4FB640E0DF92DFB865 /* ../src/example.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = example.cpp; path = ../src/example.cpp; sourceTree = "<group>"; };
 		7F3B12E3C9D554D9FE28101D /* ../src/shared.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = shared.cpp; path = ../src/shared.cpp; sourceTree = "<group>"; };
-		2CE4BD5BB9DEF92439C0AB58 /* ../src/example.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = example.h; path = ../src/example.h; sourceTree = "<group>"; };
-		F196143B0370A9D348494ACC /* ../src/gameframe.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = gameframe.h; path = ../src/gameframe.h; sourceTree = "<group>"; };
-		7746CA7A63049ED8F7D6BF42 /* ../src/jewels.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = jewels.h; path = ../src/jewels.h; sourceTree = "<group>"; };
+		2CE4BD5BB9DEF92439C0AB58 /* ../src/Board.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Board.h; path = ../src/Board.h; sourceTree = "<group>"; };
+		F196143B0370A9D348494ACC /* ../src/Jewel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Jewel.h; path = ../src/Jewel.h; sourceTree = "<group>"; };
+		7746CA7A63049ED8F7D6BF42 /* ../src/example.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = example.h; path = ../src/example.h; sourceTree = "<group>"; };
 		D954BD82D7708B65A08FB6B9 /* ../src/shared.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = shared.h; path = ../src/shared.h; sourceTree = "<group>"; };
 		F6123B1E6FE4471A00F49751 /* ../data/fonts */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = folder; name = fonts; path = ../data/fonts; sourceTree = "<group>"; };
 		5DE458993031811A4C7D28C1 /* ../data/images */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = folder; name = images; path = ../data/images; sourceTree = "<group>"; };
@@ -189,14 +189,14 @@
 		04998D4417F8A9ED003441C3 /* src */ = {
 			isa = PBXGroup;
 			children = (
-				360377333740D8A2FD15BBE6 /* entry_point.cpp */, 
-				0BF9628FC8D38F9748F0CDEB /* example.cpp */, 
-				4DA100C319512824B7570663 /* gameframe.cpp */, 
-				04FE4D4FB640E0DF92DFB865 /* jewels.cpp */, 
+				360377333740D8A2FD15BBE6 /* Board.cpp */, 
+				0BF9628FC8D38F9748F0CDEB /* Jewel.cpp */, 
+				4DA100C319512824B7570663 /* entry_point.cpp */, 
+				04FE4D4FB640E0DF92DFB865 /* example.cpp */, 
 				7F3B12E3C9D554D9FE28101D /* shared.cpp */, 
-				2CE4BD5BB9DEF92439C0AB58 /* example.h */, 
-				F196143B0370A9D348494ACC /* gameframe.h */, 
-				7746CA7A63049ED8F7D6BF42 /* jewels.h */, 
+				2CE4BD5BB9DEF92439C0AB58 /* Board.h */, 
+				F196143B0370A9D348494ACC /* Jewel.h */, 
+				7746CA7A63049ED8F7D6BF42 /* example.h */, 
 				D954BD82D7708B65A08FB6B9 /* shared.h */, 
 
 			);
@@ -307,10 +307,10 @@
 			isa = PBXSourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
-				2DC477AC10D6C07B3FE008F6 /* entry_point.cpp */, 
-				DA49ED8903C628BA578C8670 /* example.cpp */, 
-				C8860D93875589970329DCCD /* gameframe.cpp */, 
-				1E839D002B2BA83FC83A695A /* jewels.cpp */, 
+				2DC477AC10D6C07B3FE008F6 /* Board.cpp */, 
+				DA49ED8903C628BA578C8670 /* Jewel.cpp */, 
+				C8860D93875589970329DCCD /* entry_point.cpp */, 
+				1E839D002B2BA83FC83A695A /* example.cpp */, 
 				3A631A475DE035FC53ADE5EA /* shared.cpp */, 
 
 			);

+ 22 - 22
examples/Match3/proj.macosx/Match3_macosx.xcodeproj/project.pbxproj

@@ -15,10 +15,10 @@
 		0405A00118720D2200BA6557 /* libpng.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 04059FF11872031A00BA6557 /* libpng.a */; };
 		049B57321871FBE900EF3C66 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 049B57311871FBE900EF3C66 /* Cocoa.framework */; };
 		049B574A1871FBE900EF3C66 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 049B57491871FBE900EF3C66 /* Images.xcassets */; };
-		2DC477AC10D6C07B3FE008F6 /* ../src/entry_point.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 360377333740D8A2FD15BBE6 /* ../src/entry_point.cpp */; };
-		DA49ED8903C628BA578C8670 /* ../src/example.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0BF9628FC8D38F9748F0CDEB /* ../src/example.cpp */; };
-		C8860D93875589970329DCCD /* ../src/gameframe.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DA100C319512824B7570663 /* ../src/gameframe.cpp */; };
-		1E839D002B2BA83FC83A695A /* ../src/jewels.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 04FE4D4FB640E0DF92DFB865 /* ../src/jewels.cpp */; };
+		2DC477AC10D6C07B3FE008F6 /* ../src/Board.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 360377333740D8A2FD15BBE6 /* ../src/Board.cpp */; };
+		DA49ED8903C628BA578C8670 /* ../src/Jewel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0BF9628FC8D38F9748F0CDEB /* ../src/Jewel.cpp */; };
+		C8860D93875589970329DCCD /* ../src/entry_point.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DA100C319512824B7570663 /* ../src/entry_point.cpp */; };
+		1E839D002B2BA83FC83A695A /* ../src/example.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 04FE4D4FB640E0DF92DFB865 /* ../src/example.cpp */; };
 		3A631A475DE035FC53ADE5EA /* ../src/shared.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7F3B12E3C9D554D9FE28101D /* ../src/shared.cpp */; };
 		CD59C69314E9E74CD0A11E03 /* ../data/fonts in Sources */ = {isa = PBXBuildFile; fileRef = F6123B1E6FE4471A00F49751 /* ../data/fonts */; };
 		EFF139F8BA484314F7AAF645 /* ../data/images in Sources */ = {isa = PBXBuildFile; fileRef = 5DE458993031811A4C7D28C1 /* ../data/images */; };
@@ -94,14 +94,14 @@
 		049B57391871FBE900EF3C66 /* demo_macosx-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Match3_macosx-Info.plist"; sourceTree = "<group>"; };
 		049B57491871FBE900EF3C66 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = Match3/Images.xcassets; sourceTree = "<group>"; };
 		049B57501871FBE900EF3C66 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; };
-		360377333740D8A2FD15BBE6 /* ../src/entry_point.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = entry_point.cpp; path = ../src/entry_point.cpp; sourceTree = "<group>"; };
-		0BF9628FC8D38F9748F0CDEB /* ../src/example.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = example.cpp; path = ../src/example.cpp; sourceTree = "<group>"; };
-		4DA100C319512824B7570663 /* ../src/gameframe.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = gameframe.cpp; path = ../src/gameframe.cpp; sourceTree = "<group>"; };
-		04FE4D4FB640E0DF92DFB865 /* ../src/jewels.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = jewels.cpp; path = ../src/jewels.cpp; sourceTree = "<group>"; };
+		360377333740D8A2FD15BBE6 /* ../src/Board.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Board.cpp; path = ../src/Board.cpp; sourceTree = "<group>"; };
+		0BF9628FC8D38F9748F0CDEB /* ../src/Jewel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Jewel.cpp; path = ../src/Jewel.cpp; sourceTree = "<group>"; };
+		4DA100C319512824B7570663 /* ../src/entry_point.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = entry_point.cpp; path = ../src/entry_point.cpp; sourceTree = "<group>"; };
+		04FE4D4FB640E0DF92DFB865 /* ../src/example.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = example.cpp; path = ../src/example.cpp; sourceTree = "<group>"; };
 		7F3B12E3C9D554D9FE28101D /* ../src/shared.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = shared.cpp; path = ../src/shared.cpp; sourceTree = "<group>"; };
-		2CE4BD5BB9DEF92439C0AB58 /* ../src/example.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = example.h; path = ../src/example.h; sourceTree = "<group>"; };
-		F196143B0370A9D348494ACC /* ../src/gameframe.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = gameframe.h; path = ../src/gameframe.h; sourceTree = "<group>"; };
-		7746CA7A63049ED8F7D6BF42 /* ../src/jewels.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = jewels.h; path = ../src/jewels.h; sourceTree = "<group>"; };
+		2CE4BD5BB9DEF92439C0AB58 /* ../src/Board.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Board.h; path = ../src/Board.h; sourceTree = "<group>"; };
+		F196143B0370A9D348494ACC /* ../src/Jewel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Jewel.h; path = ../src/Jewel.h; sourceTree = "<group>"; };
+		7746CA7A63049ED8F7D6BF42 /* ../src/example.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = example.h; path = ../src/example.h; sourceTree = "<group>"; };
 		D954BD82D7708B65A08FB6B9 /* ../src/shared.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = shared.h; path = ../src/shared.h; sourceTree = "<group>"; };
 		F6123B1E6FE4471A00F49751 /* ../data/fonts */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = folder; name = fonts; path = ../data/fonts; sourceTree = "<group>"; };
 		5DE458993031811A4C7D28C1 /* ../data/images */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = folder; name = images; path = ../data/images; sourceTree = "<group>"; };
@@ -206,14 +206,14 @@
 		04A57D391871FF8B0068B1E5 /* src */ = {
 			isa = PBXGroup;
 			children = (
-				360377333740D8A2FD15BBE6 /* entry_point.cpp */, 
-				0BF9628FC8D38F9748F0CDEB /* example.cpp */, 
-				4DA100C319512824B7570663 /* gameframe.cpp */, 
-				04FE4D4FB640E0DF92DFB865 /* jewels.cpp */, 
+				360377333740D8A2FD15BBE6 /* Board.cpp */, 
+				0BF9628FC8D38F9748F0CDEB /* Jewel.cpp */, 
+				4DA100C319512824B7570663 /* entry_point.cpp */, 
+				04FE4D4FB640E0DF92DFB865 /* example.cpp */, 
 				7F3B12E3C9D554D9FE28101D /* shared.cpp */, 
-				2CE4BD5BB9DEF92439C0AB58 /* example.h */, 
-				F196143B0370A9D348494ACC /* gameframe.h */, 
-				7746CA7A63049ED8F7D6BF42 /* jewels.h */, 
+				2CE4BD5BB9DEF92439C0AB58 /* Board.h */, 
+				F196143B0370A9D348494ACC /* Jewel.h */, 
+				7746CA7A63049ED8F7D6BF42 /* example.h */, 
 				D954BD82D7708B65A08FB6B9 /* shared.h */, 
 
 			);
@@ -348,10 +348,10 @@
 			isa = PBXSourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
-				2DC477AC10D6C07B3FE008F6 /* entry_point.cpp */, 
-				DA49ED8903C628BA578C8670 /* example.cpp */, 
-				C8860D93875589970329DCCD /* gameframe.cpp */, 
-				1E839D002B2BA83FC83A695A /* jewels.cpp */, 
+				2DC477AC10D6C07B3FE008F6 /* Board.cpp */, 
+				DA49ED8903C628BA578C8670 /* Jewel.cpp */, 
+				C8860D93875589970329DCCD /* entry_point.cpp */, 
+				1E839D002B2BA83FC83A695A /* example.cpp */, 
 				3A631A475DE035FC53ADE5EA /* shared.cpp */, 
 
 			);

+ 2 - 2
examples/Match3/proj.win32/Match3_vs2010.vcxproj

@@ -88,10 +88,10 @@
     </ProjectReference>
   </ItemGroup>
   <ItemGroup>
-    <ClCompile Include="../src/entry_point.cpp" /><ClCompile Include="../src/example.cpp" /><ClCompile Include="../src/gameframe.cpp" /><ClCompile Include="../src/jewels.cpp" /><ClCompile Include="../src/shared.cpp" />
+    <ClCompile Include="../src/Board.cpp" /><ClCompile Include="../src/Jewel.cpp" /><ClCompile Include="../src/entry_point.cpp" /><ClCompile Include="../src/example.cpp" /><ClCompile Include="../src/shared.cpp" />
   </ItemGroup>
   <ItemGroup>
-    <ClInclude Include="../src/example.h" /><ClInclude Include="../src/gameframe.h" /><ClInclude Include="../src/jewels.h" /><ClInclude Include="../src/shared.h" />
+    <ClInclude Include="../src/Board.h" /><ClInclude Include="../src/Jewel.h" /><ClInclude Include="../src/example.h" /><ClInclude Include="../src/shared.h" />
   </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">

+ 2 - 2
examples/Match3/proj.win32/Match3_vs2013.vcxproj

@@ -90,10 +90,10 @@
     </ProjectReference>
   </ItemGroup>
   <ItemGroup>
-    <ClCompile Include="../src/entry_point.cpp" /><ClCompile Include="../src/example.cpp" /><ClCompile Include="../src/gameframe.cpp" /><ClCompile Include="../src/jewels.cpp" /><ClCompile Include="../src/shared.cpp" />
+    <ClCompile Include="../src/Board.cpp" /><ClCompile Include="../src/Jewel.cpp" /><ClCompile Include="../src/entry_point.cpp" /><ClCompile Include="../src/example.cpp" /><ClCompile Include="../src/shared.cpp" />
   </ItemGroup>
   <ItemGroup>
-    <ClInclude Include="../src/example.h" /><ClInclude Include="../src/gameframe.h" /><ClInclude Include="../src/jewels.h" /><ClInclude Include="../src/shared.h" />
+    <ClInclude Include="../src/Board.h" /><ClInclude Include="../src/Jewel.h" /><ClInclude Include="../src/example.h" /><ClInclude Include="../src/shared.h" />
   </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">

+ 276 - 0
examples/Match3/src/Board.cpp

@@ -0,0 +1,276 @@
+#include "Board.h"
+#include "Jewel.h"
+
+Board::Board(): _size(0, 0), _selected(0)
+{
+
+}
+
+Vector2 getPos(const Point& p)
+{
+    Vector2 pos;
+    pos.x = p.x * JewelSize.x;
+    pos.y = p.y * JewelSize.y;
+    pos += JewelSize / 2;
+
+    return pos;
+}
+
+void Board::init(int w, int h)
+{
+    _size.x = w;
+    _size.y = h;
+
+    _view = new Sprite;
+
+    _field.resize(_size.x * _size.y);
+
+    for (int y = 0; y < _size.y; ++y)
+    {
+        for (int x = 0; x < _size.x; ++x)
+        {
+            _field[x + y * _size.x].pos = Point(x, y);
+        }
+    }
+
+    _view->setSize(_size.x * JewelSize.x, _size.y * JewelSize.y);
+
+    _view->addEventListener(TouchEvent::TOUCH_DOWN, CLOSURE(this, &Board::touched));
+    _view->setInputChildrenEnabled(false);
+
+    _view->setCallbackDoUpdate(CLOSURE(this, &Board::update));
+}
+
+struct swapData: public Object
+{
+    swapData(space* A, space* B): a(A), b(B) {}
+    space* a;
+    space* b;
+};
+
+spTween Board::swap(space& a, space& b)
+{
+    spTween tween;
+    tween = a.jewel->swap(getPos(b.pos));
+    tween = b.jewel->swap(getPos(a.pos));
+    std::swap(a.jewel, b.jewel);
+
+
+    tween->setDataObject(new swapData(&a, &b));
+    return tween;
+}
+
+
+void Board::swapped(Event* event)
+{
+    TweenEvent* te = safeCast<TweenEvent*>(event);
+    spObject data = te->tween->getDataObject();
+    swapData* sw = safeCast<swapData*>(data.get());
+    space& a = *sw->a;
+    space& b = *sw->b;
+    std::vector<space*> spaces;
+    findMatches(spaces, a);
+    findMatches(spaces, b);
+    if (spaces.empty())
+    {
+        a.jewel->swap(getPos(b.pos));
+        b.jewel->swap(getPos(a.pos));
+
+        std::swap(a.jewel, b.jewel);
+    }
+}
+
+space* Board::getSpace(const Point& pos, bool check)
+{
+    if (pos.x < 0 || pos.x >= _size.x)
+        return 0;
+    if (pos.y < 0 || pos.y >= _size.y)
+        return 0;
+
+    space& sp = _field[pos.x + pos.y * _size.x];
+    if (check)
+    {
+        if (!sp.jewel)
+            return 0;
+        if (sp.jewel->isExploding())
+            return 0;
+        if (sp.jewel->isSwaping())
+            return 0;
+        if (sp.jewel->isDead())
+            return 0;
+        if (sp.jewel->isFalling())
+            return 0;
+    }
+    return  &sp;
+}
+
+const Point dirUp(0, -1);
+const Point dirDown(0, 1);
+const Point dirLeft(-1, 0);
+const Point dirRight(1, 0);
+
+void Board::findMatches(std::vector<space*>& spaces, space& sp)
+{
+    std::vector<space*> hor;
+    findMatches(hor, sp, dirUp);
+    findMatches(hor, sp, dirDown);
+
+    std::vector<space*> ver;
+    findMatches(ver, sp, dirLeft);
+    findMatches(ver, sp, dirRight);
+
+    if (hor.size() >= 2)
+    {
+        spaces.insert(spaces.end(), hor.begin(), hor.end());
+    }
+
+    if (ver.size() >= 2)
+    {
+        spaces.insert(spaces.end(), ver.begin(), ver.end());
+    }
+
+    if (!spaces.empty())
+        spaces.push_back(&sp);
+}
+
+void Board::findMatches(std::vector<space*>& spaces, space& sp, const Point& dir)
+{
+    Point pos = sp.pos;
+    while (true)
+    {
+        pos += dir;
+        space* s = getSpace(pos);
+        if (!s)
+            return;
+        if (sp.jewel->getType() != s->jewel->getType())
+            return;
+
+        spaces.push_back(s);
+    }
+}
+
+void Board::update(const UpdateState& us)
+{
+    for (int y = 0; y < _size.y; ++y)
+    {
+        for (int x = 0; x < _size.x; ++x)
+        {
+            space* sp = getSpace(Point(x, y));
+            if (!sp)
+                continue;
+
+            std::vector<space*> spaces;
+            findMatches(spaces, *sp);
+
+            for (size_t i = 0; i < spaces.size(); ++i)
+            {
+                space* s = spaces[i];
+                s->jewel->explode();
+            }
+
+        }
+    }
+
+    for (int y = 0; y < _size.y; ++y)
+    {
+        for (int x = 0; x < _size.x; ++x)
+        {
+            space& sp = _field[x + y * _size.x];
+
+            spJewel jewel = sp.jewel;
+            if (!jewel)
+                continue;
+
+            if (jewel->isDead())
+                sp.jewel = 0;
+        }
+    }
+
+
+    for (int x = 0; x < _size.x; ++x)
+    {
+        float last_y = 0;
+        for (int y = _size.y - 1; y >= 0; --y)
+        {
+            space& sp = _field[x + y * _size.x];
+
+            if (!sp.jewel)
+            {
+                spJewel fallJewel;
+                for (int ty = y - 1; ty >= 0; --ty)
+                {
+                    space* fall = getSpace(Point(x, ty), false);
+                    if (!fall->jewel)
+                        continue;
+
+                    fallJewel = fall->jewel;
+                    fall->jewel = 0;
+                    break;
+                }
+
+
+                Vector2 newPos = getPos(sp.pos);
+
+                if (fallJewel)
+                {
+                    OX_ASSERT(fallJewel->isDead() == false);
+                }
+                else
+                {
+                    last_y -= JewelSize.y + 10 + rand() % 65;
+
+                    fallJewel = new Jewel;
+                    spActor view = fallJewel->getView();
+
+                    view->setPosition(Vector2(newPos.x, last_y));
+                    view->attachTo(_view);
+
+                }
+
+                fallJewel->fall(getPos(Point(x, y)));
+                sp.jewel = fallJewel;
+            }
+        }
+    }
+}
+
+void Board::touched(Event* event)
+{
+    TouchEvent* te = safeCast<TouchEvent*>(event);
+    Vector2 pos = te->localPosition;
+    //log::messageln("%d - %d: %.2f, %.2f", event->target->getObjectID(), event->currentTarget->getObjectID(), pos.x, pos.y);
+    Point spacePos;
+    spacePos.x = (int)(pos.x / JewelSize.x);
+    spacePos.y = (int)(pos.y / JewelSize.y);
+
+    space* sp = getSpace(spacePos);
+
+
+    if (_selected)
+    {
+        _selected->jewel->unselect();
+        if (sp)
+        {
+            Point dir = _selected->pos - sp->pos;
+            if (dir.x == 0 && abs(dir.y) == 1 ||
+                    dir.y == 0 && abs(dir.x) == 1)
+            {
+                spTween tween = swap(*_selected, *sp);
+                tween->setDoneCallback(CLOSURE(this, &Board::swapped));
+            }
+        }
+
+        _selected = 0;
+    }
+    else
+    {
+        _selected = sp;
+        if (sp)
+            sp->jewel->select();
+    }
+}
+
+spActor Board::getView()
+{
+    return _view;
+}

+ 45 - 0
examples/Match3/src/Board.h

@@ -0,0 +1,45 @@
+#pragma once
+#include <vector>
+#include "oxygine-framework.h"
+#include <vector>
+#include "Jewel.h"
+
+using namespace oxygine;
+
+DECLARE_SMART(Jewel, spJewel);
+
+struct space
+{
+    Point pos;
+    spJewel jewel;
+};
+
+class Board
+{
+public:
+    Board();
+
+    void init(int w, int h);
+
+    spActor getView();
+
+
+private:
+
+    space* getSpace(const Point& pos, bool check = true);
+
+    void update(const UpdateState& us);
+
+    spTween swap(space& a, space& b);
+    void touched(Event*);
+    void swapped(Event*);
+
+    void findMatches(std::vector<space*>& spaces, space& sp);
+    void findMatches(std::vector<space*>& spaces, space& sp, const Point& dir);
+
+    spSprite            _view;
+    space*              _selected;
+    spTween             _current;
+    std::vector<space>  _field;
+    Point               _size;
+};

+ 85 - 0
examples/Match3/src/Jewel.cpp

@@ -0,0 +1,85 @@
+#include "Jewel.h"
+#include "shared.h"
+
+const Vector2 JewelSize(100, 100);
+
+Jewel::Jewel(): _swaping(false), _exploding(false), _dead(false), _falling(false)
+{
+    _type = rand() % 6 + 1;
+
+    _view = new Sprite;
+
+    char name[255];
+    safe_sprintf(name, "jewel%d", _type);
+    ResAnim* rs = res.getResAnim(name);
+
+    _view->setResAnim(rs);
+
+
+    //set pilot to center of sprite
+    Vector2 center = _view->getSize() / 2;
+    //round center to avoid blurred image
+    center.x = int(center.x);
+    center.y = int(center.y);
+    _view->setAnchorInPixels(center);
+}
+
+spActor Jewel::getView() const
+{
+    return _view;
+}
+
+int     Jewel::getType() const
+{
+    return _type;
+}
+
+void Jewel::explode()
+{
+    _exploding = true;
+    float angle = 360 * (rand() % 2 ? -1 : 1);
+    spTween tween = _view->addTween(Actor::TweenRotationDegrees(angle), 500);
+    _view->addTween(Actor::TweenAlpha(0), 500);
+    tween->setDoneCallback(CLOSURE(this, &Jewel::exploded));
+}
+
+void Jewel::exploded(Event*)
+{
+    _dead = true;
+    _view->detach();
+}
+
+void Jewel::select()
+{
+    _view->addTween(Actor::TweenRotation(1), 500, -1, true);
+}
+
+void Jewel::unselect()
+{
+    _view->removeTweens(false);
+    _view->addTween(Actor::TweenRotation(0), 250);
+}
+
+void Jewel::fall(const Vector2& pos)
+{
+    _falling = true;
+    _view->addTween(Actor::TweenPosition(pos), 300) ->setDoneCallback(CLOSURE(this, &Jewel::fallen));
+}
+
+spTween Jewel::swap(const Vector2& pos)
+{
+    _swaping = true;
+    spTween tween = _view->addTween(Actor::TweenPosition(pos), 500);
+    tween->addDoneCallback(CLOSURE(this, &Jewel::swapped));
+    return tween;
+}
+
+void Jewel::swapped(Event*)
+{
+    _swaping = false;
+}
+
+void Jewel::fallen(Event*)
+{
+    _falling = false;
+}

+ 44 - 0
examples/Match3/src/Jewel.h

@@ -0,0 +1,44 @@
+#pragma once
+#include "oxygine-framework.h"
+
+using namespace oxygine;
+
+DECLARE_SMART(Jewel, spJewel);
+
+extern const Vector2 JewelSize;
+
+
+class Jewel: public Object
+{
+public:
+    Jewel();
+
+    spActor getView() const;
+    int     getType() const;
+
+    bool    isExploding() const {return _exploding;}
+    bool    isSwaping() const {return _swaping;}
+    bool    isDead() const {return _dead;}
+    bool    isFalling() const {return _falling;}
+
+
+    void explode();
+    void select();
+    void unselect();
+
+    void    fall(const Vector2& pos);
+    spTween swap(const Vector2& pos);
+
+private:
+    void exploded(Event*);
+    void fallen(Event*);
+    void swapped(Event*);
+
+    bool _exploding;
+    bool _swaping;
+    bool _dead;
+    bool _falling;
+    spSprite _view;
+
+    int _type;
+};

+ 13 - 2
examples/Match3/src/example.cpp

@@ -1,10 +1,13 @@
 #include "oxygine-framework.h"
 
-#include "gameframe.h"
+#include "Board.h"
 #include "shared.h"
 
 using namespace oxygine;
 
+
+Board board;
+
 void example_preinit()
 {
 
@@ -15,7 +18,15 @@ void example_init()
     //load xml file with resources definition
     res.loadXML("resources.xml");
 
-    getStage()->addChild(new GameFrame());
+    spSprite bg = new Sprite;
+    bg->setResAnim(res.getResAnim("bg"));
+    bg->attachTo(getStage());
+
+    board.init(6, 5);
+
+    spActor view = board.getView();
+    view->setPosition(getStage()->getSize() / 2 - view->getSize() / 2);
+    getStage()->addChild(view);
 }
 
 void example_destroy()

+ 0 - 498
examples/Match3/src/gameframe.cpp

@@ -1,498 +0,0 @@
-#include "gameframe.h"
-#include "shared.h"
-
-
-int Field::StartAnimation(Point ind)
-{
-    spTween tween = At(ind)->PlayAnimation();
-    if (tween)
-    {
-        tween->addEventListener(TweenEvent::DONE, CLOSURE(this, &Field::EndAnimationCallback));
-        animated_count++;
-    }
-    return 0;
-}
-
-int Field::goUp(Point ind, bool scoreit)
-{
-
-    Point next_ind = ind;
-    next_ind.y -= 1;
-    int sum = 1;
-
-    if (At(next_ind) && At(next_ind)->IsID(At(ind))) sum += goUp(next_ind, scoreit);
-    if (scoreit)
-    {
-        StartAnimation(ind);
-    }
-    return sum;
-}
-
-int Field::goDown(Point ind, bool scoreit)
-{
-
-    Point next_ind = ind;
-    next_ind.y += 1;
-    int sum = 1;
-
-    if (At(next_ind) && At(next_ind)->IsID(At(ind))) sum += goDown(next_ind, scoreit);
-    if (scoreit)
-    {
-        StartAnimation(ind);
-    }
-    return sum;
-}
-
-int Field::goRight(Point ind, bool scoreit)
-{
-
-    Point next_ind = ind;
-    next_ind.x += 1;
-    int sum = 1;
-
-    if (At(next_ind) && At(next_ind)->IsID(At(ind))) sum += goRight(next_ind, scoreit);
-    if (scoreit)
-    {
-        StartAnimation(ind);
-    }
-    return sum;
-}
-
-
-int Field::goLeft(Point ind, bool scoreit)
-{
-    Point next_ind = ind;
-    next_ind.x -= 1;
-    int sum = 1;
-
-    if (At(next_ind) && At(next_ind)->IsID(At(ind)))  sum += goLeft(next_ind, scoreit);
-    if (scoreit)
-    {
-        StartAnimation(ind);
-    }
-    return sum;
-}
-
-int Field::CheckJewel(Point ind, bool donotscore)
-{
-    int s1 = goLeft(ind);
-    s1 += goRight(ind) - 1;
-
-    int s2 = goUp(ind);
-    s2 += goDown(ind) - 1;
-
-    int bs = 0;
-
-
-    if (s2 > 2 && s1 > 2)
-    {
-        bs = s1 + s2 - 1;
-        if (donotscore)
-            return bs;
-
-        At(ind)->LockUnlock();
-        goLeft(ind, true);
-        goRight(ind, true);
-        goUp(ind, true);
-        At(ind)->LockUnlock();
-        goDown(ind, true);
-        return bs;
-    }
-
-    if (s1 > s2 && s1 > 2)
-    {
-        bs = s1 - 2;
-        if (donotscore)
-            return s1;
-
-        At(ind)->LockUnlock();
-        goLeft(ind, true);
-        At(ind)->LockUnlock();
-        goRight(ind, true);
-        return bs;
-    }
-
-    if (s2 > s1 && s2 > 2)
-    {
-        bs = s2 - 2;
-        if (donotscore)
-            return s2;
-        At(ind)->LockUnlock();
-        goUp(ind, true);
-        At(ind)->LockUnlock();
-        goDown(ind, true);
-        return bs;
-    }
-    return bs;
-}
-
-
-bool Field::FindSolutions()
-{
-    std::vector<TFieldSolutions> solutions;
-
-    for (int i = 0; i < FIELD_SIZE - 1; i++)
-    {
-        for (int j = 0; j < FIELD_SIZE; j++)
-        {
-            int points;
-            ForceSwap(jewels[i][j], jewels[i + 1][j]);
-            points = CheckJewel(Point(i, j), true);
-            if (points > 0)
-            {
-                solutions.push_back(TFieldSolutions(Point(i, j), Point(i + 1, j), points));
-            }
-            points += CheckJewel(Point(i + 1, j), true);
-            if (points > 0)
-            {
-                solutions.push_back(TFieldSolutions(Point(i + 1, j), Point(i, j), points));
-            }
-            ForceSwap(jewels[i][j], jewels[i + 1][j]);
-        }
-    }
-
-    for (int i = 0; i < FIELD_SIZE; i++)
-    {
-        for (int j = 0; j < FIELD_SIZE - 1; j++)
-        {
-            int points;
-            ForceSwap(jewels[i][j], jewels[i][j + 1]);
-            points = CheckJewel(Point(i, j), true);
-            if (points > 0)
-            {
-                solutions.push_back(TFieldSolutions(Point(i, j), Point(i, j + 1), points));
-            }
-            points += CheckJewel(Point(i, j + 1), true);
-            if (points > 0)
-            {
-                solutions.push_back(TFieldSolutions(Point(i, j + 1), Point(i, j), points));
-            }
-            ForceSwap(jewels[i][j], jewels[i][j + 1]);
-        }
-    }
-
-    if (solutions.empty())
-        return false;
-
-    return true;
-}
-
-
-void Field::FillField(bool first_time)
-{
-    for (int i = 0; i < FIELD_SIZE; i++)
-        for (int j = FIELD_SIZE - 1; j >= 0; j--)
-        {
-            if (first_time)
-            {
-                jewels[i][j] = new Jewel(rand() % 6);
-                jewels[i][j]->setPosition(getCellPosition(i, j));
-                jewels[i][j]->index = Point(i, j);
-                addChild(jewels[i][j]);
-            }
-            else
-                jewels[i][j]->Set(rand() % 6);
-        }
-
-    CleanField();
-}
-
-void Field::CleanField()
-{
-    bool ex;
-    do
-    {
-        ex = true;
-        for (int i = 0; i < FIELD_SIZE; i++)
-            for (int j = 0; j < FIELD_SIZE; j++)
-            {
-                if (CheckJewel(Point(i, j), true) > 0)
-                {
-                    jewels[i][j]->Set(rand() % 6);
-                    ex = false;
-                }
-            }
-    }
-    while (!ex);
-}
-
-bool Field::CheckField()
-{
-    std::vector<TFieldVariants> variants;
-    for (int i = 0; i < FIELD_SIZE; i++)
-        for (int j = 0; j < FIELD_SIZE; j++)
-        {
-            int points = CheckJewel(Point(i, j), true);
-            if (points > 0)
-            {
-                variants.push_back(TFieldVariants(Point(i, j), points));
-            }
-        }
-
-    if (variants.empty())
-    {
-        return false;
-    }
-    else
-    {
-        for (size_t i = 0; i < variants.size(); i++)
-        {
-            CheckJewel(variants.at(i).index);
-        }
-        variants.clear();
-        return true;
-    }
-}
-
-
-bool Field::BackSwap()
-{
-    if (back_swap)
-        return false;
-    back_swap = true;
-    Swap(At(jewel_drag_ind), At(jewel_new_ind));
-    return true;
-}
-
-
-void Field::DropEndCallback(Event* ev)
-{
-    safeSpCast<Jewel>(ev->target)->setState(jsNormal);
-    droped_count--;
-    if (droped_count == 0)
-    {
-        if (CheckField())
-            DropField();
-        else
-        {
-            if (FindSolutions())
-                state = fsWaiting;
-            else
-                RefreshField();
-        }
-    }
-}
-
-
-bool Field::Swap(spJewel First, spJewel Second, bool skip_animation)
-{
-    Point diff = getCellIndex(First->getPosition()) - getCellIndex(Second->getPosition());
-    if (abs(diff.x) > 1 || (abs(diff.y) > 1) ||
-            abs(diff.x) == abs(diff.y) || Second == First ||
-            !(Second->getState() == jsNormal && First->getState() == jsNormal))
-        return false;
-
-    ForceSwap(First, Second);
-
-    if (!skip_animation)
-    {
-        state = fsAnimation;
-
-        jewel_new_ind  = getCellIndex(First->getPosition());
-        jewel_drag_ind = getCellIndex(Second->getPosition());
-
-        First->addTween(Sprite::TweenPosition(Second->getPosition()), 200);
-        Second->addTween(Sprite::TweenPosition(First->getPosition()), 200)->addEventListener(TweenEvent::DONE, CLOSURE(this, &Field::EndSwapCallback));
-    }
-
-    return true;
-}
-
-void Field::JewelClick(Event* event)
-{
-    TouchEvent* te = safeCast<TouchEvent*>(event);
-    Point ind = getCellIndex(te->localPosition);
-
-    if (state == fsSwaping)
-    {
-        if (At(ind))
-        {
-            state = fsWaiting;
-            At(jewel_drag_ind)->UnSelect();
-            At(ind)->UnSelect();
-            back_swap = false;
-            Swap(At(ind), At(jewel_drag_ind));
-        }
-    }
-
-    if (state == fsWaiting)
-    {
-        if (At(ind))
-        {
-            //At(ind)->PlayAnimation();
-            jewel_drag_ind = ind;
-            At(ind)->SetSelected();
-            state = fsSwaping;
-        }
-    }
-
-    DropField();
-}
-
-int Field::FindFreeCell(int column, int limit)
-{
-    int free = -1;
-    for (int j = FIELD_SIZE - 1; j > limit; j--)
-        if (jewels[column][j]->getState() == jsScored)
-        {
-            free = j;
-            break;
-        }
-
-    return free;
-}
-
-void Field::ForceSwap(spJewel First, spJewel Second)
-{
-    Point first_index = First->index;
-    Point second_index = Second->index;
-
-    jewels[first_index.x][first_index.y] = Second;
-    jewels[first_index.x][first_index.y]->index = first_index;
-
-    jewels[second_index.x][second_index.y] = First;
-    jewels[second_index.x][second_index.y]->index = second_index;
-}
-
-void  Field::DropJewel(spJewel Target, spJewel Jewel)
-{
-    if (Jewel->getState() != jsNormal)
-        return;
-
-    if (Target->getState() != jsScored)
-        return;
-
-    spTween tween = Jewel->DropTo(Target->getPosition());
-    tween->addEventListener(TweenEvent::DONE, CLOSURE(this, &Field::DropEndCallback));
-    Target->setPosition(getCellPosition(Jewel->index.x, Jewel->index.y));
-    ForceSwap(Target, Jewel);
-    droped_count++;
-}
-
-void Field::RefreshField()
-{
-    for (int i = 0; i < FIELD_SIZE; i++)
-    {
-        for (int j = FIELD_SIZE - 1; j >= 0; j--)
-        {
-            jewels[i][j]->setState(jsScored);
-        }
-        GenerateNewJewels(i);
-    }
-    CleanField();
-}
-
-int Field::GenerateNewJewels(int column)
-{
-    int count = 0;
-    for (int j = FIELD_SIZE - 1; j >= 0; j--)
-    {
-        if (jewels[column][j]->getState() == jsScored)
-        {
-            Vector2 pos = jewels[column][j]->getPosition();
-            jewels[column][j]->Set(rand() % 6);
-            jewels[column][j]->setVisible(true);
-            jewels[column][j]->setPosition(Vector2(pos.x, -getPosition().y - count * (JEWEL_SIZE + rand() % 10 + 20)));
-            spTween tween = jewels[column][j]->DropTo(pos);
-            droped_count++;
-            tween->addEventListener(TweenEvent::DONE, CLOSURE(this, &Field::DropEndCallback));
-            count++;
-
-        }
-    }
-
-    return 0;
-}
-
-bool Field::DropField()
-{
-    for (int i = 0; i < FIELD_SIZE; i++)
-    {
-        for (int j = FIELD_SIZE - 1; j >= 0; j--)
-        {
-            if (jewels[i][j]->getState() == jsNormal)
-            {
-                int free = FindFreeCell(i, j);
-                if (free != -1)
-                {
-                    DropJewel(jewels[i][free], jewels[i][j]);
-                }
-            }
-        }
-        GenerateNewJewels(i);
-    }
-
-    if (droped_count > 0)
-        state = fsAnimation;
-    return true;
-}
-
-void Field::EndAnimationCallback(Event* ev)
-{
-    safeSpCast<Jewel>(ev->target)->AnimationEnd();
-    animated_count--;
-
-    if (animated_count == 0)
-        DropField();
-}
-
-void Field::EndSwapCallback(Event* ev)
-{
-    if (CheckField())
-    {
-        state = fsAnimation;
-    }
-    else
-    {
-        if (!BackSwap()) state = fsWaiting;
-    }
-}
-
-Field::Field()
-{
-    animated_count = 0;
-    droped_count = 0;
-    back_swap = false;
-
-    EventCallback cb = CLOSURE(this, &Field::JewelClick);
-    addEventListener(TouchEvent::TOUCH_DOWN, cb);
-    state = fsWaiting;
-
-    setSize(JEWEL_SIZE * FIELD_SIZE, JEWEL_SIZE * FIELD_SIZE);
-
-    FillField(true);
-    RefreshField();
-}
-
-spJewel Field::At(Point index)
-{
-    if (index.x > -1 && index.y > -1 && index.x < FIELD_SIZE && index.y < FIELD_SIZE)
-        return jewels[index.x][index.y];
-    else
-        return NULL;
-}
-
-
-Point Field::getCellIndex(Vector2 position)
-{
-    return Point(position.x / JEWEL_SIZE, position.y / JEWEL_SIZE);
-}
-
-Vector2 Field::getCellPosition(int i, int j)
-{
-    return Vector2(i * JEWEL_SIZE + JEWEL_SIZE / 2, j * JEWEL_SIZE + JEWEL_SIZE / 2);
-}
-
-//////////////////////////////////////////////////////////////////////////////////////////
-
-GameFrame::GameFrame()
-{
-    setResAnim(res.getResAnim("bg"));
-
-    spTField field = new Field();
-    float scale = getStage()->getHeight() * 0.9f / field->getHeight();
-    field->setScale(scale);
-
-    field->setPosition(getStage()->getSize() / 2 - field->getSize() * scale / 2);
-    addChild(field);
-}

+ 0 - 102
examples/Match3/src/gameframe.h

@@ -1,102 +0,0 @@
-#pragma once
-#include "Actor.h"
-#include "TextField.h"
-#include "Button.h"
-#include "jewels.h"
-
-#define FIELD_SIZE 6
-
-
-
-using namespace oxygine;
-
-DECLARE_SMART(GameFrame, spGameFrame);
-DECLARE_SMART(Field, spTField);
-DECLARE_SMART(TFieldSolutions, spTFieldSolutions);
-
-typedef enum {fsWaiting, fsSwaping, fsFalling, fsChecking, fsAutoSwaping, fsAnimation} TFieldState;
-
-class TFieldSolutions
-{
-public:
-    Point target;
-    Point jewel;
-
-    int jewel_count;
-
-    TFieldSolutions(Point Target, Point Jewel, int count)
-    {
-        target = Target;
-        jewel = Jewel;
-        jewel_count = count;
-    }
-
-};
-
-class TFieldVariants
-{
-public:
-    Point index;
-    int points;
-    TFieldVariants(Point Index, int score) {index = Index; points = score;}
-};
-
-
-class Field : public Actor
-{
-public:
-    TFieldState getState() {return state;}
-
-    spJewel jewels[FIELD_SIZE][FIELD_SIZE];
-
-    Field();
-    spJewel At(Point index);
-
-    Vector2 getCellPosition(int i, int j);
-    Point getCellIndex(Vector2 position);
-
-    void JewelClick(Event* event);
-    bool Swap(spJewel First, spJewel Second, bool skip_animation = false);
-    bool BackSwap();
-
-private:
-    TFieldState state;
-    Vector2 size;
-
-    Point jewel_drag_ind;
-    Point jewel_new_ind;
-    int droped_count;
-    int animated_count;
-
-    int goUp(Point ind, bool scoreit = false);
-    int goDown(Point ind, bool scoreit = false);
-    int goRight(Point ind, bool scoreit = false);
-    int goLeft(Point ind, bool scoreit = false);
-    int CheckJewel(Point ind, bool donotscore = false);
-
-    void EndSwapCallback(Event* ev);
-    void EndAnimationCallback(Event* ev);
-    void DropEndCallback(Event* ev);
-
-    bool back_swap;
-    bool DropField();
-    void DropJewel(spJewel Target, spJewel Jewel);
-    void ForceSwap(spJewel First, spJewel Second);
-    int FindFreeCell(int column, int limit = 0);
-    int StartAnimation(Point ind);
-    int GenerateNewJewels(int column);
-    bool CheckField();
-    void CleanField();
-    void FillField(bool first_time = false);
-    bool FindSolutions();
-    void RefreshField();
-};
-
-
-
-class GameFrame : public Sprite
-{
-public:
-    GameFrame();
-
-};

+ 0 - 75
examples/Match3/src/jewels.cpp

@@ -1,75 +0,0 @@
-#include "jewels.h"
-#include "shared.h"
-#include "math.h"
-
-Jewel::Jewel(int jewel_id)
-{
-    locked = false;
-
-    state = jsNormal;
-    Set(jewel_id);
-    setTouchEnabled(false);
-    setAnchor(0.5f, 0.5f);
-}
-
-void Jewel::Set(int id)
-{
-    setResAnim(res.getResAnim(jewels_ids[id]));
-    _id = id;
-    setAlpha(255);
-}
-
-
-void Jewel::UnSelect()
-{
-    if (state != jsSelected)
-        return;
-
-    state = jsNormal;
-    setRotation(0);
-    setPosition(old_position);
-    removeTweens();
-}
-
-void Jewel::SetSelected()
-{
-    if (state != jsNormal)
-        return;
-
-    state = jsSelected;
-    spTweenQueue tween = new TweenQueue();
-    old_position = getPosition();
-    //setPosition(getX() + JEWEL_SIZE/2, getY() + JEWEL_SIZE/2);
-
-    tween->add(Sprite::TweenRotation(MATH_PI * 0.1f), 100);
-    tween->add(Sprite::TweenRotation(MATH_PI  * (-0.1f)), 400, -1, true);
-
-
-    addTween(tween);
-}
-
-
-spTween Jewel::PlayAnimation()
-{
-    if (!(state == jsNormal && locked))
-        return 0;
-
-    state = jsAnimation;
-
-    string anim = jewels_ids[_id];
-    return addTween(Sprite::TweenAlpha(0), 500, 1);
-}
-
-spTween Jewel::DropTo(Vector2 pos)
-{
-    int time = fabs(getPosition().y - pos.y) * 2;
-    spTween tween = addTween(Sprite::TweenPosition(pos), time);
-    state = jsDropped;
-    return tween;
-}
-
-void Jewel::AnimationEnd()
-{
-    state = jsScored;
-    setVisible(false);
-}

+ 0 - 44
examples/Match3/src/jewels.h

@@ -1,44 +0,0 @@
-#pragma once
-
-#include "oxygine-framework.h"
-
-using namespace std;
-using namespace oxygine;
-
-
-#define JEWEL_SIZE 50
-
-
-
-DECLARE_SMART(Jewel, spJewel);
-
-typedef enum {jsNormal, jsAnimation, jsSelected, jsScored, jsDropped} TJewelState;
-
-const string jewels_ids[6] = {"jewel1", "jewel2", "jewel3", "jewel4", "jewel5", "jewel6"};
-
-class Jewel : public Sprite
-{
-    Vector2 old_position;
-    TJewelState state;
-    int _id;
-    bool locked;
-
-public:
-    Jewel(int jewel_id);
-
-    Point index;
-    void LockUnlock() {locked = !locked;}
-    TJewelState getState() {return state;}
-    void setState(TJewelState new_state) {state = new_state;}
-
-    int GetId() {return _id;}
-
-    void SetSelected();
-    void UnSelect();
-    spTween DropTo(Vector2 pos);
-    bool IsID(spJewel spJewel) {return spJewel->GetId() == _id;}
-    void Set(int id);
-
-    spTween PlayAnimation();
-    void AnimationEnd();
-};

+ 1 - 1
oxygine/src/Button.cpp

@@ -118,7 +118,7 @@ namespace oxygine
         }
     }
 
-    void Button::setResAnim(const ResAnim* r)
+    void Button::setResAnim(const ResAnim* r, int, int)
     {
         _resAnim = r;
         updateButtonState(_state);

+ 1 - 1
oxygine/src/Button.h

@@ -17,7 +17,7 @@ namespace oxygine
 
         int getRow() const {return _row;}
 
-        void setResAnim(const ResAnim* r);
+        void setResAnim(const ResAnim* r, int  col = 0, int row = 0) OVERRIDE;
 
         /**Sets which row from ResAnim should be used. Default value is 0. Could be used for CheckBoxes*/
         void setRow(int row);

+ 4 - 4
oxygine/src/Tween.h

@@ -125,10 +125,10 @@ namespace oxygine
         /**set Delay before starting tween*/
         void setDelay(timeMS delay) { _delay = delay; }
         /** loops = -1 means infinity repeat cycles*/
-        void setLoops(int loops) { _loops = loops; }        
-		/*set Duration of tween**/
-		void setDuration(timeMS duration) { _duration = duration; }
-		void setClient(Actor* client) { _client = client; }
+        void setLoops(int loops) { _loops = loops; }
+        /*set Duration of tween**/
+        void setDuration(timeMS duration) { _duration = duration; }
+        void setClient(Actor* client) { _client = client; }
 
         /**delete actor from parent node when tween done*/
         void setDetachActor(bool detach) { _detach = detach; }

+ 2 - 0
tools/gen_template.py

@@ -43,6 +43,8 @@ def run(args):
             args.src = dest + "/src"
             args.dest = dest + "/proj." + p
             _run(args)
+    else:
+        _run(args)
             
 
 def _run(args):

+ 4 - 4
tools/others/gen_templates.py

@@ -5,12 +5,12 @@ def gen(path, project = ""):
 	if not project:
 		project = path
 
-	#projs = ("win32", "android", "macosx", "ios", "cmake", "emscripten")
+	projs = ("win32", "android", "macosx", "ios", "cmake", "emscripten")
 	
 	#projs = ("ios", "macosx")
 	#projs = ("macosx", )	
 	#projs = ("win32", )
-	projs = ("cmake", )	
+	#projs = ("cmake", )	
 	#projs = ("android", )
 	#projs = ("emscripten", )
 
@@ -26,7 +26,7 @@ def gen(path, project = ""):
 
 
 
-if 1:
+if 0:
 	gen("Demo")
 	gen("Game/part1", "GamePart1")
 	gen("Game/part2", "GamePart2")
@@ -38,4 +38,4 @@ if 1:
 	gen("Match3")
 
 
-gen("DemoBox2D")
+gen("Match3")