contrib/asteronits: intro Android version with vibration
authorAlexis Laferrière <alexis.laf@xymus.net>
Tue, 15 Dec 2015 22:34:47 +0000 (17:34 -0500)
committerAlexis Laferrière <alexis.laf@xymus.net>
Wed, 16 Dec 2015 13:45:16 +0000 (08:45 -0500)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

contrib/asteronits/Makefile
contrib/asteronits/src/android.nit [new file with mode: 0644]

index c0db1ed..08b689c 100644 (file)
@@ -26,10 +26,10 @@ check: bin/asteronits
 
 android: bin/asteronits.apk
 bin/asteronits.apk: $(shell ${NITLS} -M src/asteronits.nit android) ${NITC} res/drawable-hdpi/icon.png pre-build
-       ${NITC} src/touch_ui.nit -m android -o $@
+       ${NITC} src/android.nit -m android -o $@
 
 android-release: $(shell ${NITLS} -M src/asteronits.nit android) ${NITC} res/drawable-hdpi/icon.png pre-build
-       ${NITC} src/touch_ui.nit -m android -o bin/asteronits.apk --release
+       ${NITC} src/android.nit -m android -o bin/asteronits.apk --release
 
 res/drawable-hdpi/icon.png: art/icon.svg
        make -C ../inkscape_tools/
diff --git a/contrib/asteronits/src/android.nit b/contrib/asteronits/src/android.nit
new file mode 100644 (file)
index 0000000..4042f6d
--- /dev/null
@@ -0,0 +1,35 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# 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.
+
+import ::android::platform
+import ::android::vibration
+
+import asteronits
+import touch_ui
+
+redef class Ship
+       redef fun hit
+       do
+               super
+               app.vibrator.vibrate 20
+       end
+end
+
+redef class Asteroid
+       redef fun destroy
+       do
+               super
+               app.vibrator.vibrate 10
+       end
+end