dino: use vibration on Android
authorAlexis Laferrière <alexis.laf@xymus.net>
Tue, 8 Apr 2014 19:53:29 +0000 (15:53 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Thu, 5 Jun 2014 15:13:05 +0000 (11:13 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

examples/mnit_dino/src/dino_android.nit

index 9468aa9..1a3459a 100644 (file)
@@ -1,6 +1,6 @@
 # This file is part of NIT ( http://www.nitlanguage.org ).
 #
-# Copyright 2012-2013 Alexis Laferrière <alexis.laf@xymus.net>
+# Copyright 2012-2014 Alexis Laferrière <alexis.laf@xymus.net>
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@ end
 import dino
 
 import mnit_android
+import android::vibration
 
 redef class ImageSet
        redef fun start_over_path do return "images/play_again_mobile.png"
@@ -33,3 +34,21 @@ end
 redef class Display
        redef fun top_offset do return 92
 end
+
+redef class Dino
+       # When hit, vibrate
+       redef fun hit(hitter, dmg)
+       do
+               app.vibrator.vibrate 25
+               super
+       end
+end
+
+redef class Caveman
+       # When crushed, vibrate a little
+       redef fun die(turn)
+       do
+               app.vibrator.vibrate 10
+               super
+       end
+end