examples/moles: intro new traps; nukes and big cacti disguised as moles
authorAlexis Laferrière <alexis.laf@xymus.net>
Sun, 9 Aug 2015 15:00:34 +0000 (11:00 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Wed, 12 Aug 2015 18:42:12 +0000 (14:42 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

examples/mnit_moles/src/moles.nit
examples/mnit_moles/src/moles_android.nit
examples/mnit_moles/src/moles_linux.nit
examples/mnit_moles/src/more_traps.nit [new file with mode: 0644]

index 38986cc..4625ac7 100644 (file)
@@ -211,7 +211,8 @@ class Game
                end
        end
 
-       fun do_turn do
+       fun do_turn
+       do
                for hole in holes do hole.do_turn
 
                speed_modifier = modifier_half_life / (modifier_half_life+points.to_f) * global_speed_modifier
index 722202d..891ff53 100644 (file)
@@ -21,6 +21,7 @@ import android::portrait
 
 import moles
 import effects
+import more_traps
 
 redef class Game
        redef fun columns do return 3
index 2d8a27a..66a645a 100644 (file)
@@ -20,5 +20,6 @@ import mnit_linux
 
 import moles
 import effects
+import more_traps
 
 redef fun display_scale do return 0.25
diff --git a/examples/mnit_moles/src/more_traps.nit b/examples/mnit_moles/src/more_traps.nit
new file mode 100644 (file)
index 0000000..cf64cc5
--- /dev/null
@@ -0,0 +1,58 @@
+# 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.
+
+# Add more traps
+module more_traps
+
+import moles
+import effects
+
+# Nuclear trap
+class Nuke
+       super Trap
+
+       redef fun penalty_img do return app.assets.penalty_hundred
+
+       redef fun flashes do return [
+               new Flash(5.0, 0.0, 1.0, 0.0, 0.0, 1.25, 2.0),
+               new Flash(0.2, 0.0, 1.0, 1.0, 1.0, 1.0, 2.0)]
+end
+
+# Large cactus trap
+class BigTrap
+       super Trap
+
+       redef fun penalty_img do return app.assets.penalty_twenty
+end
+
+redef class Game
+
+       # Nuclear trap
+       var nuke = new Nuke(app.assets.nuke, 180.0*display_scale, 780.0*display_scale, 100) is lazy
+
+       # Large cactus trap
+       var big_cactus = new BigTrap(app.assets.big_cactus, 242.0*display_scale, 820.0*display_scale, 20) is lazy
+end
+
+redef class Hole
+       redef fun to_pop
+       do
+               if game.points > 25 then
+                       if 25.rand == 0 then return game.big_cactus
+                       if game.points > 50 and 100.rand == 0 then return game.nuke
+               end
+
+               return super
+       end
+end