contrib: remove crazy_moles
[nit.git] / examples / mnit_dino / src / dino.nit
index 684146d..27ced99 100644 (file)
@@ -21,31 +21,26 @@ module dino is
 end
 
 import mnit
-import realtime
 
 import graphism
 import fancy_dino
 import splash
 
-class DinoApp
-       super App
-
+redef class App
        var cavemen_at_first_level = 6
        var cavemen_incr = 4
 
-       var target_dt = 12000000
-
        var game : nullable Game = null
-       var score = new Container[Int](0)
+       var score = new Ref[Int](0)
        var imgs : nullable ImageSet = null
        var splash : nullable SplashScreen = null
 
-       init do super
-
-       redef fun init_window
+       redef fun on_create
        do
                super
 
+               maximum_fps = 80.0
+
                var display = display
                assert display != null
 
@@ -63,16 +58,8 @@ class DinoApp
        do
                var game = game
                if game != null then
-                       var clock = new Clock
-
                        var turn = game.do_turn
                        game.draw( display, imgs.as(not null), turn )
-
-                       var dt = clock.lapse
-                       if dt.sec == 0 and dt.nanosec < target_dt then
-                               var sleep_t = target_dt - dt.nanosec
-                               sys.nanosleep(0, sleep_t)
-                       end
                else
                        splash.draw( display, true )
                end
@@ -94,7 +81,7 @@ class DinoApp
                                if game.won then
                                        next_nbr_caveman += cavemen_incr
                                else
-                                       score = new Container[Int](0)
+                                       score = new Ref[Int](0)
                                        next_nbr_caveman = cavemen_at_first_level
                                end
                                game = new Game( next_nbr_caveman, score )
@@ -111,7 +98,3 @@ class DinoApp
                return false # unknown event, can be handled by something else
        end
 end
-
-fun app: DinoApp do return once new DinoApp
-
-app.main_loop