diff --git a/.classpath b/.classpath
new file mode 100644
index 0000000..36de7ba
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/.project b/.project
new file mode 100644
index 0000000..4c7a50f
--- /dev/null
+++ b/.project
@@ -0,0 +1,33 @@
+
+
+ EngineWrapper
+
+
+
+
+
+ com.android.ide.eclipse.adt.ResourceManagerBuilder
+
+
+
+
+ com.android.ide.eclipse.adt.PreCompilerBuilder
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ com.android.ide.eclipse.adt.ApkBuilder
+
+
+
+
+
+ com.android.ide.eclipse.adt.AndroidNature
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
new file mode 100644
index 0000000..59a113e
--- /dev/null
+++ b/AndroidManifest.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Readme.txt b/Readme.txt
new file mode 100644
index 0000000..c7412e3
--- /dev/null
+++ b/Readme.txt
@@ -0,0 +1,8 @@
+Шаблон для приложения Android
+Как установить:
+1) Кинуть все содержимое в каталог Android/ВашеПриложение/
+2) Придумать название приложению и название для package, вписать их в AndroidManifest.xml, в JniWrapper.java, MainActivity.java, правильно расположить java-файлы.
+3) Придумать и ввести название своей Jni-библиотеки игры в Android.mk (LOCAL_MODULE : = MyAppLib), это же название библиотеки вбить в JniWrapper.java.
+4) переименовать jni-методы в android_api.h/cpp в соответствии с названиями package.
+5) Не забыть про иконки
+6) Написать скрипт сборки и можно запускать!
diff --git a/assets/anim_tex.bmp b/assets/anim_tex.bmp
new file mode 100644
index 0000000..1be364e
Binary files /dev/null and b/assets/anim_tex.bmp differ
diff --git a/assets/button_normal.bmp b/assets/button_normal.bmp
new file mode 100644
index 0000000..eb444a8
Binary files /dev/null and b/assets/button_normal.bmp differ
diff --git a/assets/button_pressed.bmp b/assets/button_pressed.bmp
new file mode 100644
index 0000000..22f0341
Binary files /dev/null and b/assets/button_pressed.bmp differ
diff --git a/assets/cave_hd.png b/assets/cave_hd.png
new file mode 100644
index 0000000..91127af
Binary files /dev/null and b/assets/cave_hd.png differ
diff --git a/assets/chips/chip1.png b/assets/chips/chip1.png
new file mode 100644
index 0000000..80b2dbd
Binary files /dev/null and b/assets/chips/chip1.png differ
diff --git a/assets/chips/chip1.xml b/assets/chips/chip1.xml
new file mode 100644
index 0000000..021e533
--- /dev/null
+++ b/assets/chips/chip1.xml
@@ -0,0 +1,10 @@
+
+
+ 83
+ 166
+ 250
+ 333
+ 416
+ 500
+
+
\ No newline at end of file
diff --git a/assets/chips/chip1_nmap.png b/assets/chips/chip1_nmap.png
new file mode 100644
index 0000000..2572435
Binary files /dev/null and b/assets/chips/chip1_nmap.png differ
diff --git a/assets/chips/chip1finish.bmp b/assets/chips/chip1finish.bmp
new file mode 100644
index 0000000..444f2dd
Binary files /dev/null and b/assets/chips/chip1finish.bmp differ
diff --git a/assets/chips/chip1locked.bmp b/assets/chips/chip1locked.bmp
new file mode 100644
index 0000000..9e84876
Binary files /dev/null and b/assets/chips/chip1locked.bmp differ
diff --git a/assets/chips/chip2.png b/assets/chips/chip2.png
new file mode 100644
index 0000000..7160638
Binary files /dev/null and b/assets/chips/chip2.png differ
diff --git a/assets/chips/chip2.xml b/assets/chips/chip2.xml
new file mode 100644
index 0000000..6505c17
--- /dev/null
+++ b/assets/chips/chip2.xml
@@ -0,0 +1,16 @@
+
+
+ 83
+ 166
+ 250
+ 333
+ 416
+ 500
+ 583
+ 666
+ 750
+ 833
+ 916
+ 1000
+
+
\ No newline at end of file
diff --git a/assets/chips/chip2_nmap.png b/assets/chips/chip2_nmap.png
new file mode 100644
index 0000000..0d51ee2
Binary files /dev/null and b/assets/chips/chip2_nmap.png differ
diff --git a/assets/chips/chip2finish.bmp b/assets/chips/chip2finish.bmp
new file mode 100644
index 0000000..444f2dd
Binary files /dev/null and b/assets/chips/chip2finish.bmp differ
diff --git a/assets/chips/chip2locked.bmp b/assets/chips/chip2locked.bmp
new file mode 100644
index 0000000..8373b44
Binary files /dev/null and b/assets/chips/chip2locked.bmp differ
diff --git a/assets/chips/chip3.png b/assets/chips/chip3.png
new file mode 100644
index 0000000..a2eef42
Binary files /dev/null and b/assets/chips/chip3.png differ
diff --git a/assets/chips/chip3.xml b/assets/chips/chip3.xml
new file mode 100644
index 0000000..96b0ab3
--- /dev/null
+++ b/assets/chips/chip3.xml
@@ -0,0 +1,16 @@
+
+
+ 83
+ 166
+ 250
+ 333
+ 416
+ 500
+ 583
+ 666
+ 750
+ 833
+ 916
+ 1000
+
+
\ No newline at end of file
diff --git a/assets/chips/chip3finish.bmp b/assets/chips/chip3finish.bmp
new file mode 100644
index 0000000..444f2dd
Binary files /dev/null and b/assets/chips/chip3finish.bmp differ
diff --git a/assets/chips/chip3locked.bmp b/assets/chips/chip3locked.bmp
new file mode 100644
index 0000000..0c53faa
Binary files /dev/null and b/assets/chips/chip3locked.bmp differ
diff --git a/assets/chips/chip4.bmp b/assets/chips/chip4.bmp
new file mode 100644
index 0000000..73f5bf3
Binary files /dev/null and b/assets/chips/chip4.bmp differ
diff --git a/assets/chips/chip4.png b/assets/chips/chip4.png
new file mode 100644
index 0000000..fbef774
Binary files /dev/null and b/assets/chips/chip4.png differ
diff --git a/assets/chips/chip4.xml b/assets/chips/chip4.xml
new file mode 100644
index 0000000..eafb4ab
--- /dev/null
+++ b/assets/chips/chip4.xml
@@ -0,0 +1,16 @@
+
+
+ 83
+ 166
+ 250
+ 333
+ 416
+ 500
+ 583
+ 666
+ 750
+ 833
+ 916
+ 1000
+
+
\ No newline at end of file
diff --git a/assets/chips/chip4finish.bmp b/assets/chips/chip4finish.bmp
new file mode 100644
index 0000000..444f2dd
Binary files /dev/null and b/assets/chips/chip4finish.bmp differ
diff --git a/assets/chips/chip4locked.bmp b/assets/chips/chip4locked.bmp
new file mode 100644
index 0000000..2d3f672
Binary files /dev/null and b/assets/chips/chip4locked.bmp differ
diff --git a/assets/console_bkg.bmp b/assets/console_bkg.bmp
new file mode 100644
index 0000000..d32ee4c
Binary files /dev/null and b/assets/console_bkg.bmp differ
diff --git a/assets/fonts.xml b/assets/fonts.xml
new file mode 100644
index 0000000..02431eb
--- /dev/null
+++ b/assets/fonts.xml
@@ -0,0 +1,5 @@
+
+droid_sans14
+fonts/droid_sans14_font_bitmap.bmp32
+fonts/droid_sans14_font_charmap.txt
+
\ No newline at end of file
diff --git a/assets/fonts/droid_sans14_font_bitmap.bmp32 b/assets/fonts/droid_sans14_font_bitmap.bmp32
new file mode 100644
index 0000000..b9f2b1f
Binary files /dev/null and b/assets/fonts/droid_sans14_font_bitmap.bmp32 differ
diff --git a/assets/fonts/droid_sans14_font_charmap.txt b/assets/fonts/droid_sans14_font_charmap.txt
new file mode 100644
index 0000000..f17cd0b
--- /dev/null
+++ b/assets/fonts/droid_sans14_font_charmap.txt
@@ -0,0 +1,95 @@
+32 0.00976562 0.0195312 0 0.0546875 0 0 0.0078125
+49 0.0195312 0.0195312 0.00390625 0.015625 0.0078125 0.0390625 0.015625
+50 0.0371094 0.0195312 0.00195312 0.015625 0.0136719 0.0390625 0.015625
+51 0.0605469 0.0195312 0.00195312 0.015625 0.0117188 0.0390625 0.015625
+52 0.0820312 0.0195312 0.00195312 0.015625 0.0136719 0.0390625 0.015625
+53 0.105469 0.0195312 0.00195312 0.015625 0.0117188 0.0390625 0.015625
+54 0.126953 0.0195312 0.00195312 0.015625 0.0117188 0.0390625 0.015625
+55 0.148438 0.0195312 0.00195312 0.015625 0.0117188 0.0390625 0.015625
+56 0.169922 0.0195312 0.00195312 0.015625 0.0117188 0.0390625 0.015625
+57 0.191406 0.0195312 0.00195312 0.015625 0.0117188 0.0390625 0.015625
+48 0.212891 0.0195312 0.00195312 0.015625 0.0117188 0.0390625 0.015625
+97 0.234375 0.0195312 0.00195312 0.0234375 0.00976562 0.03125 0.0136719
+98 0.253906 0.0195312 0.00195312 0.0117188 0.0117188 0.0429688 0.015625
+99 0.275391 0.0195312 0.00195312 0.0234375 0.00976562 0.03125 0.0136719
+100 0.294922 0.0195312 0.00195312 0.0117188 0.0117188 0.0429688 0.015625
+101 0.316406 0.0195312 0.00195312 0.0234375 0.0117188 0.03125 0.015625
+102 0.337891 0.0195312 0 0.0117188 0.00976562 0.0429688 0.0078125
+103 0.357422 0.0195312 0.00195312 0.0234375 0.0136719 0.0429688 0.0136719
+104 0.380859 0.0195312 0.00195312 0.0117188 0.0117188 0.0429688 0.015625
+105 0.402344 0.0195312 0 0.0117188 0.00585938 0.0429688 0.0078125
+106 0.417969 0.0195312 -0.00195312 0.0117188 0.0078125 0.0546875 0.0078125
+107 0.435547 0.0195312 0.00195312 0.0117188 0.0136719 0.0429688 0.0136719
+108 0.458984 0.0195312 0.00195312 0.0117188 0.00390625 0.0429688 0.0078125
+109 0.472656 0.0195312 0.00195312 0.0234375 0.0214844 0.03125 0.0253906
+110 0.503906 0.0195312 0.00195312 0.0234375 0.0117188 0.03125 0.015625
+111 0.525391 0.0195312 0.00195312 0.0234375 0.0117188 0.03125 0.015625
+112 0.546875 0.0195312 0.00195312 0.0234375 0.0117188 0.0429688 0.015625
+113 0.568359 0.0195312 0.00195312 0.0234375 0.0117188 0.0429688 0.015625
+114 0.589844 0.0195312 0.00195312 0.0234375 0.0078125 0.03125 0.00976562
+115 0.607422 0.0195312 0 0.0234375 0.0117188 0.03125 0.0136719
+116 0.628906 0.0195312 0 0.015625 0.00976562 0.0390625 0.00976562
+117 0.648438 0.0195312 0.00195312 0.0234375 0.0117188 0.03125 0.015625
+118 0.669922 0.0195312 -0.00195312 0.0234375 0.0175781 0.03125 0.0136719
+119 0.697266 0.0195312 -0.00195312 0.0234375 0.0234375 0.03125 0.0195312
+120 0.730469 0.0195312 0 0.0234375 0.0136719 0.03125 0.0136719
+121 0.753906 0.0195312 -0.00195312 0.0234375 0.0175781 0.0429688 0.0136719
+122 0.78125 0.0195312 0.00195312 0.0234375 0.0117188 0.03125 0.0136719
+65 0.802734 0.0195312 -0.00195312 0.015625 0.0214844 0.0390625 0.0175781
+66 0.833984 0.0195312 0.00195312 0.015625 0.0136719 0.0390625 0.0175781
+67 0.857422 0.0195312 0.00195312 0.015625 0.0136719 0.0390625 0.015625
+68 0.880859 0.0195312 0.00195312 0.015625 0.015625 0.0390625 0.0195312
+69 0.90625 0.0195312 0.00195312 0.015625 0.00976562 0.0390625 0.0136719
+70 0.925781 0.0195312 0.00195312 0.015625 0.0117188 0.0390625 0.0136719
+71 0.947266 0.0195312 0.00195312 0.015625 0.015625 0.0390625 0.0195312
+72 0.00976562 0.09375 0.00195312 0.015625 0.015625 0.0390625 0.0195312
+73 0.0351562 0.09375 0 0.015625 0.00976562 0.0390625 0.00976562
+74 0.0546875 0.09375 -0.00390625 0.015625 0.00976562 0.0507812 0.00585938
+75 0.0742188 0.09375 0.00195312 0.015625 0.015625 0.0390625 0.015625
+76 0.0996094 0.09375 0.00195312 0.015625 0.0117188 0.0390625 0.0136719
+77 0.121094 0.09375 0.00195312 0.015625 0.0195312 0.0390625 0.0234375
+78 0.150391 0.09375 0.00195312 0.015625 0.015625 0.0390625 0.0195312
+79 0.175781 0.09375 0.00195312 0.015625 0.0175781 0.0390625 0.0214844
+80 0.203125 0.09375 0.00195312 0.015625 0.0117188 0.0390625 0.015625
+81 0.224609 0.09375 0.00195312 0.015625 0.0175781 0.046875 0.0214844
+82 0.251953 0.09375 0.00195312 0.015625 0.0136719 0.0390625 0.015625
+83 0.275391 0.09375 0 0.015625 0.0136719 0.0390625 0.0136719
+84 0.298828 0.09375 0 0.015625 0.0136719 0.0390625 0.0136719
+85 0.322266 0.09375 0.00195312 0.015625 0.015625 0.0390625 0.0195312
+86 0.347656 0.09375 -0.00195312 0.015625 0.0195312 0.0390625 0.015625
+87 0.376953 0.09375 -0.00195312 0.015625 0.0292969 0.0390625 0.0253906
+88 0.416016 0.09375 -0.00195312 0.015625 0.0195312 0.0390625 0.015625
+89 0.445312 0.09375 -0.00195312 0.015625 0.0175781 0.0390625 0.0136719
+90 0.472656 0.09375 0.00195312 0.015625 0.0117188 0.0390625 0.015625
+46 0.494141 0.09375 0.00195312 0.046875 0.00390625 0.0078125 0.0078125
+44 0.507812 0.09375 0.00195312 0.046875 0.00390625 0.0117188 0.0078125
+58 0.521484 0.09375 0.00195312 0.0234375 0.00390625 0.03125 0.0078125
+59 0.535156 0.09375 0.00195312 0.0234375 0.00390625 0.0351562 0.0078125
+64 0.548828 0.09375 0.00195312 0.015625 0.0195312 0.0429688 0.0234375
+35 0.578125 0.09375 0 0.015625 0.015625 0.0390625 0.0175781
+36 0.603516 0.09375 0.00195312 0.0117188 0.0117188 0.046875 0.015625
+37 0.625 0.09375 0.00195312 0.015625 0.0195312 0.0390625 0.0234375
+94 0.654297 0.09375 0 0.015625 0.0136719 0.0234375 0.0136719
+38 0.677734 0.09375 0.00195312 0.015625 0.0175781 0.0390625 0.0195312
+42 0.705078 0.09375 0 0.0117188 0.0136719 0.0234375 0.015625
+33 0.728516 0.09375 0.00195312 0.015625 0.00390625 0.0390625 0.0078125
+63 0.742188 0.09375 0 0.015625 0.00976562 0.0390625 0.0117188
+40 0.761719 0.09375 0.00195312 0.015625 0.0078125 0.046875 0.0078125
+41 0.779297 0.09375 0 0.015625 0.00585938 0.046875 0.0078125
+91 0.794922 0.09375 0.00195312 0.015625 0.00585938 0.046875 0.0078125
+93 0.810547 0.09375 0 0.015625 0.00585938 0.046875 0.0078125
+123 0.826172 0.09375 0 0.015625 0.00976562 0.046875 0.00976562
+125 0.845703 0.09375 0 0.015625 0.00976562 0.046875 0.00976562
+60 0.865234 0.09375 0.00195312 0.0234375 0.0117188 0.0273438 0.015625
+62 0.886719 0.09375 0.00195312 0.0234375 0.0117188 0.0273438 0.015625
+95 0.908203 0.09375 0 0.0585938 0.0117188 0.00390625 0.0117188
+45 0.929688 0.09375 0.00195312 0.0390625 0.00585938 0.0078125 0.00976562
+43 0.945312 0.09375 0 0.0234375 0.0136719 0.0273438 0.015625
+61 0.00976562 0.167969 0 0.0273438 0.0136719 0.0195312 0.015625
+124 0.0332031 0.167969 0.00585938 0.0117188 0.00390625 0.0546875 0.0136719
+92 0.046875 0.167969 -0.00195312 0.015625 0.0136719 0.0390625 0.00976562
+47 0.0703125 0.167969 -0.00195312 0.015625 0.0136719 0.0390625 0.00976562
+126 0.09375 0.167969 0.00195312 0.03125 0.0117188 0.0117188 0.015625
+96 0.115234 0.167969 0.00585938 0.0117188 0.00585938 0.0078125 0.015625
+34 0.130859 0.167969 0.00195312 0.015625 0.00976562 0.015625 0.0117188
+39 0.150391 0.167969 0.00195312 0.015625 0.00390625 0.015625 0.00585938
\ No newline at end of file
diff --git a/assets/function_info_list.xml b/assets/function_info_list.xml
new file mode 100644
index 0000000..6c9b9d9
--- /dev/null
+++ b/assets/function_info_list.xml
@@ -0,0 +1,44 @@
+
+
+ p
+ Print
+ Print out string to console
+ This command prints out string to console. Example: p("Hello world");
+
+
+ help
+ Help
+ Print out all available functions to console
+ This command prints out all available functions to console with short description. Example: help();
+
+
+ man
+ Manual
+ Print out information about function
+ This command prints out all information about asked function. Example: man("p");
+
+
+ ptl
+ PrintTextureList
+ Print out list of all textures loaded
+ This command prints out list of textures that is loaded at this time with their ref count. Example: ptl();
+
+
+ pal
+ PrintAnimationList
+ Print out list of all animations loaded
+ This command prints out list of animations that is loaded at this time. Example: pal();
+
+
+ pwl
+ PrintWidgetList
+ Print out list of widgets registered in system
+ This command prints out list of widgets that is available at this time. Example: pwl();
+
+
+ mw
+ MoveWidget
+ Move widget on screen
+ This command immediately moves widgets on screen. First param is widget's name, last two params - distance for X and Y. Example: mw("StartButton", -5, 100.5);
+
+
\ No newline at end of file
diff --git a/assets/match3params.xml b/assets/match3params.xml
new file mode 100644
index 0000000..e5a3260
--- /dev/null
+++ b/assets/match3params.xml
@@ -0,0 +1,47 @@
+
+ 7
+ 7
+ 64.0
+ 64.0
+ -0.5
+ -0.0014
+ 1.0
+ 0.3
+ 0.4
+ 150
+ 4
+
+
+ DefaultShader
+ chip1
+
+ chip1
+ chips/chip1.xml
+ chips/chip1.xml
+
+
+ DefaultShader
+ chip2
+
+ chip2
+ chips/chip2.xml
+ chips/chip2.xml
+
+
+ DefaultShader
+ chip3
+
+ chip3
+ chips/chip3.xml
+ chips/chip3.xml
+
+
+ DefaultShader
+ chip4
+
+ chip4
+ chips/chip4.xml
+ chips/chip4.xml
+
+
+
\ No newline at end of file
diff --git a/assets/shaders.xml b/assets/shaders.xml
new file mode 100644
index 0000000..d2a8df3
--- /dev/null
+++ b/assets/shaders.xml
@@ -0,0 +1,7 @@
+
+
+DefaultShader
+shaders/shader_vertex.txt
+shaders/shader_fragment.txt
+
+
\ No newline at end of file
diff --git a/assets/shaders/shader_bump_fragment.txt b/assets/shaders/shader_bump_fragment.txt
new file mode 100644
index 0000000..63528af
--- /dev/null
+++ b/assets/shaders/shader_bump_fragment.txt
@@ -0,0 +1,35 @@
+precision lowp float;
+uniform sampler2D Texture;
+uniform sampler2D NormalMap;
+uniform float Transparency;
+varying vec2 texCoord;
+varying vec2 posCoord;
+
+void main()
+{
+ vec3 lightPos = vec3(400.0, 200.0, 200.0);
+
+ vec3 lVec = normalize(lightPos - vec3(posCoord, 0.0));
+
+ vec3 texParam = texture2D(NormalMap, texCoord.st).rgb;
+ vec3 normVec;
+ if (texParam.x == 0.0 && texParam.y == 0.0 && texParam.z == 0.0)
+ {
+ normVec = vec3(0.0,0.0,1.0);
+ }
+ else
+ {
+ normVec = (texture2D(NormalMap, texCoord.st).rgb - 0.5)* 2.0;
+
+ }
+
+ vec4 diffuse = vec4(1.0, 1.0, 1.0, 1.0) * max( dot(lVec, normVec), 0.0) * 0.5;
+ //vec4 diffuse = vec4(1.0, 1.0, 1.0, 1.0) * 0.5;
+
+ vec4 color = texture2D(Texture, texCoord).rgba * 0.5 + texture2D(Texture, texCoord).rgba * diffuse;
+
+ gl_FragColor = vec4(color.rgb, color.a * Transparency);
+
+
+
+}
\ No newline at end of file
diff --git a/assets/shaders/shader_bump_vertex.txt b/assets/shaders/shader_bump_vertex.txt
new file mode 100644
index 0000000..5e57020
--- /dev/null
+++ b/assets/shaders/shader_bump_vertex.txt
@@ -0,0 +1,14 @@
+attribute vec3 vPosition;
+attribute vec2 vTexCoord;
+varying vec2 texCoord;
+varying vec2 posCoord;
+
+uniform mat4 ProjectionMatrix;
+
+void main()
+{
+ //480x320
+ gl_Position = ProjectionMatrix * vec4(vPosition.xyz, 1.0);
+ posCoord = vPosition.xy;
+ texCoord = vTexCoord;
+}
\ No newline at end of file
diff --git a/assets/shaders/shader_fragment.txt b/assets/shaders/shader_fragment.txt
new file mode 100644
index 0000000..2893d3d
--- /dev/null
+++ b/assets/shaders/shader_fragment.txt
@@ -0,0 +1,14 @@
+precision lowp float;
+uniform sampler2D Texture;
+uniform float Transparency;
+varying vec2 texCoord;
+
+void main()
+{
+ vec4 color = texture2D(Texture, texCoord).rgba;
+
+ gl_FragColor = vec4(color.rgb, color.a * Transparency);
+
+
+
+}
\ No newline at end of file
diff --git a/assets/shaders/shader_vertex.txt b/assets/shaders/shader_vertex.txt
new file mode 100644
index 0000000..72d9f46
--- /dev/null
+++ b/assets/shaders/shader_vertex.txt
@@ -0,0 +1,12 @@
+attribute vec3 vPosition;
+attribute vec2 vTexCoord;
+varying vec2 texCoord;
+
+uniform mat4 ProjectionMatrix;
+
+void main()
+{
+ //480x320
+ gl_Position = ProjectionMatrix * vec4(vPosition.xyz, 1.0);
+ texCoord = vTexCoord;
+}
\ No newline at end of file
diff --git a/assets/test_animation.xml b/assets/test_animation.xml
new file mode 100644
index 0000000..1de72af
--- /dev/null
+++ b/assets/test_animation.xml
@@ -0,0 +1,11 @@
+
+
+
+100
+200
+300
+400
+
+
\ No newline at end of file
diff --git a/assets/textures.xml b/assets/textures.xml
new file mode 100644
index 0000000..349e39f
--- /dev/null
+++ b/assets/textures.xml
@@ -0,0 +1,20 @@
+
+console_bkg.bmp
+cave_hd.pngcave_hd
+button_normal.bmpbutton_normal
+button_pressed.bmpbutton_pressed
+chips/chip1.pngchip1
+chips/chip1_nmap.pngchip1_nmap
+chips/chip2.pngchip2
+chips/chip2_nmap.pngchip2_nmap
+chips/chip3.pngchip3
+chips/chip4.pngchip4
+chips/chip1locked.bmpchip1locked
+chips/chip2locked.bmpchip2locked
+chips/chip3locked.bmpchip3locked
+chips/chip4locked.bmpchip4locked
+chips/chip1finish.bmpchip1finish
+chips/chip2finish.bmpchip2finish
+chips/chip3finish.bmpchip3finish
+chips/chip4finish.bmpchip4finish
+
\ No newline at end of file
diff --git a/default.properties b/default.properties
new file mode 100644
index 0000000..0b9250e
--- /dev/null
+++ b/default.properties
@@ -0,0 +1,11 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system use,
+# "build.properties", and override values to adapt the script to your
+# project structure.
+
+# Project target.
+target=android-8
diff --git a/jni/Android.mk b/jni/Android.mk
new file mode 100644
index 0000000..54a5998
--- /dev/null
+++ b/jni/Android.mk
@@ -0,0 +1,91 @@
+# Copyright (C) 2009 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+
+LPATH := $(call my-dir)
+
+ENGINE_PATH = $(SalmonEnginePathCygwin)
+
+BOOST_PATH = $(LibsPathCygwin)/boost_1_47_0
+
+OGG_PATH = $(LibsPathCygwin)/libogg-1.3.0
+
+VORBIS_PATH = $(LibsPathCygwin)/libvorbis-1.3.2
+
+SQUIRREL_PATH = $(LibsPathCygwin)/sqplus
+
+LIBPNG_PATH = $(LibsPathCygwin)/libpng_1.4.1_android
+
+ZIP_PATH = $(LibsPathCygwin)/julienr-libzip-android/jni
+
+#ENGINE_PATH = $(SalmonEnginePath)
+
+#BOOST_PATH = $(LibsPath)/boost_1_47_0
+
+#OGG_PATH = $(LibsPath)/libogg-1.3.0
+
+#VORBIS_PATH = $(LibsPath)/libvorbis-1.3.2
+
+#SQUIRREL_PATH = $(LibsPath)/sqplus
+
+#LIBPNG_PATH = $(LibsPath)/libpng_1.4.1_android
+
+#ZIP_PATH = $(LibsPath)/julienr-libzip-android/jni
+
+#====== ENGINE AND LIBS =====================
+
+include $(ENGINE_PATH)/Android_Engine.mk
+
+
+#================= THE GAME =======================
+
+
+LOCAL_PATH:= $(LPATH)
+
+include $(CLEAR_VARS)
+
+#LOCAL_CFLAGS := -DTARGET_ANDROID -DTARGET_HALIBUT -g -ggdb -O0
+LOCAL_CFLAGS := -DTARGET_ANDROID -DTARGET_HALIBUT
+LOCAL_STATIC_LIBRARIES := boost
+LOCAL_STATIC_LIBRARIES += squirrel
+LOCAL_STATIC_LIBRARIES += png_lib
+LOCAL_STATIC_LIBRARIES += zip
+LOCAL_SHARED_LIBRARIES := HalibutEngine
+LOCAL_SHARED_LIBRARIES += gnustl_shared
+LOCAL_C_INCLUDES := $(ENGINE_PATH)
+LOCAL_C_INCLUDES += $(BOOST_PATH)
+LOCAL_C_INCLUDES += $(VORBIS_PATH)/include
+LOCAL_C_INCLUDES += $(VORBIS_PATH)/include/vorbis
+LOCAL_C_INCLUDES += $(VORBIS_PATH)/lib
+LOCAL_C_INCLUDES += $(VORBIS_PATH)/lib/books
+LOCAL_C_INCLUDES += $(VORBIS_PATH)/lib/modes
+LOCAL_C_INCLUDES += $(OGG_PATH)/include
+LOCAL_C_INCLUDES += $(OGG_PATH)/include/ogg
+LOCAL_C_INCLUDES += $(SQUIRREL_PATH)/include
+LOCAL_C_INCLUDES += $(SQUIRREL_PATH)/sqplus
+LOCAL_C_INCLUDES += $(SQUIRREL_PATH)/squirrel
+LOCAL_C_INCLUDES += $(SQUIRREL_PATH)/sqstdlib
+LOCAL_C_INCLUDES += $(LIBPNG_PATH)
+LOCAL_C_INCLUDES += $(ZIP_PATH)
+LOCAL_MODULE := CrystalOfRhylilLib
+LOCAL_SRC_FILES := main_code.cpp
+LOCAL_SRC_FILES += android_api.cpp
+LOCAL_SRC_FILES += match3/match3field.cpp
+
+LOCAL_LDLIBS := -lGLESv2
+#LOCAL_LDLIBS += -llog -Wl -g -ggdb -lz
+LOCAL_LDLIBS += -llog -Wl -lz
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/jni/Application.mk b/jni/Application.mk
new file mode 100644
index 0000000..9f22b54
--- /dev/null
+++ b/jni/Application.mk
@@ -0,0 +1,11 @@
+#APP_PLATFORM := android-9
+
+#APP_STL := gnustl_static
+#APP_STL := stlport_static
+APP_STL := gnustl_shared
+APP_CPPFLAGS += -fexceptions
+APP_CPPFLAGS += -frtti
+APP_OPTIM := debug
+
+#APP_ABI := armeabi-v7a
+
diff --git a/jni/android_api.cpp b/jni/android_api.cpp
new file mode 100644
index 0000000..434eea9
--- /dev/null
+++ b/jni/android_api.cpp
@@ -0,0 +1,150 @@
+#include "android_api.h"
+
+#include "main_code.h"
+
+
+//#include "boost/shared_ptr.h"
+
+const float CONST_MAXRIX_WIDTH = 800.f;
+const float CONST_MAXRIX_HEIGHT = 480.f;
+
+boost::mutex RenderMutex;
+
+JNIEXPORT void JNICALL Java_fishrungames_crystalofrhylil_JniWrapper_Init(JNIEnv * env, jobject obj, jint width, jint height)
+{
+ try
+ {
+ if (App->Inited)
+ {
+ App->OuterDeinit(); //Clean up what is left at previous launch (if applicable)
+ }
+
+ App->OuterInit(width, height, CONST_MAXRIX_WIDTH, CONST_MAXRIX_HEIGHT);
+
+ App->Inited = true;
+
+ }
+ catch (ErrorCommon e)
+ {
+ throw;
+ }
+}
+
+JNIEXPORT void JNICALL Java_fishrungames_crystalofrhylil_JniWrapper_StopSounds(JNIEnv * env, jobject obj)
+{
+
+}
+
+
+JNIEXPORT void JNICALL Java_fishrungames_crystalofrhylil_JniWrapper_Update(JNIEnv * env, jobject obj, long dt)
+{
+ RenderMutex.lock();
+ try
+ {
+ if (App->Inited)
+ {
+ App->OuterDraw();
+ App->OuterUpdate(dt);
+ }
+
+ }
+ catch (...)
+ {
+ throw;
+ }
+
+ RenderMutex.unlock();
+}
+
+JNIEXPORT int JNICALL Java_fishrungames_crystalofrhylil_JniWrapper_IsInited(JNIEnv * env, jobject obj)
+{
+
+ if (App->Inited)
+ {
+ return 1;
+ }
+ else
+ {
+ return 0;
+ }
+
+}
+
+JNIEXPORT void JNICALL Java_fishrungames_crystalofrhylil_JniWrapper_Destroy(JNIEnv * env, jobject obj)
+{
+ RenderMutex.lock();
+ try
+ {
+ if (App->Inited)
+ {
+ App->Inited = false;
+ App->OuterDeinit();
+ }
+ }
+ catch (ErrorCommon e)
+ {
+ throw;
+ }
+ RenderMutex.unlock();
+}
+
+
+JNIEXPORT void JNICALL Java_fishrungames_crystalofrhylil_JniWrapper_OnTapDown(JNIEnv * env, jobject obj, float x, float y, long time)
+{
+
+ try
+ {
+ App->OuterOnTapDown(vec2(x*CONST_MAXRIX_WIDTH/HalibutRender->GetScreenWidth(), y*CONST_MAXRIX_HEIGHT/HalibutRender->GetScreenHeight()));
+ }
+ catch (ErrorCommon e)
+ {
+ throw;
+ }
+}
+
+
+JNIEXPORT void JNICALL Java_fishrungames_crystalofrhylil_JniWrapper_OnTapUp(JNIEnv * env, jobject obj, float x, float y, long time)
+{
+ try
+ {
+ App->OuterOnTapUp(vec2(x*CONST_MAXRIX_WIDTH/HalibutRender->GetScreenWidth(), y*CONST_MAXRIX_HEIGHT/HalibutRender->GetScreenHeight()));
+ }
+ catch (ErrorCommon e)
+ {
+ throw;
+ }
+}
+
+JNIEXPORT void JNICALL Java_fishrungames_crystalofrhylil_JniWrapper_OnTapMove(JNIEnv * env, jobject obj, float x, float y, long time)
+{
+}
+
+JNIEXPORT void JNICALL Java_fishrungames_crystalofrhylil_JniWrapper_OnFling(JNIEnv * env, jobject obj, jfloat velocityX, jfloat velocityY, long time)
+{
+}
+
+JNIEXPORT void JNICALL Java_fishrungames_crystalofrhylil_JniWrapper_OnScroll(JNIEnv * env, jobject obj, jfloat distanceX, jfloat distanceY, long time)
+{
+ try
+ {
+ App->OuterOnMove(vec2(distanceX*CONST_MAXRIX_WIDTH/HalibutRender->GetScreenWidth(), distanceY*CONST_MAXRIX_HEIGHT/HalibutRender->GetScreenHeight()));
+ }
+ catch (ErrorCommon e)
+ {
+ throw;
+ }
+}
+
+JNIEXPORT void JNICALL Java_fishrungames_crystalofrhylil_JniWrapper_OnKeyPress(JNIEnv * env, jobject obj, jint keyCode)
+{
+
+ try
+ {
+ App->OnKeyPress(keyCode);
+ }
+ catch (ErrorCommon e)
+ {
+ throw;
+ }
+}
+
diff --git a/jni/android_api.h b/jni/android_api.h
new file mode 100644
index 0000000..216c086
--- /dev/null
+++ b/jni/android_api.h
@@ -0,0 +1,31 @@
+#ifndef ANDROID_API_H_INCLUDED
+#define ANDROID_API_H_INCLUDED
+
+#include
+#include
+
+#include
+#include
+#include
+
+#include "boost/shared_ptr.hpp"
+
+#include "main_code.h"
+
+
+extern "C" {
+ JNIEXPORT void JNICALL Java_fishrungames_crystalofrhylil_JniWrapper_Init(JNIEnv * env, jobject obj, jint width, jint height);
+ JNIEXPORT void JNICALL Java_fishrungames_crystalofrhylil_JniWrapper_StopSounds(JNIEnv * env, jobject obj);
+ JNIEXPORT void JNICALL Java_fishrungames_crystalofrhylil_JniWrapper_Update(JNIEnv * env, jobject obj, long dt);
+ JNIEXPORT void JNICALL Java_fishrungames_crystalofrhylil_JniWrapper_Destroy(JNIEnv * env, jobject obj);
+ JNIEXPORT int JNICALL Java_fishrungames_crystalofrhylil_JniWrapper_IsInited(JNIEnv * env, jobject obj);
+ JNIEXPORT void JNICALL Java_fishrungames_crystalofrhylil_JniWrapper_OnTapDown(JNIEnv * env, jobject obj, jfloat x, jfloat y, long time);
+ JNIEXPORT void JNICALL Java_fishrungames_crystalofrhylil_JniWrapper_OnTapUp(JNIEnv * env, jobject obj, jfloat x, jfloat y, long time);
+ JNIEXPORT void JNICALL Java_fishrungames_crystalofrhylil_JniWrapper_OnTapMove(JNIEnv * env, jobject obj, jfloat x, jfloat y, long time);
+ JNIEXPORT void JNICALL Java_fishrungames_crystalofrhylil_JniWrapper_OnFling(JNIEnv * env, jobject obj, jfloat velocityX, jfloat velocityY, long time);
+ JNIEXPORT void JNICALL Java_fishrungames_crystalofrhylil_JniWrapper_OnScroll(JNIEnv * env, jobject obj, jfloat distanceX, jfloat distanceY, long time);
+ JNIEXPORT void JNICALL Java_fishrungames_crystalofrhylil_JniWrapper_OnKeyPress(JNIEnv * env, jobject obj, jint keyCode);
+};
+
+
+#endif
diff --git a/jni/main_code.cpp b/jni/main_code.cpp
new file mode 100644
index 0000000..70bcc1d
--- /dev/null
+++ b/jni/main_code.cpp
@@ -0,0 +1,141 @@
+#include "main_code.h"
+
+#ifdef TARGET_ANDROID
+#include "android_api.h"
+#endif
+
+#include
+#include
+#include
+#include
+
+#include "include/Engine.h"
+
+#include "main_code.h"
+
+#ifndef TARGET_IOS
+boost::shared_ptr App(new TMyApplication);
+#endif
+
+bool animPaused = false;
+
+struct TOnClickTest
+{
+ void operator()()
+ {
+
+ //ResourceManager->ScriptManager.RunScript("5+5;");
+
+ if (animPaused)
+ {
+ //animPaused = false;
+ //ResourceManager->HalibutAnimationManager.StartAnimation("test_anim");
+ //ResourceManager->HalibutAnimationManager.ShowAnimation("test_anim");
+ //ResourceManager->SoundManager.PlayMusic("finalogg.ogg");
+
+ //App->Match3Controller.Match3Field->StartAnimateChip(4,1);
+
+ //App->Match3Controller.Match3Field->HighlightMatch3();
+ }
+ else
+ {
+ //animPaused = true;
+ //ResourceManager->HalibutAnimationManager.StopAnimation("test_anim");
+ //ResourceManager->HalibutAnimationManager.HideAnimation("test_anim");
+ //ResourceManager->SoundManager.StopMusic("finalogg.ogg");
+ //App->Match3Controller.Match3Field->StopAnimateChip(4,1);
+ //App->Match3Controller.Match3Field->HighlightMatch3();
+ }
+
+ }
+};
+
+
+
+
+
+//What to do on init
+void TMyApplication::InnerInit()
+{
+ #ifdef TARGET_ANDROID
+ ResourceManager->PathToResources = "";
+ #endif
+ #ifdef TARGET_WIN32
+ #ifdef DEBUG
+ ResourceManager->PathToResources = "../../assets/";
+ #else
+ ResourceManager->PathToResources = "res/";
+ #endif
+ #endif
+ #ifdef TARGET_IOS
+ ResourceManager->PathToResources = "assets/";
+ #endif
+
+ boost::shared_ptr px = FileToPropertyTree("function_info_list.xml");
+
+ ResourceManager->ScriptManager.Serialize(*px);
+
+ px = FileToPropertyTree("shaders.xml");
+ ResourceManager->ShaderManager.Serialize(*px);
+
+ HalibutRender->PushShader("DefaultShader");
+
+ px = FileToPropertyTree("textures.xml");
+ ResourceManager->TexList.Serialize(*px);
+
+ px = FileToPropertyTree("fonts.xml");
+ ResourceManager->FontManager.Serialize(*px);
+ ResourceManager->FontManager.PushFont("droid_sans14");
+
+
+ ResourceManager->GUIManager.AddWidgetAndFill(boost::shared_ptr(new TSquareButton),
+ "ololo", "group1",
+ boost::shared_ptr(new TSquareButtonTriangleListFiller(vec2(100, 100), vec2(200, 200), "button_normal", "button_pressed")));
+
+
+ ResourceManager->GUIManager.AddWidgetAndFill(boost::shared_ptr(new TSquareStatic),
+ "Background", "group1",
+ boost::shared_ptr(new TSquareStaticTriangleListFiller(vec2(0, 0), vec2(800, 480), "cave_hd")));
+
+
+ ResourceManager->GUIManager.AddWidget(boost::shared_ptr(new TMatch3Field(Match3Controller)),
+ "match3", "group1");
+
+ ResourceManager->GUIManager.MoveWidget("ololo", vec2(-100, 0));
+
+ TOnClickTest OnClickTest;
+
+ //ResourceManager->GUIManager.GetOnClickSignal("ololo").connect(OnClickTest);
+
+ //testAnimObject.Serialize(FileToPropertyTree("test_animation_xml.xml"));
+
+ //ResourceManager->HalibutAnimationManager.AddAnimationObject("test_anim", testAnimObject);
+
+ //ResourceManager->HalibutAnimationManager.StartAnimation("test_anim");
+
+
+ //ResourceManager->ShaderManager.AddShader("DefaultShader", "shader_vertex.txt", "shader_fragment.txt");
+ /*HalibutRender->PushShader("DefaultShader");
+
+ ResourceManager->TexList.AddTexture(CONST_CONSOLE_TEX_NAME);
+
+ ResourceManager->FontManager.AddFont("droid_sans14", "droid_sans14_font_bitmap.bmp32", "droid_sans14_font_charmap.txt");
+ ResourceManager->FontManager.PushFont("droid_sans14");*/
+
+}
+
+//What to do on deinit
+void TMyApplication::InnerDeinit()
+{
+ Inited = false;
+}
+
+//What to do on draw
+void TMyApplication::InnerDraw()
+{
+}
+
+//What to do on update. timer means how many ms passed since last update
+void TMyApplication::InnerUpdate(cardinal timer)
+{
+}
diff --git a/jni/main_code.h b/jni/main_code.h
new file mode 100644
index 0000000..0830ff8
--- /dev/null
+++ b/jni/main_code.h
@@ -0,0 +1,64 @@
+#ifndef GL_CODE_H_INCLUDED
+#define GL_CODE_H_INCLUDED
+
+#ifdef TARGET_ANDROID
+//#include "android_api.h"
+#endif
+
+#include
+#include
+#include
+
+#include "boost/shared_ptr.hpp"
+/*#include "boost/thread/thread.hpp"
+#include "boost/signal.hpp"
+#include "boost/assign.hpp"
+#include "boost/bind.hpp"
+*/
+#include "include/Engine.h"
+
+#include "match3/match3field.h"
+
+
+class TMatch3Controller
+{
+public:
+ TMatch3Field* Match3Field;
+
+
+ TMatch3Controller()
+ : Match3Field(NULL)
+ {
+ }
+
+};
+
+
+//Application class
+class TMyApplication : public TApplication
+{
+public:
+ bool Inited;
+
+ TMatch3Controller Match3Controller;
+
+ TMyApplication() : Inited(false) { }
+
+ virtual void InnerInit();
+ //What to do on init
+
+ virtual void InnerDeinit();
+ //What to do on deinit
+
+ virtual void InnerDraw();
+ //What to do on draw
+
+ virtual void InnerUpdate(cardinal timer);
+ //What to do on update. timer means how many ms passed since last update
+};
+
+#ifndef TARGET_IOS
+extern boost::shared_ptr App;
+#endif
+
+#endif
diff --git a/jni/match3/match3field.cpp b/jni/match3/match3field.cpp
new file mode 100644
index 0000000..09f7147
--- /dev/null
+++ b/jni/match3/match3field.cpp
@@ -0,0 +1,1329 @@
+#include "match3/match3field.h"
+
+#include "main_code.h"
+#include
+
+
+void TChipTemplateParams::Serialize(boost::property_tree::ptree& propertyTree)
+{
+
+ std::string selectedShaderName = propertyTree.get("SelectedShaderName");
+ std::string selectedTexName = propertyTree.get("SelectedTexName");
+ std::string selectedNormTexName = propertyTree.get("SelectedNormTexName");
+ std::string finishingTexName = propertyTree.get("FinishingTexName");
+
+ SelectedRenderParams.ShaderName = selectedShaderName;
+ SelectedRenderParams.TexName = selectedTexName;
+ SelectedRenderParams.NormTexName = selectedNormTexName;
+ SelectedRenderParams.Transparency = 1.f;
+
+ FinishingRenderParams.ShaderName = "";
+ FinishingRenderParams.TexName = finishingTexName;
+ FinishingRenderParams.NormTexName = "";
+ FinishingRenderParams.Transparency = 1.f;
+
+ std::string selectedAnimFileName = propertyTree.get("SelectedAnimFileName");
+ std::string finishingAnimFileName = propertyTree.get("FinishingAnimFileName");
+
+ boost::shared_ptr px = FileToPropertyTree(selectedAnimFileName);
+ SelectedTemplateAnimObject.Serialize(*px);
+ px = FileToPropertyTree(finishingAnimFileName);
+ FinishingTemplateAnimObject.Serialize(*px);
+
+}
+
+
+void TMatch3FieldParams::Serialize(boost::property_tree::ptree& propertyTree)
+{
+
+ TChipTemplateParams chipTemplateParams;
+
+ FieldWidth = propertyTree.get("Match3Params.FieldWidth");
+ FieldHeight = propertyTree.get("Match3Params.FieldHeight");
+ CellWidth = propertyTree.get("Match3Params.CellWidth");
+ CellHeight = propertyTree.get("Match3Params.CellHeight");
+ ChipLowestSpeed = propertyTree.get("Match3Params.ChipLowestSpeed");
+ ChipAcceleration = propertyTree.get("Match3Params.ChipAcceleration");
+ ChipPositionEpsilon = propertyTree.get("Match3Params.ChipPositionEpsilon");
+ ChipVelocityEpsilon = propertyTree.get("Match3Params.ChipVelocityEpsilon");
+ ChipK = propertyTree.get("Match3Params.ChipK");
+ ChipMatchTime = propertyTree.get("Match3Params.ChipMatchTime");
+ ChipTypeCount = propertyTree.get("Match3Params.ChipTypeCount");
+
+ BOOST_FOREACH(boost::property_tree::ptree::value_type &v, propertyTree.get_child("Match3Params.ChipList"))
+ {
+ boost::property_tree::ptree& p = v.second.get_child("");
+ chipTemplateParams.Serialize(p);
+ ChipTemplateParamsArr.push_back(chipTemplateParams);
+ }
+
+
+}
+
+int TChip::StaticAnimationIndex = 0;
+
+TChip::TChip(int chipType, TRenderPairList::iterator renderPair, cardinal vertexListShift, TChipState chipState)
+ : ChipType(chipType)
+ , RenderPair(renderPair)
+ , VertexListShift(vertexListShift)
+ , ChipState(chipState)
+ , Velocity(0)
+{
+ AnimName = "test_anim"+tostr(StaticAnimationIndex++);
+}
+
+TChip::~TChip()
+{
+}
+
+vec2 TChip::GetLeftBottomPos()
+{
+ std::vector::iterator i = RenderPair->second.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].begin() + VertexListShift;
+
+ return vec2(i->v[0], i->v[1]);
+}
+
+void TChip::SetLeftBottomPos(vec2 newPos)
+{
+ vec2 shift = newPos - GetLeftBottomPos();
+
+ MoveLeftBottomPos(shift);
+}
+
+void TChip::MoveLeftBottomPos(vec2 shift)
+{
+ for (int i=0; i<6; i++)
+ {
+ *(RenderPair->second.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].begin() + VertexListShift + i) += vec3(shift, 0);
+ }
+}
+
+
+
+
+TMatch3Logic::TMatch3Logic()
+ //: TemplateAnimObject(TRenderPairList::iterator(), 0, 1)
+{
+ //TemplateAnimObject.Serialize(FileToPropertyTree("chip1_xml.xml"));
+}
+
+
+TMatch3Logic::~TMatch3Logic()
+{
+
+ //Match3FieldParams.ChipTemplateParamsArr.clear();
+
+}
+
+void TMatch3Logic::FillRandomChipMatrix(std::vector renderPairIteratorVector, vec2 leftBottomPos)
+{
+
+ RenderPairIteratorVector = renderPairIteratorVector;
+
+ LeftBottomPosField = leftBottomPos;
+
+ ChipTypeCount = Match3FieldParams.ChipTypeCount;
+
+ ChipMatrix.resize(Match3FieldParams.FieldWidth);
+
+ for (cardinal i = 0; i < Match3FieldParams.FieldWidth; ++i)
+ {
+ for (cardinal j=0; j < Match3FieldParams.FieldHeight; ++j)
+ {
+ int chipType = rand() % ChipTypeCount;
+
+ if (i == 0 && j == 6)
+ {
+ //AddChipToUp(i, chipType, GetExpectedLeftBottomPos(i, j), TChip::CS_LOCKED);
+ AddChipToUp(i, chipType, GetExpectedLeftBottomPos(i, j), TChip::CS_STANDBY);
+ }
+ else
+ {
+ AddChipToUp(i, chipType, GetExpectedLeftBottomPos(i, j), TChip::CS_STANDBY);
+ }
+ }
+ }
+
+
+
+ std::vector chipList = GetAvailableMatchingChips();
+
+ while (chipList.size() != 0)
+ {
+ UnmatchChips(chipList);
+ chipList = GetAvailableMatchingChips();
+ }
+
+}
+
+
+vec2 TMatch3Logic::GetExpectedLeftBottomPos(cardinal x, cardinal y)
+{
+ return LeftBottomPosField + vec2(x*Match3FieldParams.CellWidth, y*Match3FieldParams.CellHeight);
+}
+
+
+
+void TMatch3Logic::StartAnimateChip(cardinal x, cardinal y)
+{
+ ResourceManager->HalibutAnimationManager.StartAnimation(ChipMatrix[x][y].AnimName);
+}
+
+void TMatch3Logic::StopAnimateChip(cardinal x, cardinal y)
+{
+
+ ResourceManager->HalibutAnimationManager.StopAnimation(ChipMatrix[x][y].AnimName);
+
+}
+
+
+bool TMatch3Logic::ChipIsLocked(ivec2 chip)
+{
+ return ChipMatrix[chip.v[0]][chip.v[1]].ChipState == TChip::CS_LOCKED;
+}
+
+bool TMatch3Logic::ChipIsFinishing(ivec2 chip)
+{
+ return ChipMatrix[chip.v[0]][chip.v[1]].ChipState == TChip::CS_FINISHING;
+}
+
+bool TMatch3Logic::ChipIsStable(ivec2 chip)
+{
+ return ChipMatrix[chip.v[0]][chip.v[1]].ChipState == TChip::CS_STANDBY ||
+ ChipMatrix[chip.v[0]][chip.v[1]].ChipState == TChip::CS_LOCKED;
+}
+
+bool TMatch3Logic::ChipCanBeSelected(ivec2 chip)
+{
+
+ if (ChipMatrix[chip.v[0]][chip.v[1]].ChipState != TChip::CS_STANDBY)
+ {
+ return false;
+ }
+
+
+ if (chip.v[1] == 0)
+ {
+ return true;
+ }
+
+ int i = chip.v[1] - 1;
+
+ while (i >= 0 && ChipIsStable(ivec2(chip.v[0], i)) && !ChipIsLocked(ivec2(chip.v[0], i)))
+ {
+ i--;
+ }
+
+ if (i < 0 || ChipIsLocked(ivec2(chip.v[0], i)))
+ {
+ return true;
+ }
+
+ return false;
+
+
+}
+
+bool TMatch3Logic::ChipsCanBeSwapped(ivec2 p1, ivec2 p2)
+{
+ float distance_x = static_cast(p1.v[0] - p2.v[0]);
+ float distance_y = static_cast(p1.v[1] - p2.v[1]);
+
+ if ((((fabs(distance_x) == 1) && (fabs(distance_y) == 0))
+ || ((fabs(distance_x) == 0) && (fabs(distance_y) == 1))) &&
+ ChipCanBeSelected(p1) &&
+ ChipCanBeSelected(p2))
+ {
+
+ return true;
+ }
+
+ return false;
+}
+
+bool TMatch3Logic::ChipCanBeMatchedUp(ivec2 chip)
+{
+ if (chip.v[1] <= Match3FieldParams.FieldHeight - 3)
+ {
+ if ((ChipMatrix[chip.v[0]][chip.v[1]].ChipType == ChipMatrix[chip.v[0]][chip.v[1] + 1].ChipType)
+ && (ChipMatrix[chip.v[0]][chip.v[1]].ChipType == ChipMatrix[chip.v[0]][chip.v[1] + 2].ChipType))
+ {
+
+ if (ChipMatrix[chip.v[0]][chip.v[1]].ChipState == TChip::CS_STANDBY &&
+ ChipMatrix[chip.v[0]][chip.v[1] + 1].ChipState == TChip::CS_STANDBY &&
+ ChipMatrix[chip.v[0]][chip.v[1] + 2].ChipState == TChip::CS_STANDBY)
+ {
+ return true;
+ }
+
+
+ }
+ }
+
+ return false;
+}
+
+bool TMatch3Logic::ChipCanBeMatchedDown(ivec2 chip)
+{
+ if (chip.v[1] >= 2)
+ {
+ if ((ChipMatrix[chip.v[0]][chip.v[1]].ChipType == ChipMatrix[chip.v[0]][chip.v[1] - 1].ChipType)
+ && (ChipMatrix[chip.v[0]][chip.v[1]].ChipType == ChipMatrix[chip.v[0]][chip.v[1] - 2].ChipType))
+ {
+ if (ChipMatrix[chip.v[0]][chip.v[1]].ChipState == TChip::CS_STANDBY &&
+ ChipMatrix[chip.v[0]][chip.v[1] - 1].ChipState == TChip::CS_STANDBY &&
+ ChipMatrix[chip.v[0]][chip.v[1] - 2].ChipState == TChip::CS_STANDBY)
+ {
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+bool TMatch3Logic::ChipCanBeMatchedLeft(ivec2 chip)
+{
+ if (chip.v[0] >= 2)
+ {
+ if ((ChipMatrix[chip.v[0]][chip.v[1]].ChipType == ChipMatrix[chip.v[0] - 1][chip.v[1]].ChipType)
+ && (ChipMatrix[chip.v[0]][chip.v[1]].ChipType == ChipMatrix[chip.v[0] - 2][chip.v[1]].ChipType))
+ {
+ if (ChipMatrix[chip.v[0]][chip.v[1]].ChipState == TChip::CS_STANDBY &&
+ ChipMatrix[chip.v[0] - 1][chip.v[1]].ChipState == TChip::CS_STANDBY &&
+ ChipMatrix[chip.v[0] - 2][chip.v[1]].ChipState == TChip::CS_STANDBY)
+ {
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+bool TMatch3Logic::ChipCanBeMatchedRight(ivec2 chip)
+{
+ if (chip.v[0] <= Match3FieldParams.FieldWidth - 3)
+ {
+ if ((ChipMatrix[chip.v[0]][chip.v[1]].ChipType == ChipMatrix[chip.v[0] + 1][chip.v[1]].ChipType)
+ && (ChipMatrix[chip.v[0]][chip.v[1]].ChipType == ChipMatrix[chip.v[0] + 2][chip.v[1]].ChipType))
+ {
+ if (ChipMatrix[chip.v[0]][chip.v[1]].ChipState == TChip::CS_STANDBY &&
+ ChipMatrix[chip.v[0] + 1][chip.v[1]].ChipState == TChip::CS_STANDBY &&
+ ChipMatrix[chip.v[0] + 2][chip.v[1]].ChipState == TChip::CS_STANDBY)
+ {
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+
+void TMatch3Logic::UnmatchChips(std::vector chipList)
+{
+ std::vector::iterator i;
+
+ for (i = chipList.begin(); i != chipList.end(); ++i)
+ {
+
+ ChangeChipType(*i);
+ }
+}
+
+void TMatch3Logic::ReplaceAnimation(ivec2 p)
+{
+
+
+ TChip& chip = ChipMatrix[p.v[0]][p.v[1]];
+
+ if (ResourceManager->HalibutAnimationManager.AnimationExists(chip.AnimName))
+ {
+ ResourceManager->HalibutAnimationManager.ReplaceAnimationObject(chip.AnimName, chip.RenderPair, chip.VertexListShift / 6);
+ }
+ else
+ {
+
+ THalibutExternalAnimObject testAnimObject(Match3FieldParams.ChipTemplateParamsArr[chip.ChipType].SelectedTemplateAnimObject);
+
+ testAnimObject.ReplaceAnimObject(chip.RenderPair, chip.VertexListShift / 6);
+
+ ResourceManager->HalibutAnimationManager.AddAnimationObject(chip.AnimName, testAnimObject);
+
+ }
+
+ ResourceManager->HalibutAnimationManager.StopAnimation(chip.AnimName);
+}
+
+
+void TMatch3Logic::MoveVertexListShiftBack(TRenderPairList::iterator renderPairItr, cardinal moveFrom)
+{
+ for (cardinal i = 0; i < ChipMatrix.size(); i++)
+ {
+ for (cardinal j = 0; j < ChipMatrix[i].size(); j++)
+ {
+ if (ChipMatrix[i][j].RenderPair == renderPairItr)
+ {
+ if (ChipMatrix[i][j].VertexListShift > moveFrom)
+ {
+ ChipMatrix[i][j].VertexListShift -= 6;
+
+ ReplaceAnimation(ivec2(i, j));
+ }
+ }
+ }
+ }
+}
+
+void TMatch3Logic::AddChipToUp(cardinal colNum, int chipType, vec2 spawnPos, TChip::TChipState chipState)
+{
+ cardinal yPos = ChipMatrix[colNum].size();
+
+ vec2 posFrom = spawnPos;
+ vec2 posTo = posFrom + vec2(Match3FieldParams.CellWidth, Match3FieldParams.CellHeight);
+
+ cardinal renderPairIndex;
+
+ if (chipState == TChip::CS_LOCKED)
+ {
+ renderPairIndex = chipType + Match3FieldParams.ChipTypeCount;
+ }
+ else
+ {
+ renderPairIndex = chipType;
+ }
+
+ TTriangleList& triangleList = RenderPairIteratorVector[renderPairIndex]->second;
+
+ std::vector vertexCoordArr = MakeVertexCoordVec(posFrom, posTo);
+
+ std::vector texCoordArr = MakeTexCoordVec();
+
+ triangleList.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].insert(triangleList.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].end(), vertexCoordArr.begin(), vertexCoordArr.end());
+
+ triangleList.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB].insert(triangleList.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB].end(), texCoordArr.begin(), texCoordArr.end());
+
+ cardinal vertexListShift = RenderPairIteratorVector[renderPairIndex]->second.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].size()-6;
+
+ ChipMatrix[colNum].push_back(TChip(chipType, RenderPairIteratorVector[renderPairIndex], vertexListShift, chipState));
+
+ ReplaceAnimation(ivec2(colNum, yPos));
+
+ triangleList.NeedRefreshBuffer = true;
+}
+
+
+void TMatch3Logic::InsertEmptyChip(cardinal colNum, cardinal rowNum, int chipType)
+{
+
+ vec2 posFrom = GetExpectedLeftBottomPos(colNum, rowNum);
+ vec2 posTo = posFrom + vec2(Match3FieldParams.CellWidth, Match3FieldParams.CellHeight);
+
+ cardinal renderPairIndex = Match3FieldParams.ChipTypeCount * 2 + chipType;
+
+ TChip::TChipState chipState = TChip::CS_X;
+
+ TTriangleList& triangleList = RenderPairIteratorVector[renderPairIndex]->second;
+
+ std::vector vertexCoordArr = MakeVertexCoordVec(posFrom, posTo);
+
+ std::vector texCoordArr = MakeTexCoordVec();
+
+ triangleList.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].insert(triangleList.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].end(), vertexCoordArr.begin(), vertexCoordArr.end());
+
+ triangleList.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB].insert(triangleList.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB].end(), texCoordArr.begin(), texCoordArr.end());
+
+ cardinal vertexListShift = RenderPairIteratorVector[renderPairIndex]->second.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].size()-6;
+
+ ChipMatrix[colNum].insert(ChipMatrix[colNum].begin() + rowNum, TChip(chipType, RenderPairIteratorVector[renderPairIndex], vertexListShift, chipState));
+
+ ReplaceAnimation(ivec2(colNum, rowNum));
+
+
+ triangleList.NeedRefreshBuffer = true;
+
+ vec2 pos = GetExpectedLeftBottomPos(colNum, rowNum);
+
+ ChipDeletingVector.push_back(TChipDeletingData(ivec2(colNum, rowNum), pos));
+}
+
+
+
+void TMatch3Logic::UpdateChipSwapping(cardinal dt)
+{
+
+ std::vector::iterator i = ChipSwappingPairVector.begin();
+
+ std::vector > chipsToSwapAgain;
+
+ while (i != ChipSwappingPairVector.end())
+ {
+
+ i->T += dt / static_cast(Match3FieldParams.ChipMatchTime);
+
+ if (i->T >= 1.f)
+ {
+
+ ivec2 chip1pos = i->Chip1;
+ ivec2 chip2pos = i->Chip2;
+
+ bool isReturning = i->IsReturning;
+
+ TChip& chip1 = ChipMatrix[chip1pos.v[0]][chip1pos.v[1]];
+ TChip& chip2 = ChipMatrix[chip2pos.v[0]][chip2pos.v[1]];
+
+
+ TChip c = chip1;
+ chip1 = chip2;
+ chip2 = c;
+
+
+ ResetChipPos(chip1pos);
+ ResetChipPos(chip2pos);
+
+ chip1.ChipState = TChip::CS_STANDBY;
+ chip2.ChipState = TChip::CS_STANDBY;
+
+
+ i = ChipSwappingPairVector.erase(i);
+
+
+ //Check if chips do
+ if (!isReturning)
+ {
+ std::vector matchingChipList = GetAvailableMatchingChips();
+
+ if (matchingChipList.size() == 0)
+ {
+ //SwapChips(chip1pos, chip2pos);
+ chipsToSwapAgain.push_back(std::pair(chip1pos, chip2pos));
+ }
+ }
+
+ }
+ else
+ {
+
+ TChip& chip1 = ChipMatrix[i->Chip1.v[0]][i->Chip1.v[1]];
+ TChip& chip2 = ChipMatrix[i->Chip2.v[0]][i->Chip2.v[1]];
+
+ vec3 newPosChip1 = vec3(i->Chip1RealPosFrom + (i->Chip2RealPosFrom - i->Chip1RealPosFrom) * i->T, 0);
+ vec3 newPosChip2 = vec3(i->Chip2RealPosFrom + (i->Chip1RealPosFrom - i->Chip2RealPosFrom) * i->T, 0);
+
+ vec3 shiftChip1 = newPosChip1 - chip1.RenderPair->second.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB][chip1.VertexListShift];
+ vec3 shiftChip2 = newPosChip2 - chip2.RenderPair->second.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB][chip2.VertexListShift];
+
+ for (int k = 0; k < 6; k++)
+ {
+
+ chip1.RenderPair->second.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB][chip1.VertexListShift + k] += shiftChip1;
+ chip2.RenderPair->second.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB][chip2.VertexListShift + k] += shiftChip2;
+ }
+
+ chip1.RenderPair->second.NeedRefreshBuffer = true;
+ chip2.RenderPair->second.NeedRefreshBuffer = true;
+ }
+
+
+ if (i != ChipSwappingPairVector.end())
+ {
+ ++i;
+ }
+
+ }
+
+ std::vector >::iterator pairVecItr;
+
+ for (pairVecItr = chipsToSwapAgain.begin(); pairVecItr != chipsToSwapAgain.end(); ++pairVecItr)
+ {
+ SwapChips(pairVecItr->first, pairVecItr->second, true);
+ }
+}
+
+
+void TMatch3Logic::UpdateChipPosition(cardinal dt)
+{
+
+ for (cardinal i=0; i 0 && ChipIsFinishing(ivec2(i, j-1))))
+ {
+
+ chip.Velocity = -chip.Velocity * Match3FieldParams.ChipK;
+ chip.SetLeftBottomPos(GetExpectedLeftBottomPos(i, j));
+
+
+ }
+
+ if (fabs(chip.Velocity) <= Match3FieldParams.ChipVelocityEpsilon)
+ {
+
+ if (fabs(expectedPos.v[0] - realPos.v[0]) <= Match3FieldParams.ChipPositionEpsilon &&
+ fabs(expectedPos.v[1] - realPos.v[1]) <= Match3FieldParams.ChipPositionEpsilon
+ )
+ {
+ chip.ChipState = TChip::CS_STANDBY;
+ chip.SetLeftBottomPos(GetExpectedLeftBottomPos(i, j));
+ chip.Velocity = 0.f;
+ }
+ }
+
+
+ chip.RenderPair->second.NeedRefreshBuffer = true;
+
+ for (cardinal k = j + 1; k < ChipMatrix[i].size(); k++)
+ {
+
+ TChip& chipAbove = ChipMatrix[i][k];
+
+ vec2 posAbove = chipAbove.GetLeftBottomPos();
+
+ if (chipAbove.GetLeftBottomPos().v[1] - chip.GetLeftBottomPos().v[1] < Match3FieldParams.CellHeight)
+ {
+ if (!ChipIsLocked(ivec2(i, k)) && !ChipIsFinishing(ivec2(i, k)))
+ {
+ chipAbove.ChipState = TChip::CS_FALLING;
+ chipAbove.SetLeftBottomPos(chip.GetLeftBottomPos() + vec2(0, Match3FieldParams.CellHeight));
+ chipAbove.Velocity = chip.Velocity;
+ chipAbove.RenderPair->second.NeedRefreshBuffer = true;
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+
+void TMatch3Logic::RemoveBubbles()
+{
+ cardinal max_y = ChipMatrix.size()-1;
+
+ for (cardinal i=0; i < ChipMatrix[max_y].size(); i++)
+ {
+ if (ChipMatrix[i][max_y].ChipState == TChip::CS_FINISHING)
+ {
+ DestroyChip(ivec2(i, max_y));
+ AddChipToUp(i, rand() % ChipTypeCount, GetExpectedLeftBottomPos(i, ChipMatrix[i].size())+vec2(0, Match3FieldParams.CellHeight));
+ }
+ }
+}
+
+void TMatch3Logic::TryMatchAllChips()
+{
+
+ std::vector matchingChips = GetAvailableMatchingChips();
+
+ std::vector::iterator i;
+
+ for (i = matchingChips.begin(); i != matchingChips.end(); ++i)
+ {
+ ivec2 p = *i;
+
+ int chipType = ChipMatrix[p.v[0]][p.v[1]].ChipType;
+ DestroyChip(p);
+ InsertEmptyChip(p.v[0], p.v[1], chipType);
+ }
+
+}
+
+void TMatch3Logic::DestroyChip(ivec2 p)
+{
+ ChipMatrix[p.v[0]][p.v[1]].RenderPair->second.NeedRefreshBuffer = true;
+
+ ResourceManager->HalibutAnimationManager.DeleteAnimationObject(ChipMatrix[p.v[0]][p.v[1]].AnimName);
+
+ ChipMatrix[p.v[0]][p.v[1]].RenderPair->second.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].erase(
+ ChipMatrix[p.v[0]][p.v[1]].RenderPair->second.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].begin() + ChipMatrix[p.v[0]][p.v[1]].VertexListShift,
+ ChipMatrix[p.v[0]][p.v[1]].RenderPair->second.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].begin() + ChipMatrix[p.v[0]][p.v[1]].VertexListShift + 6);
+
+ ChipMatrix[p.v[0]][p.v[1]].RenderPair->second.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB].erase(
+ ChipMatrix[p.v[0]][p.v[1]].RenderPair->second.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB].begin() + ChipMatrix[p.v[0]][p.v[1]].VertexListShift,
+ ChipMatrix[p.v[0]][p.v[1]].RenderPair->second.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB].begin() + ChipMatrix[p.v[0]][p.v[1]].VertexListShift + 6);
+
+ MoveVertexListShiftBack(ChipMatrix[p.v[0]][p.v[1]].RenderPair, ChipMatrix[p.v[0]][p.v[1]].VertexListShift);
+
+ ChipMatrix[p.v[0]].erase(ChipMatrix[p.v[0]].begin() + p.v[1]);
+ /*
+ for (cardinal i=p.v[1]; i < ChipMatrix[p.v[0]].size(); i++)
+ {
+ if (!ChipIsLocked(ivec2(p.v[0], i)) && !ChipIsFinishing(ivec2(p.v[0], i)))
+ {
+ ChipMatrix[p.v[0]][i].ChipState = TChip::CS_FALLING;
+ }
+ }*/
+
+}
+
+void TMatch3Logic::ChangeChipType(ivec2 p)
+{
+ cardinal newChipType = rand() % ChipTypeCount;
+
+ TChip& chip = ChipMatrix[p.v[0]][p.v[1]];
+
+ std::vector::iterator vertexCoordItrBegin = chip.RenderPair->second.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].begin() + chip.VertexListShift;
+ std::vector::iterator vertexCoordItrEnd = vertexCoordItrBegin + 6;
+
+ std::vector::iterator texCoordItrBegin = chip.RenderPair->second.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB].begin() + chip.VertexListShift;
+ std::vector::iterator texCoordItrEnd = texCoordItrBegin + 6;
+
+ std::vector vertexCoordSubVec(vertexCoordItrBegin, vertexCoordItrEnd);
+ std::vector texCoordSubVec(texCoordItrBegin, texCoordItrEnd);
+
+ chip.RenderPair->second.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].erase(vertexCoordItrBegin, vertexCoordItrEnd);
+ chip.RenderPair->second.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB].erase(texCoordItrBegin, texCoordItrEnd);
+
+ MoveVertexListShiftBack(chip.RenderPair, chip.VertexListShift);
+
+ chip.RenderPair->second.NeedRefreshBuffer = true;
+
+ chip.ChipType = newChipType;
+
+ RenderPairIteratorVector[newChipType]->second.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].insert(RenderPairIteratorVector[newChipType]->second.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].end(), vertexCoordSubVec.begin(), vertexCoordSubVec.end());
+ RenderPairIteratorVector[newChipType]->second.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB].insert(RenderPairIteratorVector[newChipType]->second.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB].end(), texCoordSubVec.begin(), texCoordSubVec.end());
+
+ RenderPairIteratorVector[newChipType]->second.NeedRefreshBuffer = true;
+
+ chip.RenderPair = RenderPairIteratorVector[newChipType];
+ chip.VertexListShift = RenderPairIteratorVector[newChipType]->second.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].size() - 6;
+
+ //Hack to make sure animation is replaced by new one
+ ResourceManager->HalibutAnimationManager.DeleteAnimationObject(chip.AnimName);
+ ReplaceAnimation(ivec2(p.v[0], p.v[1]));
+
+
+}
+
+
+void TMatch3Logic::SelectChip(ivec2 pos)
+{
+ if (!(selectedChip == ivec2(-1, -1)))
+ {
+ StopAnimateChip(selectedChip.v[0], selectedChip.v[1]);
+ }
+
+ StartAnimateChip(pos.v[0], pos.v[1]);
+
+ selectedChip = pos;
+}
+
+
+void TMatch3Logic::UnselectChip()
+{
+ if (!(selectedChip == ivec2(-1, -1)))
+ {
+ StopAnimateChip(selectedChip.v[0], selectedChip.v[1]);
+ selectedChip = ivec2(-1, -1);
+ }
+}
+
+ivec2 TMatch3Logic::GetSelectedChip()
+{
+ return selectedChip;
+}
+
+std::vector TMatch3Logic::GetAvailableMatchingChips()
+{
+ std::vector result;
+
+ for (cardinal x=0; xIsReturning = isReturning;
+
+ ChipMatrix[p1.v[0]][p1.v[1]].ChipState = TChip::CS_SWAPPING;
+ ChipMatrix[p2.v[0]][p2.v[1]].ChipState = TChip::CS_SWAPPING;
+
+
+}
+
+void TMatch3Logic::ResetChipPos(ivec2 p)
+{
+ vec2 posFrom(LeftBottomPosField.v[0] + p.v[0]*Match3FieldParams.CellWidth, LeftBottomPosField.v[1] + p.v[1]*Match3FieldParams.CellHeight);
+ vec2 posTo(LeftBottomPosField.v[0] + (p.v[0] + 1)*Match3FieldParams.CellWidth, LeftBottomPosField.v[1] + (p.v[1] + 1)*Match3FieldParams.CellHeight);
+
+ std::vector vertexCoordVec = MakeVertexCoordVec(posFrom, posTo);
+
+ TChip& chip = ChipMatrix[p.v[0]][p.v[1]];
+
+ for (cardinal i = 0; isecond.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB][chip.VertexListShift + i] = vertexCoordVec[i];
+ }
+
+ chip.RenderPair->second.NeedRefreshBuffer = true;
+
+
+}
+
+void TMatch3Logic::UpdateLogic(cardinal dt)
+{
+
+ if (dt > 1000)
+ {
+ dt = 1000; //To prevent float overflow during looong laaaag
+ }
+
+ UpdateChipSwapping(dt);
+ UpdateChipPosition(dt);
+ TryMatchAllChips();
+
+ std::vector::iterator i;
+
+ bool erased = false;
+
+ for (i = ChipDeletingVector.begin(); i != ChipDeletingVector.end();)
+ {
+ erased = false;
+
+ i->T += dt / 150.f;
+
+ if (i->T > 1.f)
+ {
+ i->T = 1.f;
+ }
+
+ ivec2 p = i->Chip;
+ vec2 leftBottomPos = i->Pos;
+
+ vec2 halfPos = vec2(Match3FieldParams.CellWidth / 2.f, Match3FieldParams.CellHeight / 2.f);
+
+ vec2 centerPos = leftBottomPos + halfPos;
+
+ std::vector vertexCoordArr = MakeVertexCoordVec(centerPos - (1.f - i->T)*halfPos, centerPos + (1.f - i->T)*halfPos);
+
+ for (int t = 0; t < 6; t++)
+ {
+ ChipMatrix[p.v[0]][p.v[1]].RenderPair->second.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB][ChipMatrix[p.v[0]][p.v[1]].VertexListShift + t] = vertexCoordArr[t];
+ }
+
+
+ if (i->T == 1.f)
+ {
+
+ ChipMatrix[p.v[0]][p.v[1]].ChipState = TChip::CS_FINISHING;
+
+ i = ChipDeletingVector.erase(i);
+ erased = true;
+ }
+
+ if (i != ChipDeletingVector.end() && !erased)
+ {
+ ++i;
+ }
+ }
+
+ RemoveBubbles();
+}
+
+
+
+void TMatch3Logic::HitFieldWithPattern(ivec2 pos, std::vector > pattern, std::vector > jumpingPattern)
+{
+
+ const float CONST_VELOCITY_TO_ADD = 0.2f;
+
+ for (cardinal i = 0; i < pattern.size(); i++)
+ {
+ for (int j = static_cast(pattern[i].size()-1); j >=0; j--)
+ {
+
+ ivec2 fieldPos = pos + ivec2(i,j);
+
+ if (fieldPos.v[0] >= 0 && fieldPos.v[0] < static_cast(ChipMatrix.size()) &&
+ fieldPos.v[1] >= 0 && fieldPos.v[1] < static_cast(ChipMatrix[fieldPos.v[0]].size()))
+ {
+
+ if (ChipIsStable(fieldPos))
+ {
+ if (pattern[i][j] > 0)
+ {
+ DestroyChip(fieldPos);
+ InsertEmptyChip(fieldPos.v[0], fieldPos.v[1], 0);
+ }
+ }
+
+ if (ChipIsLocked(fieldPos))
+ {
+ ChipMatrix[fieldPos.v[0]][fieldPos.v[1]].ChipState = TChip::CS_STANDBY;
+ }
+ }
+ }
+ }
+
+ for (cardinal i = 0; i < jumpingPattern.size(); i++)
+ {
+
+ ivec2 abovePos = pos + ivec2(i, jumpingPattern[i].size());
+
+ if (abovePos.v[0] >= 0 && abovePos.v[0] < static_cast(ChipMatrix.size()) &&
+ abovePos.v[1] >= 0 && abovePos.v[1] < static_cast(ChipMatrix[i].size()))
+ {
+
+ if (ChipMatrix[abovePos.v[0]][abovePos.v[1]].ChipState == TChip::CS_FALLING ||
+ ChipMatrix[abovePos.v[0]][abovePos.v[1]].ChipState == TChip::CS_STANDBY)
+ {
+ ChipMatrix[abovePos.v[0]][abovePos.v[1]].ChipState = TChip::CS_FALLING;
+ ChipMatrix[abovePos.v[0]][abovePos.v[1]].Velocity += CONST_VELOCITY_TO_ADD;
+ }
+
+ }
+
+
+ for (cardinal j = 0; j < jumpingPattern[i].size(); j++)
+ {
+
+ ivec2 fieldPos = pos + ivec2(i,j);
+
+ if (fieldPos.v[0] >= 0 && fieldPos.v[0] < static_cast(ChipMatrix.size()) &&
+ fieldPos.v[1] >= 0 && fieldPos.v[1] < static_cast(ChipMatrix[fieldPos.v[0]].size()))
+ {
+ if (ChipMatrix[fieldPos.v[0]][fieldPos.v[1]].ChipState == TChip::CS_FALLING ||
+ ChipMatrix[fieldPos.v[0]][fieldPos.v[1]].ChipState == TChip::CS_STANDBY)
+ {
+ if (jumpingPattern[i][j] > 0)
+ {
+ ChipMatrix[fieldPos.v[0]][fieldPos.v[1]].ChipState = TChip::CS_FALLING;
+ ChipMatrix[fieldPos.v[0]][fieldPos.v[1]].Velocity += CONST_VELOCITY_TO_ADD;
+ }
+ }
+ }
+ }
+ }
+
+
+}
+
+
+
+//================================================
+//============ TMatch3Field ======================
+//================================================
+
+
+TMatch3Field::TMatch3Field()
+{
+ LastTappedPos = vec2(0,0);
+}
+
+TMatch3Field::TMatch3Field(const TMatch3Field& m)
+{
+ LastTappedPos = m.LastTappedPos;
+ LastMovePos = m.LastMovePos;
+}
+
+TMatch3Field& TMatch3Field::operator=(const TMatch3Field& m)
+{
+ LastTappedPos = m.LastTappedPos;
+ LastMovePos = m.LastMovePos;
+ return *this;
+}
+
+TMatch3Field::TMatch3Field(TMatch3Controller& match3Controller)
+ //: Match3Controller(match3Controller)
+{
+ //Match3Controller.Match3Field = this;
+
+ FillBasicChipMatrixAndTriangleList();
+}
+
+TMatch3Field::~TMatch3Field()
+{
+}
+
+void TMatch3Field::FillBasicChipMatrixAndTriangleList()
+{
+ TRenderParams renderParams;
+
+ renderParams.Transparency = 1.f;
+
+
+ boost::shared_ptr px(FileToPropertyTree("match3params.xml"));
+ Match3FieldParams.Serialize(*px);
+
+ std::vector triangleListVec;
+
+ for (cardinal i = 0; i < Match3FieldParams.ChipTypeCount; i++)
+ {
+ TriangleListVector.push_back(TRenderPair(Match3FieldParams.ChipTemplateParamsArr[i].SelectedRenderParams, TTriangleList()));
+ }
+
+
+ renderParams.TexName = "chip1locked";
+ TriangleListVector.push_back(TRenderPair(renderParams, TTriangleList()));
+
+ renderParams.TexName = "chip2locked";
+ TriangleListVector.push_back(TRenderPair(renderParams, TTriangleList()));
+
+ renderParams.TexName = "chip3locked";
+ TriangleListVector.push_back(TRenderPair(renderParams, TTriangleList()));
+
+ renderParams.TexName = "chip4locked";
+ TriangleListVector.push_back(TRenderPair(renderParams, TTriangleList()));
+
+
+
+
+ for (cardinal i = 0; i < Match3FieldParams.ChipTypeCount; i++)
+ {
+ TriangleListVector.push_back(TRenderPair(Match3FieldParams.ChipTemplateParamsArr[i].FinishingRenderParams, TTriangleList()));
+ }
+
+ for (TRenderPairList::iterator i = TriangleListVector.begin(); i != TriangleListVector.end(); ++i)
+ {
+
+
+ triangleListVec.push_back(i);
+ }
+
+ LeftBottomPos = vec2(150, 0);
+
+ FillRandomChipMatrix(triangleListVec, LeftBottomPos);
+
+ //Init everything
+ selectedChip = ivec2(-1, -1);
+
+ for (TRenderPairList::iterator i = TriangleListVector.begin(); i != TriangleListVector.end(); ++i)
+ {
+
+ i->second.RefreshBuffer();
+ }
+
+}
+
+
+ivec2 TMatch3Field::PosToChip(vec2 pos)
+{
+
+ int x, y;
+ vec2 fieldPos = pos - LeftBottomPos;
+ x = static_cast(fieldPos.v[0] / Match3FieldParams.CellWidth);
+ y = static_cast(fieldPos.v[1] / Match3FieldParams.CellHeight);
+
+ return ivec2(x, y);
+
+}
+
+void TMatch3Field::Update(cardinal dt)
+{
+
+ TMatch3Logic::UpdateLogic(dt);
+
+
+ TRenderPairList::iterator i;
+ for (i = TriangleListVector.begin(); i != TriangleListVector.end(); ++i)
+ {
+ if (i->second.NeedRefreshBuffer)
+ {
+ i->second.RefreshBuffer();
+ }
+ }
+
+ int y = 6;
+ y = 6 + y;
+
+
+}
+
+void TMatch3Field::OnTapDown(vec2 pos)
+{
+ //See also OnMove
+
+ LastTappedPos = pos;
+ LastMovePos = LastTappedPos;
+
+ ivec2 chip = PosToChip(pos);
+
+
+
+ /*
+ To hit field by pattern
+ std::vector > pattern;
+ pattern.resize(3);
+ pattern[0].resize(3);
+ pattern[1].resize(3);
+ pattern[2].resize(3);
+
+ pattern[0][0] = 0; pattern[1][0] = 1; pattern[2][0] = 0;
+ pattern[0][1] = 1; pattern[1][1] = 1; pattern[2][1] = 1;
+ pattern[0][2] = 0; pattern[1][2] = 1; pattern[2][2] = 0;
+
+ std::vector > jumpingPattern;
+ jumpingPattern.resize(3);
+ jumpingPattern[0].resize(3);
+ jumpingPattern[1].resize(3);
+ jumpingPattern[2].resize(3);
+
+ jumpingPattern[0][0] = 0; jumpingPattern[1][0] = 0; jumpingPattern[2][0] = 0;
+ jumpingPattern[0][1] = 0; jumpingPattern[1][1] = 0; jumpingPattern[2][1] = 0;
+ jumpingPattern[0][2] = 1; jumpingPattern[1][2] = 0; jumpingPattern[2][2] = 1;
+
+
+ HitFieldWithPattern(chip - ivec2(1, 1), pattern, jumpingPattern);
+
+ return;*/
+
+
+
+ if (selectedChip == chip)
+ {
+ UnselectChip();
+ }
+ else
+ {
+
+ if (ChipsCanBeSwapped(selectedChip, chip))
+ {
+ SwapChips(selectedChip, chip);
+ UnselectChip();
+ }
+ else
+ {
+ if (ChipCanBeSelected(chip))
+ {
+ SelectChip(chip);
+ }
+ }
+
+ }
+}
+
+
+void TMatch3Field::OnTapUp(vec2 pos)
+{
+
+}
+
+void TMatch3Field::OnMove(vec2 shift)
+{
+
+ if (selectedChip == ivec2(-1, -1))
+ {
+ return;
+ }
+
+ LastMovePos += shift;
+
+ if ((LastTappedPos - LastMovePos).v[0] >= Match3FieldParams.CellWidth * 0.5f)
+ {
+ ivec2 newPosChip = selectedChip + ivec2(1, 0);
+
+ if (selectedChip.v[0] <= Match3FieldParams.FieldWidth - 2)
+ {
+ if (ChipsCanBeSwapped(selectedChip, newPosChip))
+ {
+ SwapChips(selectedChip, newPosChip);
+ UnselectChip();
+ }
+ }
+ }
+ else if ((LastMovePos - LastTappedPos).v[0] >= Match3FieldParams.CellWidth * 0.5f)
+ {
+ ivec2 newPosChip = selectedChip - ivec2(1, 0);
+
+ if (selectedChip.v[0] >= 1)
+ {
+ if (ChipsCanBeSwapped(selectedChip, newPosChip))
+ {
+ SwapChips(selectedChip, newPosChip);
+ UnselectChip();
+ }
+ }
+ }
+ else if ((LastMovePos - LastTappedPos).v[1] >= Match3FieldParams.CellHeight * 0.5f)
+ {
+ ivec2 newPosChip = selectedChip + ivec2(0, 1);
+
+ if (selectedChip.v[1] <= Match3FieldParams.FieldHeight - 2)
+ {
+ if (ChipsCanBeSwapped(selectedChip, newPosChip))
+ {
+ SwapChips(selectedChip, newPosChip);
+ UnselectChip();
+ }
+ }
+ }
+ else if ((LastTappedPos - LastMovePos).v[1] >= Match3FieldParams.CellHeight * 0.5f)
+ {
+ ivec2 newPosChip = selectedChip - ivec2(0, 1);
+
+ if (selectedChip.v[1] >= 1)
+ {
+ if (ChipsCanBeSwapped(selectedChip, newPosChip))
+ {
+ SwapChips(selectedChip, newPosChip);
+ UnselectChip();
+ }
+ }
+ }
+
+}
+
+
+bool TMatch3Field::CheckClick(vec2 mousePos)
+{
+
+ vec2 fieldPos = mousePos - LeftBottomPos;
+ if (fieldPos.v[0] >= 0 && fieldPos.v[0] <= Match3FieldParams.FieldWidth*Match3FieldParams.CellWidth)
+ {
+ if (fieldPos.v[1] >= 0 && fieldPos.v[1] <= Match3FieldParams.FieldHeight*Match3FieldParams.CellHeight)
+ {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
+
+void TMatch3Field::HighlightMatch3()
+{
+
+ std::vector chips = GetAvailableMatchingChips();
+
+ std::vector::iterator i;
+
+ for (i = chips.begin(); i != chips.end(); ++i)
+ {
+ ResourceManager->HalibutAnimationManager.StartAnimation(ChipMatrix[i->v[0]][i->v[1]].AnimName);
+
+ }
+}
diff --git a/jni/match3/match3field.h b/jni/match3/match3field.h
new file mode 100644
index 0000000..003a4b7
--- /dev/null
+++ b/jni/match3/match3field.h
@@ -0,0 +1,276 @@
+#ifndef MATCH3FIELD_H_INCLUDED
+#define MATCH3FIELD_H_INCLUDED
+
+#include "include/Engine.h"
+
+
+
+const cardinal CONST_MAX_FIELD_WIDTH = 11;
+const cardinal CONST_MAX_FIELD_HEIGHT = 11;
+
+
+const float CONST_MATCH3_CELL_WIDTH = 42.f;
+const float CONST_MATCH3_CELL_HEIGHT = 42.f;
+const float CONST_CHIP_LOWEST_SPEED = -0.5f;
+const float CONST_CHIP_ACCELERATION = -0.0014f;
+
+/*
+const float CONST_MATCH3_CELL_WIDTH = 32.f;
+const float CONST_MATCH3_CELL_HEIGHT = 32.f;
+const float CONST_CHIP_LOWEST_SPEED = -0.3f;
+const float CONST_CHIP_ACCELERATION = -0.001f;
+*/
+const cardinal CONST_MATCH_TIME = 150;
+
+const float CONST_CHIP_POSITION_EPSILON = 1.f;
+const float CONST_CHIP_VELOCITY_EPSILON = 0.3f;
+
+
+const float CONST_CHIP_K = 0.4f;
+
+const cardinal CONST_CHIP_TYPE_COUNT = 4;
+
+
+struct TChipTemplateParams : public TSerializeInterface
+{
+ THalibutExternalAnimObject SelectedTemplateAnimObject;
+ THalibutExternalAnimObject FinishingTemplateAnimObject;
+ TRenderParams SelectedRenderParams;
+ TRenderParams FinishingRenderParams;
+
+ virtual void Serialize(boost::property_tree::ptree& propertyTree);
+
+};
+
+
+struct TMatch3FieldParams : public TSerializeInterface
+{
+ cardinal FieldWidth;
+ cardinal FieldHeight;
+ float CellWidth;
+ float CellHeight;
+ float ChipLowestSpeed;
+ float ChipAcceleration;
+
+ float ChipPositionEpsilon;
+ float ChipVelocityEpsilon;
+ float ChipK;
+ cardinal ChipMatchTime;
+
+ cardinal ChipTypeCount;
+
+ std::vector ChipTemplateParamsArr;
+
+ TMatch3FieldParams()
+ : FieldWidth(CONST_MAX_FIELD_WIDTH)
+ , FieldHeight(CONST_MAX_FIELD_HEIGHT)
+ , CellWidth(CONST_MATCH3_CELL_WIDTH)
+ , CellHeight(CONST_MATCH3_CELL_HEIGHT)
+ , ChipLowestSpeed(CONST_CHIP_LOWEST_SPEED)
+ , ChipAcceleration(CONST_CHIP_ACCELERATION)
+ , ChipPositionEpsilon(CONST_CHIP_POSITION_EPSILON)
+ , ChipVelocityEpsilon(CONST_CHIP_VELOCITY_EPSILON)
+ , ChipK(CONST_CHIP_K)
+ , ChipMatchTime(CONST_MATCH_TIME)
+ , ChipTypeCount(CONST_CHIP_TYPE_COUNT)
+ {
+
+ }
+
+
+ virtual void Serialize(boost::property_tree::ptree& propertyTree);
+
+};
+
+
+struct TChip
+{
+ int ChipType; // -1 means empty field
+ std::string AnimName; //Generated automatically
+
+ TRenderPairList::iterator RenderPair;
+
+ cardinal VertexListShift;
+
+ float Velocity;
+
+ enum TChipState
+ {
+ CS_STANDBY,
+ CS_SWAPPING,
+ CS_FALLING,
+ CS_LOCKED,
+ CS_FINISHING,
+ CS_X,
+ } ChipState;
+
+ TChip(int chipType, TRenderPairList::iterator renderPair, cardinal vertexListShift, TChipState chipState = CS_FALLING);
+
+ ~TChip();
+
+ vec2 GetLeftBottomPos();
+ void SetLeftBottomPos(vec2 newPos);
+ void MoveLeftBottomPos(vec2 shift);
+
+ static int StaticAnimationIndex;
+
+};
+
+struct TChipSwappingPair
+{
+ float T;
+ ivec2 Chip1;
+ ivec2 Chip2;
+
+ vec2 Chip1RealPosFrom;
+ vec2 Chip2RealPosFrom;
+
+ bool IsReturning;
+
+
+ TChipSwappingPair(ivec2 chip1, ivec2 chip2, vec2 chip1PosFrom, vec2 chip2PosFrom)
+ : Chip1(chip1)
+ , Chip2(chip2)
+ , T(0)
+ , Chip1RealPosFrom(chip1PosFrom)
+ , Chip2RealPosFrom(chip2PosFrom)
+ , IsReturning(false)
+ {
+ }
+
+};
+
+struct TChipDeletingData
+{
+ float T;
+ ivec2 Chip;
+ vec2 Pos;
+
+ TChipDeletingData(ivec2 chip, vec2 pos)
+ : T(0.f)
+ , Chip(chip)
+ , Pos(pos)
+ {
+ }
+};
+
+class TMatch3Logic
+{
+protected:
+
+ cardinal ChipTypeCount;
+
+ std::vector > ChipMatrix;
+ std::vector ChipSwappingPairVector;
+ std::vector ChipDeletingVector;
+
+ std::vector RenderPairIteratorVector;
+
+ ivec2 selectedChip;
+
+ vec2 LeftBottomPosField;
+
+ TMatch3FieldParams Match3FieldParams;
+
+ void FillRandomChipMatrix(std::vector renderPairIteratorVector, vec2 leftBottomPos);
+
+ vec2 GetExpectedLeftBottomPos(cardinal x, cardinal y);
+
+ void StartAnimateChip(cardinal x, cardinal y);
+ void StopAnimateChip(cardinal x, cardinal y);
+
+ bool ChipIsLocked(ivec2 chip);
+ bool ChipIsFinishing(ivec2 chip);
+ bool ChipIsStable(ivec2 chip);
+ bool ChipCanBeSelected(ivec2 chip);
+ bool ChipsCanBeSwapped(ivec2 p1, ivec2 p2);
+
+ bool ChipCanBeMatchedUp(ivec2 chip);
+ bool ChipCanBeMatchedDown(ivec2 chip);
+ bool ChipCanBeMatchedLeft(ivec2 chip);
+ bool ChipCanBeMatchedRight(ivec2 chip);
+
+ void UnmatchChips(std::vector chipList);
+ void UpdateChipPosition(cardinal dt);
+ void RemoveBubbles();
+
+ void ReplaceAnimation(ivec2 p);
+
+ void MoveVertexListShiftBack(TRenderPairList::iterator renderPairItr, cardinal moveFrom);
+ void MoveVertexCoordDown(TRenderPairList::iterator renderPairItr, cardinal moveFrom, float value);
+
+ void AddChipToUp(cardinal colNum, int chipType, vec2 spawnPos, TChip::TChipState chipState = TChip::CS_FALLING);
+ void InsertEmptyChip(cardinal colNum, cardinal rowNum, int chipType);
+
+ void UpdateChipSwapping(cardinal dt);
+ void TryMatchAllChips();
+
+ void DestroyChip(ivec2 p);
+
+ void ChangeChipType(ivec2 p);
+
+public:
+
+ TMatch3Logic();
+ virtual ~TMatch3Logic();
+
+ void SelectChip(ivec2 pos);
+ void UnselectChip();
+ ivec2 GetSelectedChip();
+
+ std::vector GetAvailableMatchingChips();
+
+ void SwapChips(ivec2 p1, ivec2 p2, bool isReturning = false);
+
+ void ResetChipPos(ivec2 p);
+
+ void UpdateLogic(cardinal dt);
+
+ void HitFieldWithPattern(ivec2 pos, std::vector > pattern, std::vector > jumpingPattern);
+
+
+};
+
+
+class TMatch3Controller;
+
+class TMatch3Field : public TMatch3Logic, public TInstancingWidgetAncestor
+{
+protected:
+ void FillBasicChipMatrixAndTriangleList();
+
+ //TMatch3Controller& Match3Controller;
+
+ vec2 LastTappedPos;
+ vec2 LastMovePos;
+
+ ivec2 PosToChip(vec2 pos);
+
+public:
+ TMatch3Field();
+ TMatch3Field(const TMatch3Field& m);
+ TMatch3Field& operator=(const TMatch3Field& m);
+
+ TMatch3Field(TMatch3Controller& match3Controller);
+ ~TMatch3Field();
+
+ virtual void Update(cardinal dt);
+ virtual void OnTapDown(vec2 pos);
+ virtual void OnTapUp(vec2 pos);
+ virtual void OnMove(vec2 shift);
+ virtual bool CheckClick(vec2 mousePos);
+
+ void HighlightMatch3();
+
+};
+
+
+
+
+
+
+
+
+
+
+#endif
diff --git a/res/drawable-hdpi/ic_menu_template.png b/res/drawable-hdpi/ic_menu_template.png
new file mode 100644
index 0000000..1e28f93
Binary files /dev/null and b/res/drawable-hdpi/ic_menu_template.png differ
diff --git a/res/drawable-ldpi/ic_menu_template.png b/res/drawable-ldpi/ic_menu_template.png
new file mode 100644
index 0000000..6a93cf2
Binary files /dev/null and b/res/drawable-ldpi/ic_menu_template.png differ
diff --git a/res/drawable-mdpi/ic_menu_template.png b/res/drawable-mdpi/ic_menu_template.png
new file mode 100644
index 0000000..7c1cab2
Binary files /dev/null and b/res/drawable-mdpi/ic_menu_template.png differ
diff --git a/res/raw/music/shot.wav b/res/raw/music/shot.wav
new file mode 100644
index 0000000..883edf0
Binary files /dev/null and b/res/raw/music/shot.wav differ
diff --git a/res/values/strings.xml b/res/values/strings.xml
new file mode 100644
index 0000000..b8fcfcd
--- /dev/null
+++ b/res/values/strings.xml
@@ -0,0 +1,4 @@
+
+
+ AndroidJniTemplate
+
diff --git a/src/fishrungames/crystalofrhylil/GLView.java b/src/fishrungames/crystalofrhylil/GLView.java
new file mode 100644
index 0000000..3388d48
--- /dev/null
+++ b/src/fishrungames/crystalofrhylil/GLView.java
@@ -0,0 +1,72 @@
+package fishrungames.crystalofrhylil;
+
+
+import java.util.Calendar;
+
+import android.content.Context;
+import android.opengl.GLSurfaceView;
+
+import javax.microedition.khronos.egl.EGLConfig;
+import javax.microedition.khronos.opengles.GL10;
+
+import fishrungames.engine.GLViewAncestor;
+
+class GLView extends GLViewAncestor
+{
+ static long lastTimeStamp;
+ static boolean gameIsInited = false;
+
+ public GLView(Context context)
+ {
+ //Change this method? Don't forget to change method below!
+ super(context);
+ init(false, 0, 0);
+ }
+
+ public GLView(Context context, boolean translucent, int depth, int stencil)
+ {
+ //Change this method? Don't forget to change method above!
+ super(context);
+ init(translucent, depth, stencil);
+ }
+
+ public void init(boolean translucent, int depth, int stencil)
+ {
+ super.init(translucent, depth, stencil);
+ setRenderer(new Renderer());
+ Calendar c = Calendar.getInstance();
+ lastTimeStamp = c.getTimeInMillis();
+ gameIsInited = true;
+ }
+
+ private static class Renderer implements GLSurfaceView.Renderer
+ {
+ public void onDrawFrame(GL10 gl)
+ {
+ if (gameIsInited)
+ {
+ Calendar c = Calendar.getInstance();
+
+ long currentTimeStamp = c.getTimeInMillis();
+
+ JniWrapper.Update(currentTimeStamp - lastTimeStamp);
+
+ lastTimeStamp = currentTimeStamp;
+ }
+ }
+
+ public void onSurfaceChanged(GL10 gl, int width, int height)
+ {
+
+
+ //JniWrapper.Destroy();
+
+ JniWrapper.Init(width,height);
+ }
+
+ public void onSurfaceCreated(GL10 gl, EGLConfig config)
+ {
+ //Do nothing.
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/fishrungames/crystalofrhylil/JniWrapper.java b/src/fishrungames/crystalofrhylil/JniWrapper.java
new file mode 100644
index 0000000..f337529
--- /dev/null
+++ b/src/fishrungames/crystalofrhylil/JniWrapper.java
@@ -0,0 +1,26 @@
+
+package fishrungames.crystalofrhylil;
+
+public class JniWrapper
+{
+ static {
+ //System.loadLibrary("gnustl_shared");
+ //System.loadLibrary("HalibutEngine");
+ System.loadLibrary("CrystalOfRhylilLib");
+ }
+
+
+ public static native void Init(int width, int height);
+ public static native void Update(long dt);
+ public static native void StopSounds();
+ public static native void Destroy();
+ public static native int IsInited();
+ public static native void OnTapDown(float x, float y, long time);
+ public static native void OnTapUp(float x, float y, long time);
+ public static native void OnTapMove(float x, float y, long time);
+
+ public static native void OnFling(float velocityX, float velocityY, long time);
+ public static native void OnScroll(float distanceX, float distanceY, long time);
+
+ public static native void OnKeyPress(int keyCode);
+}
\ No newline at end of file
diff --git a/src/fishrungames/crystalofrhylil/MainActivity.java b/src/fishrungames/crystalofrhylil/MainActivity.java
new file mode 100644
index 0000000..99e378d
--- /dev/null
+++ b/src/fishrungames/crystalofrhylil/MainActivity.java
@@ -0,0 +1,186 @@
+package fishrungames.crystalofrhylil;
+
+import fishrungames.engine.FileWrapper;
+
+//Deprecated
+//import fishrungames.crystalofrhylil.R;
+
+import android.app.Activity;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.os.Bundle;
+
+import android.view.GestureDetector;
+import android.view.GestureDetector.SimpleOnGestureListener;
+import android.view.KeyEvent;
+import android.view.MotionEvent;
+
+
+//Deprecated
+//import java.lang.reflect.Field;
+
+
+public class MainActivity extends Activity
+{
+
+ GLView mView;
+
+ boolean IsScrolling = false;
+
+ private GestureDetector gestureDetector;
+
+ @Override
+ protected void onCreate(Bundle icicle)
+ {
+ super.onCreate(icicle);
+
+ gestureDetector = new GestureDetector(new MyGestureListener());
+
+ FileWrapper.LoadHalibutEngineLibrary();
+ FileWrapper.SetActivityInstance(this);
+ FileWrapper.SetupEnviroment();
+/*
+ * Deprecated
+ *
+ try
+ {
+ for (Field f : R.raw.class.getFields())
+ {
+ FileWrapper.AddToFileMap(f.getName(), f.getInt(null));
+ }
+
+
+ } catch (IllegalArgumentException e)
+ {
+ FileWrapper.ConsoleOut("IllegalArgumentException\n");
+ onStop();
+ } catch (IllegalAccessException e)
+ {
+ FileWrapper.ConsoleOut("IllegalAccessException\n");
+ onStop();
+ }
+*/
+ mView = new GLView(getApplication());
+
+ setContentView(mView);
+
+ String apkFilePath = null;
+ ApplicationInfo appInfo = null;
+ PackageManager packMgmr = this.getPackageManager();
+ try {
+ appInfo = packMgmr.getApplicationInfo("fishrungames.crystalofrhylil", 0);
+ } catch (NameNotFoundException e) {
+
+ e.printStackTrace();
+ throw new RuntimeException("Unable to locate assets, aborting...");
+ }
+ apkFilePath = appInfo.sourceDir;
+
+ FileWrapper.SetupApkFilePath(apkFilePath);
+ //FileWrapper.ConsoleOut("Out of java\n");
+
+ }
+
+ @Override
+ protected void onPause()
+ {
+ JniWrapper.Destroy();
+ super.onPause();
+ mView.onPause();
+ }
+
+ @Override
+ protected void onResume()
+ {
+ //Don't write anything here!
+ super.onResume();
+ mView.onResume();
+ }
+
+ @Override
+ protected void onStop()
+ {
+ //Don't write anything here!
+ super.onStop();
+ }
+
+
+ public boolean onKeyDown(int keyCode, KeyEvent event)
+ {
+ int ascii_keycode = keyCode;
+
+ if (keyCode == KeyEvent.KEYCODE_DEL)
+ {
+ ascii_keycode = 8; //Hack - getUnicodeChar does not recognize backspace
+ }
+ else
+ {
+ ascii_keycode = event.getUnicodeChar();
+ }
+
+ JniWrapper.OnKeyPress(ascii_keycode);
+ return super.onKeyDown(keyCode, event);
+ }
+
+ public boolean onKeyUp(int keyCode, KeyEvent event)
+ {
+ return true;
+ }
+
+ public boolean onTouchEvent(MotionEvent event)
+ {
+ if (gestureDetector.onTouchEvent(event))
+ {
+ return true;
+ }
+
+ if (event.getAction() == MotionEvent.ACTION_UP)
+ {
+ float x = event.getX();
+ float y = (float) mView.getHeight() - event.getY();
+
+ if (IsScrolling)
+ {
+ IsScrolling = false;
+ }
+
+ JniWrapper.OnTapUp(x, y, event.getEventTime());
+
+ }
+ return true;
+ }
+
+ class MyGestureListener extends SimpleOnGestureListener
+ {
+
+ @Override
+ public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
+ float velocityY)
+ {
+ JniWrapper.OnFling(velocityX, velocityY, e2.getEventTime());
+ return true;
+ }
+
+ public boolean onScroll(MotionEvent e1, MotionEvent e2,
+ float distanceX, float distanceY)
+ {
+ JniWrapper.OnScroll(distanceX, distanceY, e2.getEventTime());
+ IsScrolling = true;
+ return true;
+ }
+
+ public boolean onDown(MotionEvent event)
+ {
+
+ float x = event.getX();
+ float y = (float) mView.getHeight() - event.getY();
+
+ JniWrapper.OnTapDown(x, y, event.getEventTime());
+
+ return true;
+ }
+
+ }
+
+}
\ No newline at end of file
diff --git a/windows/Crystal of Rhylil.sln b/windows/Crystal of Rhylil.sln
new file mode 100644
index 0000000..83b9142
--- /dev/null
+++ b/windows/Crystal of Rhylil.sln
@@ -0,0 +1,34 @@
+п»ї
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual C++ Express 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Halibut Engine", "..\..\..\Engine\Halibut Engine\Halibut Engine.vcxproj", "{4E274B19-10B2-4987-96C5-76F35A149502}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Crystal of Rhylil", "Crystal of Rhylil\Crystal of Rhylil.vcxproj", "{0080A3E1-DFBF-4557-B198-E6D5D7724393}"
+ ProjectSection(ProjectDependencies) = postProject
+ {4E274B19-10B2-4987-96C5-76F35A149502} = {4E274B19-10B2-4987-96C5-76F35A149502}
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug_nosound|Win32 = Debug_nosound|Win32
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {4E274B19-10B2-4987-96C5-76F35A149502}.Debug_nosound|Win32.ActiveCfg = Debug_nosound|Win32
+ {4E274B19-10B2-4987-96C5-76F35A149502}.Debug_nosound|Win32.Build.0 = Debug_nosound|Win32
+ {4E274B19-10B2-4987-96C5-76F35A149502}.Debug|Win32.ActiveCfg = Debug|Win32
+ {4E274B19-10B2-4987-96C5-76F35A149502}.Debug|Win32.Build.0 = Debug|Win32
+ {4E274B19-10B2-4987-96C5-76F35A149502}.Release|Win32.ActiveCfg = Release|Win32
+ {4E274B19-10B2-4987-96C5-76F35A149502}.Release|Win32.Build.0 = Release|Win32
+ {0080A3E1-DFBF-4557-B198-E6D5D7724393}.Debug_nosound|Win32.ActiveCfg = Debug|Win32
+ {0080A3E1-DFBF-4557-B198-E6D5D7724393}.Debug_nosound|Win32.Build.0 = Debug|Win32
+ {0080A3E1-DFBF-4557-B198-E6D5D7724393}.Debug|Win32.ActiveCfg = Debug|Win32
+ {0080A3E1-DFBF-4557-B198-E6D5D7724393}.Debug|Win32.Build.0 = Debug|Win32
+ {0080A3E1-DFBF-4557-B198-E6D5D7724393}.Release|Win32.ActiveCfg = Release|Win32
+ {0080A3E1-DFBF-4557-B198-E6D5D7724393}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/windows/Crystal of Rhylil/Crystal of Rhylil.filters b/windows/Crystal of Rhylil/Crystal of Rhylil.filters
new file mode 100644
index 0000000..380cb56
--- /dev/null
+++ b/windows/Crystal of Rhylil/Crystal of Rhylil.filters
@@ -0,0 +1,27 @@
+п»ї
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hpp;hxx;hm;inl;inc;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+
+
+ Файлы исходного кода
+
+
+
+
+ Заголовочные файлы
+
+
+
\ No newline at end of file
diff --git a/windows/Crystal of Rhylil/Crystal of Rhylil.vcxproj b/windows/Crystal of Rhylil/Crystal of Rhylil.vcxproj
new file mode 100644
index 0000000..17de6e2
--- /dev/null
+++ b/windows/Crystal of Rhylil/Crystal of Rhylil.vcxproj
@@ -0,0 +1,94 @@
+п»ї
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+
+ {0080A3E1-DFBF-4557-B198-E6D5D7724393}
+ Template
+ Crystal of Rhylil
+
+
+
+ Application
+ true
+ NotSet
+
+
+ Application
+ false
+ true
+ NotSet
+
+
+
+
+
+
+
+
+
+
+
+
+ $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;$(SalmonEnginePath)include
+ $(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib;$(SalmonEnginePath)$(Configuration)
+
+
+ $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;$(SalmonEnginePath)include
+ $(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib;$(SalmonEnginePath)$(Configuration)
+
+
+
+ Level3
+ Disabled
+ $(SalmonEnginePath);$(LibsPath)\boost_1_47_0;$(LibsPath)\openal\OpenAL11_windows_sdk;$(LibsPath)\libogg-1.3.0\include;$(LibsPath)\libvorbis-1.3.2\include;$(LibsPath)\sqplus\sqplus;$(LibsPath)\sqplus\include;$(SolutionDir)\..\jni;$(LibsPath)\DirectXsdk\Include;$(LibsPath)\lpng1510
+ TARGET_WIN32;TARGET_HALIBUT;WIN32_LEAN_AND_MEAN;_WIN32_WINNT=0x0501;DEBUG
+
+
+ true
+ kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;opengl32.lib;glu32.lib;Halibut Engine.lib;libogg_static.lib;libvorbis_static.lib;libvorbisfile_static.lib;OpenAL32.lib;zlib.lib;libpng15.lib;sqplusD.lib;squirrelD.lib;sqdbglibD.lib;sqstdlibD.lib;dsound.lib;dxguid.lib;%(AdditionalDependencies)
+ $(LibsPath)\boost_1_47_0\boost_windows\libs_engine\$(Configuration);$(LibsPath)\libogg-1.3.0\win32\VS2010\Win32\$(Configuration);$(LibsPath)\libvorbis-1.3.2\win32\VS2010\Win32\$(Configuration);$(LibsPath)\openal\OpenAL11_windows_sdk\libs\Win32;$(LibsPath)\sqplus\lib;$(LibsPath)\DirectXsdk\Lib\x86;$(LibsPath)\lpng1510\projects\vstudio\Debug Library
+
+
+
+
+ Level3
+ MaxSpeed
+ true
+ true
+ $(SalmonEnginePath);$(LibsPath)\boost_1_47_0;$(LibsPath)\openal\OpenAL11_windows_sdk;$(LibsPath)\libogg-1.3.0\include;$(LibsPath)\libvorbis-1.3.2\include;$(LibsPath)\sqplus\sqplus;$(LibsPath)\sqplus\include;$(SolutionDir)\..\jni;$(LibsPath)\DirectXsdk\Include;$(LibsPath)\lpng1510
+ TARGET_WIN32;TARGET_HALIBUT;WIN32_LEAN_AND_MEAN;_WIN32_WINNT=0x0501
+
+
+ true
+ true
+ true
+ kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;opengl32.lib;glu32.lib;Halibut Engine.lib;libogg_static.lib;libvorbis_static.lib;libvorbisfile_static.lib;OpenAL32.lib;zlib.lib;libpng15.lib;sqplus.lib;squirrel.lib;sqdbglib.lib;sqstdlib.lib;dsound.lib;dxguid.lib;%(AdditionalDependencies)
+ $(LibsPath)\boost_1_47_0\boost_windows\libs_engine\$(Configuration);$(LibsPath)\libogg-1.3.0\win32\VS2010\Win32\$(Configuration);$(LibsPath)\libvorbis-1.3.2\win32\VS2010\Win32\$(Configuration);$(LibsPath)\openal\OpenAL11_windows_sdk\libs\Win32;$(LibsPath)\sqplus\lib;$(LibsPath)\DirectXsdk\Lib\x86;$(LibsPath)\lpng1510\projects\vstudio\Release Library
+
+
+
+
+
+
+ TARGET_WIN32;HALIBUT_WIN32;DEBUG;WIN32_LEAN_AND_MEAN
+ TARGET_WIN32;HALIBUT_WIN32;WIN32_LEAN_AND_MEAN
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/windows/Crystal of Rhylil/main.cpp b/windows/Crystal of Rhylil/main.cpp
new file mode 100644
index 0000000..b05cf33
--- /dev/null
+++ b/windows/Crystal of Rhylil/main.cpp
@@ -0,0 +1,20 @@
+#include "main.h"
+#include "include/Utils/Utils.h"
+
+#include "boost/property_tree/ptree.hpp"
+#include "boost/property_tree/xml_parser.hpp"
+#include
+#include "boost/foreach.hpp"
+
+
+extern boost::shared_ptr App;
+
+int APIENTRY WinMain(HINSTANCE hCurrentInst, HINSTANCE hPreviousInst,
+ LPSTR lpszCmdLine, int nCmdShow)
+{
+ App->Height = 480;
+ App->Width = 800;
+
+ //Start application
+ return MainLoop(*App);
+}
\ No newline at end of file
diff --git a/windows/Crystal of Rhylil/main.h b/windows/Crystal of Rhylil/main.h
new file mode 100644
index 0000000..efe2bfe
--- /dev/null
+++ b/windows/Crystal of Rhylil/main.h
@@ -0,0 +1,6 @@
+#pragma once
+
+/* Path to the engine */
+#include "HalibutEngineWindows.h"
+
+#include "../../jni/main_code.h"