- remove pointless leveltime from world1 levels
authorMatthias Braun <matze@braunis.de>
Wed, 12 Apr 2006 12:36:29 +0000 (12:36 +0000)
committerMatthias Braun <matze@braunis.de>
Wed, 12 Apr 2006 12:36:29 +0000 (12:36 +0000)
- rework console to not have static functions everywhere
- fix a few crashs/assertions
- minor fixes I forgot...

SVN-Revision: 3314

38 files changed:
data/levels/world1/01 - Welcome to Antarctica.stl
data/levels/world1/02 - The Journey Begins.stl
data/levels/world1/03 - Via Nostalgica.stl
data/levels/world1/04 - Tobgle Road.stl
data/levels/world1/05 - The Somewhat Smaller Bath.stl
data/levels/world1/07 - Oh No More Snowballs.stl
data/levels/world1/08 - Stone Cold.stl
data/levels/world1/09 - Grumbels Sense of Snow.stl
data/levels/world1/10 - 23rd Airborne.stl
data/levels/world1/11 - Night Chill.stl
data/levels/world1/12 - Into the Stars.stl
data/levels/world1/13 - Above the Arctic Skies.stl
data/levels/world1/14 - Entrance to the Cave.stl
data/levels/world1/15 - Under the Ice.stl
data/levels/world1/16 - Living in a Fridge.stl
data/levels/world1/17 - Or is it just me.stl
data/levels/world1/18 - Ice in the Hole.stl
data/levels/world1/19 - Miyamoto Monument.stl
data/levels/world1/20 - End of the Tunnel.stl
data/levels/world1/21 - A Path in the Clouds.stl
data/levels/world1/22 - A Mysterious House of Ice.stl
data/levels/world1/23 - The Escape.stl
data/levels/world1/24 - The Shattered Bridge.stl
data/levels/world1/25 - Arctic Ruins.stl
data/levels/world1/26 - The Castle of Nolok.stl
data/levels/world1/27 - No More Mr Ice Guy.stl
data/levels/world1/yeti.stl [deleted file]
src/console.cpp
src/console.hpp
src/control/joystickkeyboardcontroller.cpp
src/game_session.cpp
src/game_session.hpp
src/main.cpp
src/mainloop.cpp
src/player_status.cpp
src/sector.cpp
src/title.cpp
src/world.cpp

index 78ffbc4..4dc546b 100644 (file)
@@ -96,9 +96,6 @@
       (image "images/background/arctis.jpg")
       (speed 0.5)
     )
       (image "images/background/arctis.jpg")
       (speed 0.5)
     )
-    (leveltime
-      (time 300)
-    )
     (camera
       (mode "normal")
     )
     (camera
       (mode "normal")
     )
index b121544..ba32417 100644 (file)
@@ -96,9 +96,6 @@
       (image "images/background/arctis.jpg")
       (speed 0.5)
     )
       (image "images/background/arctis.jpg")
       (speed 0.5)
     )
-    (leveltime
-      (time 300)
-    )
     (camera
       (mode "normal")
     )
     (camera
       (mode "normal")
     )
index 7cc6655..b6b8e26 100644 (file)
@@ -96,9 +96,6 @@
       (image "images/background/arctis.jpg")
       (speed 0.5)
     )
       (image "images/background/arctis.jpg")
       (speed 0.5)
     )
-    (leveltime
-      (time 300)
-    )
     (camera
       (mode "normal")
     )
     (camera
       (mode "normal")
     )
index 6258099..bcbe6d3 100644 (file)
@@ -96,9 +96,6 @@
       (image "images/background/arctis.jpg")
       (speed 0.5)
     )
       (image "images/background/arctis.jpg")
       (speed 0.5)
     )
-    (leveltime
-      (time 300)
-    )
     (camera
       (mode "normal")
     )
     (camera
       (mode "normal")
     )
index 174970a..b71fe88 100644 (file)
@@ -96,9 +96,6 @@
       (image "images/background/arctis.jpg")
       (speed 0.5)
     )
       (image "images/background/arctis.jpg")
       (speed 0.5)
     )
-    (leveltime
-      (time 300)
-    )
     (camera
       (mode "normal")
     )
     (camera
       (mode "normal")
     )
index 4a85e91..94f3c18 100644 (file)
@@ -96,9 +96,6 @@
       (image "images/background/arctis.jpg")
       (speed 0.5)
     )
       (image "images/background/arctis.jpg")
       (speed 0.5)
     )
-    (leveltime
-      (time 300)
-    )
     (camera
       (mode "normal")
     )
     (camera
       (mode "normal")
     )
index 2872957..91a72f1 100644 (file)
@@ -96,9 +96,6 @@
       (image "images/background/arctis.jpg")
       (speed 0.5)
     )
       (image "images/background/arctis.jpg")
       (speed 0.5)
     )
-    (leveltime
-      (time 300)
-    )
     (camera
       (mode "normal")
     )
     (camera
       (mode "normal")
     )
index 39a9db0..649b59a 100644 (file)
@@ -96,9 +96,6 @@
       (image "images/background/arctis.jpg")
       (speed 0.5)
     )
       (image "images/background/arctis.jpg")
       (speed 0.5)
     )
-    (leveltime
-      (time 300)
-    )
     (particles-snow
       (layer -200)
     )
     (particles-snow
       (layer -200)
     )
index fd9ab8e..f60131f 100644 (file)
@@ -96,9 +96,6 @@
       (image "images/background/arctis.jpg")
       (speed 0.5)
     )
       (image "images/background/arctis.jpg")
       (speed 0.5)
     )
-    (leveltime
-      (time 300)
-    )
     (camera
       (mode "normal")
     )
     (camera
       (mode "normal")
     )
index e312ae9..d3587da 100644 (file)
@@ -96,9 +96,6 @@
       (top_color 0.0 0.0 0.0)
       (bottom_color 0.0 0.0 0.4)
     )
       (top_color 0.0 0.0 0.0)
       (bottom_color 0.0 0.0 0.4)
     )
-    (leveltime
-      (time 300)
-    )
     (particles-snow
       (layer -200)
     )
     (particles-snow
       (layer -200)
     )
index f8a92d7..821136b 100644 (file)
@@ -96,9 +96,6 @@
       (top_color 0.0 0.0 0.0)
       (bottom_color 0.0 0.0 0.4)
     )
       (top_color 0.0 0.0 0.0)
       (bottom_color 0.0 0.0 0.4)
     )
-    (leveltime
-      (time 300)
-    )
     (particles-snow
       (layer -200)
     )
     (particles-snow
       (layer -200)
     )
index bcb6d54..0aec9d2 100644 (file)
@@ -97,9 +97,6 @@
       (top_color 0.4 0.6 1.0)
       (bottom_color 1.0 1.0 1.0)
     )
       (top_color 0.4 0.6 1.0)
       (bottom_color 1.0 1.0 1.0)
     )
-    (leveltime
-      (time 200)
-    )
     (particles-clouds
       (layer -200)
     )
     (particles-clouds
       (layer -200)
     )
index 9b644fe..ab10d5e 100644 (file)
@@ -95,9 +95,6 @@
       (image "images/background/arctis.jpg")
       (speed 0.5)
     )
       (image "images/background/arctis.jpg")
       (speed 0.5)
     )
-    (leveltime
-      (time 300)
-    )
     (camera
       (mode "normal")
     )
     (camera
       (mode "normal")
     )
index 68eb7c0..19e84f6 100644 (file)
@@ -95,9 +95,6 @@
       (image "images/background/cave2.jpg")
       (speed 0.5)
     )
       (image "images/background/cave2.jpg")
       (speed 0.5)
     )
-    (leveltime
-      (time 300)
-    )
     (camera
       (mode "normal")
     )
     (camera
       (mode "normal")
     )
index 14aaf01..625c054 100644 (file)
@@ -95,9 +95,6 @@
       (image "images/background/cave2.jpg")
       (speed 0.5)
     )
       (image "images/background/cave2.jpg")
       (speed 0.5)
     )
-    (leveltime
-      (time 300)
-    )
     (camera
       (mode "normal")
     )
     (camera
       (mode "normal")
     )
index cf2ea28..cd3485c 100644 (file)
@@ -95,9 +95,6 @@
       (image "images/background/cave2.jpg")
       (speed 0.5)
     )
       (image "images/background/cave2.jpg")
       (speed 0.5)
     )
-    (leveltime
-      (time 300)
-    )
     (camera
       (mode "normal")
     )
     (camera
       (mode "normal")
     )
index 275fb93..0f10ee2 100644 (file)
@@ -95,9 +95,6 @@
       (image "images/background/cave2.jpg")
       (speed 0.5)
     )
       (image "images/background/cave2.jpg")
       (speed 0.5)
     )
-    (leveltime
-      (time 300)
-    )
     (camera
       (mode "normal")
     )
     (camera
       (mode "normal")
     )
index 6291835..276c139 100644 (file)
@@ -95,9 +95,6 @@
       (image "images/background/cave2.jpg")
       (speed 0.5)
     )
       (image "images/background/cave2.jpg")
       (speed 0.5)
     )
-    (leveltime
-      (time 300)
-    )
     (camera
       (mode "normal")
     )
     (camera
       (mode "normal")
     )
index 903f1ad..a6c7b21 100644 (file)
@@ -95,9 +95,6 @@
       (image "images/background/cave2.jpg")
       (speed 0.5)
     )
       (image "images/background/cave2.jpg")
       (speed 0.5)
     )
-    (leveltime
-      (time 300)
-    )
     (camera
       (mode "normal")
     )
     (camera
       (mode "normal")
     )
index 81d3c4e..cce1c96 100644 (file)
@@ -95,9 +95,6 @@
       (image "images/background/arctis.jpg")
       (speed 0.5)
     )
       (image "images/background/arctis.jpg")
       (speed 0.5)
     )
-    (leveltime
-      (time 300)
-    )
     (camera
       (mode "normal")
     )
     (camera
       (mode "normal")
     )
index d0f49da..19ad7ce 100644 (file)
@@ -95,9 +95,6 @@
       (image "images/background/arctis.jpg")
       (speed 0.5)
     )
       (image "images/background/arctis.jpg")
       (speed 0.5)
     )
-    (leveltime
-      (time 300)
-    )
     (camera
       (mode "normal")
     )
     (camera
       (mode "normal")
     )
index 4d636a9..0a02252 100644 (file)
@@ -96,9 +96,6 @@
       (image "images/background/arctis.jpg")
       (speed 0.5)
     )
       (image "images/background/arctis.jpg")
       (speed 0.5)
     )
-    (leveltime
-      (time 300)
-    )
     (camera
       (mode "normal")
     )
     (camera
       (mode "normal")
     )
index 8133925..7c2cf5e 100644 (file)
@@ -96,9 +96,6 @@
          (image "images/background/ocean.jpg")
          (speed 0.500000)
        )
          (image "images/background/ocean.jpg")
          (speed 0.500000)
        )
-       (leveltime
-         (time 300.000000)
-       )
        (spawnpoint (name "main") (x 96) (y 160))
        (firefly (x 6860) (y 222))
        (mriceblock (x 757) (y 221))
        (spawnpoint (name "main") (x 96) (y 160))
        (firefly (x 6860) (y 222))
        (mriceblock (x 757) (y 221))
index b1a4e01..86c833d 100644 (file)
@@ -97,9 +97,6 @@
       (image "images/background/ocean.jpg")
       (speed 0.5)
     )
       (image "images/background/ocean.jpg")
       (speed 0.5)
     )
-    (leveltime
-      (time 300)
-    )
     (camera
       (mode "normal")
     )
     (camera
       (mode "normal")
     )
index 9958c7a..4bccd2e 100644 (file)
@@ -95,9 +95,6 @@
       (top_color 0.0 0.0 0.0)
       (bottom_color 0.6 0.0 0.0)
     )
       (top_color 0.0 0.0 0.0)
       (bottom_color 0.6 0.0 0.0)
     )
-    (leveltime
-      (time 300)
-    )
     (camera
       (mode "normal")
     )
     (camera
       (mode "normal")
     )
index 9f60d7e..787ade2 100644 (file)
        )
        (spawnpoint (name "main") (x 480) (y 448))
        (init-script "
        )
        (spawnpoint (name "main") (x 480) (y 448))
        (init-script "
-DisplayEffect.fade_in(2.5);
+Effect.fade_in(1);
 ")
        (yeti
          (x 2)
 ")
        (yeti
          (x 2)
@@ -112,12 +112,9 @@ Text.set_text(\"You Made It BIG TIME!\");
 Text.set_font(\"big\");
 Text.fade_in(1.5);
 wait(6);
 Text.set_font(\"big\");
 Text.fade_in(1.5);
 wait(6);
-DisplayEffect.fade_out(1.5);
+Effect.fade_out(1.5);
 wait(1.5);
 wait(1.5);
-
-
-
-Level.finish();
+Level.finish(true);
 ")
         )
        (particles-snow
 ")
         )
        (particles-snow
diff --git a/data/levels/world1/yeti.stl b/data/levels/world1/yeti.stl
deleted file mode 100644 (file)
index d909f4a..0000000
+++ /dev/null
@@ -1,147 +0,0 @@
-;; Generated by Flexlay Editor
-(supertux-level
-  (version 2)
-  (name   (_ "Yeti Test"))
-  (author "Team")
-  (sector
-    (name  "main")
-    (music  "music/bossattack.ogg")
-    (gravity 10.000000)
-    (tilemap
-      (layer  "background")
-      (solid #f)
-      (speed  1.000000)
-      (width  25)
-      (height 20)
-      (tiles
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        ))
-    (tilemap
-      (layer  "interactive")
-      (solid #t)
-      (speed  1.000000)
-      (width  25)
-      (height 20)
-      (tiles
-        11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 
-        17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        8 8 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 8 8 
-        14 14 15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 13 14 14 
-        11 11 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 11 11 
-        11 11 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 11 11 
-        11 11 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 11 11 
-        11 11 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 11 11 
-        11 11 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 11 11 
-        11 11 21 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 22 11 11 
-        11 11 20 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 23 11 11 
-        ))
-    (tilemap
-      (layer  "foreground")
-      (solid #f)
-      (speed  1.000000)
-      (width  25)
-      (height 20)
-      (tiles
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
-        ))
-    (camera
-      (mode "normal")
-    )
-
-       (background
-         (image "images/background/semi_arctic.jpg")
-         (speed 0.500000)
-       )
-       (spawnpoint (name "main") (x 480) (y 448))
-       (init-script "
-DisplayEffect.fade_in(2.5);
-")
-       (yeti
-         (x 2)
-         (y 177)
-         (dead-script "
-Sound.play(\"sounds/invincible.wav\");
-Text.set_text(\"You Made It BIG TIME!\");
-Text.set_font(\"big\");
-Text.fade_in(1.5);
-wait(6);
-DisplayEffect.fade_out(1.5);
-wait(1.5);
-
-
-
-Level.finish();
-")
-        )
-       (particles-snow
-       )
-       (yeti_stalactite (x 97) (y 32))
-       (yeti_stalactite (x 128) (y 32))
-       (yeti_stalactite (x 161) (y 32))
-       (yeti_stalactite (x 191) (y 32))
-       (yeti_stalactite (x 223) (y 32))
-       (yeti_stalactite (x 255) (y 32))
-       (yeti_stalactite (x 288) (y 32))
-       (yeti_stalactite (x 321) (y 32))
-       (yeti_stalactite (x 352) (y 32))
-       (yeti_stalactite (x 384) (y 32))
-       (yeti_stalactite (x 417) (y 32))
-       (yeti_stalactite (x 576) (y 32))
-       (yeti_stalactite (x 545) (y 32))
-       (yeti_stalactite (x 512) (y 32))
-       (yeti_stalactite (x 479) (y 32))
-       (yeti_stalactite (x 448) (y 32))
-       (yeti_stalactite (x 607) (y 32))
-       (yeti_stalactite (x 639) (y 32))
-       (yeti_stalactite (x 671) (y 32))
-   )
- )
-
-;; EOF ;;
index 257172c..66b7a6c 100644 (file)
 #include "main.hpp"
 #include "resources.hpp"
 
 #include "main.hpp"
 #include "resources.hpp"
 
-namespace {
-  int ticks; // TODO: use a clock?
-}
+/// speed (pixels/s) the console closes
+static const float CLOSE_SPEED = 50;
 
 Console::Console()
 
 Console::Console()
+  : backgroundOffset(0), height(0), offset(0), focused(false), stayOpen(0)
 {
 {
-  background = new Surface("images/engine/console.png");
-  background2 = new Surface("images/engine/console2.png");
+  background.reset(new Surface("images/engine/console.png"));
+  background2.reset(new Surface("images/engine/console2.png"));
 }
 
 Console::~Console() 
 {
 }
 
 Console::~Console() 
 {
-  delete background;
-  delete background2;
 }
 
 void 
 }
 
 void 
@@ -156,7 +154,9 @@ Console::addLine(std::string s)
     if (height < 4+9) height=4+9;
     height+=9;
   }
     if (height < 4+9) height=4+9;
     height+=9;
   }
-  ticks=60;
+
+  if(stayOpen < 5)
+    stayOpen += 0.7;
 }
 
 void
 }
 
 void
@@ -247,6 +247,7 @@ Console::hide()
 {
   focused = false;
   height = 0;
 {
   focused = false;
   height = 0;
+  stayOpen = 0;
 
   // clear input buffer
   inputBuffer.str(std::string());
 
   // clear input buffer
   inputBuffer.str(std::string());
@@ -263,22 +264,29 @@ Console::toggle()
   }
 }
 
   }
 }
 
+void
+Console::update(float elapsed_time)
+{
+  if(stayOpen > 0) {
+    stayOpen -= elapsed_time;
+    if(stayOpen < 0)
+      stayOpen = 0;
+  } else if(!focused && height > 0) {
+    height -= elapsed_time * CLOSE_SPEED;
+    if(height < 0)
+      height = 0;
+  }
+}
+
 void 
 Console::draw(DrawingContext& context)
 {
 void 
 Console::draw(DrawingContext& context)
 {
-  if (height == 0) return;
-  if (!focused) {
-    if (ticks-- < 0) {
-      height-=10;
-      ticks=0;
-      if (height < 0) height=0;
-    }
-    if (height == 0) return;
-  }
+  if (height == 0)
+    return;
 
 
-  context.draw_surface(background2, Vector(SCREEN_WIDTH/2 - background->get_width()/2 - background->get_width() + backgroundOffset, height - background->get_height()), LAYER_FOREGROUND1+1);
-  context.draw_surface(background2, Vector(SCREEN_WIDTH/2 - background->get_width()/2 + backgroundOffset, height - background->get_height()), LAYER_FOREGROUND1+1);
-  context.draw_surface(background, Vector(SCREEN_WIDTH/2 - background->get_width()/2, height - background->get_height()), LAYER_FOREGROUND1+1);
+  context.draw_surface(background2.get(), Vector(SCREEN_WIDTH/2 - background->get_width()/2 - background->get_width() + backgroundOffset, height - background->get_height()), LAYER_FOREGROUND1+1);
+  context.draw_surface(background2.get(), Vector(SCREEN_WIDTH/2 - background->get_width()/2 + backgroundOffset, height - background->get_height()), LAYER_FOREGROUND1+1);
+  context.draw_surface(background.get(), Vector(SCREEN_WIDTH/2 - background->get_width()/2, height - background->get_height()), LAYER_FOREGROUND1+1);
   backgroundOffset+=10;
   if (backgroundOffset > (int)background->get_width()) backgroundOffset -= (int)background->get_width();
 
   backgroundOffset+=10;
   if (backgroundOffset > (int)background->get_width()) backgroundOffset -= (int)background->get_width();
 
@@ -334,14 +342,9 @@ Console::unregisterCommands(ConsoleCommandReceiver* ccr)
   }
 }
 
   }
 }
 
-int Console::height = 0;
-bool Console::focused = false;
-std::list<std::string> Console::lines;
-std::map<std::string, std::list<ConsoleCommandReceiver*> > Console::commands;
+Console* Console::instance = NULL;
 ConsoleStreamBuffer Console::inputBuffer;
 ConsoleStreamBuffer Console::outputBuffer;
 std::ostream Console::input(&Console::inputBuffer);
 std::ostream Console::output(&Console::outputBuffer);
 ConsoleStreamBuffer Console::inputBuffer;
 ConsoleStreamBuffer Console::outputBuffer;
 std::ostream Console::input(&Console::inputBuffer);
 std::ostream Console::output(&Console::outputBuffer);
-int Console::offset = 0;
-int Console::backgroundOffset = 0;
 
 
index 1863309..fd728df 100644 (file)
@@ -35,70 +35,78 @@ class Surface;
 
 class Console 
 {
 
 class Console 
 {
-  public:
-    Console();
-    ~Console();
-
-    static std::ostream input; /**< stream of keyboard input to send to the console. Do not forget to send std::endl or to flush the stream. */
-    static std::ostream output; /**< stream of characters to output to the console. Do not forget to send std::endl or to flush the stream. */
-
-    static void backspace(); /**< delete last character sent to the input stream */
-    static void scroll(int offset); /**< scroll console text up or down by @c offset lines */
-    static void autocomplete(); /**< autocomplete current command */
-
-    void draw(DrawingContext& context); /**< draw the console in a DrawingContext */
-    static void show(); /**< display the console */
-    static void hide(); /**< hide the console */
-    static void toggle(); /**< display the console if hidden, hide otherwise */
-
-    static bool hasFocus(); /**< true if characters should be sent to the console instead of their normal target */
-    static void registerCommand(std::string command, ConsoleCommandReceiver* ccr); /**< associate command with the given CCR */
-    static void unregisterCommand(std::string command, ConsoleCommandReceiver* ccr); /**< dissociate command and CCR */
-    static void unregisterCommands(ConsoleCommandReceiver* ccr); /**< dissociate all commands of given CCR */
-
-    template<typename T> static bool string_is(std::string s) {
-      std::istringstream iss(s);
-      T i;
-      if ((iss >> i) && iss.eof()) {
-       return true;
-      } else {
-       return false;
-      }
+public:
+  Console();
+  ~Console();
+
+  static Console* instance;
+
+  static std::ostream input; /**< stream of keyboard input to send to the console. Do not forget to send std::endl or to flush the stream. */
+  static std::ostream output; /**< stream of characters to output to the console. Do not forget to send std::endl or to flush the stream. */
+
+  void backspace(); /**< delete last character sent to the input stream */
+  void scroll(int offset); /**< scroll console text up or down by @c offset lines */
+  void autocomplete(); /**< autocomplete current command */
+
+  void draw(DrawingContext& context); /**< draw the console in a DrawingContext */
+  void update(float elapsed_time);
+  
+  void show(); /**< display the console */
+  void hide(); /**< hide the console */
+  void toggle(); /**< display the console if hidden, hide otherwise */
+
+  bool hasFocus(); /**< true if characters should be sent to the console instead of their normal target */
+  void registerCommand(std::string command, ConsoleCommandReceiver* ccr); /**< associate command with the given CCR */
+  void unregisterCommand(std::string command, ConsoleCommandReceiver* ccr); /**< dissociate command and CCR */
+  void unregisterCommands(ConsoleCommandReceiver* ccr); /**< dissociate all commands of given CCR */
+
+  template<typename T> static bool string_is(std::string s) {
+    std::istringstream iss(s);
+    T i;
+    if ((iss >> i) && iss.eof()) {
+      return true;
+    } else {
+      return false;
     }
     }
+  }
 
 
-    template<typename T> static T string_to(std::string s) {
-      std::istringstream iss(s);
-      T i;
-      if ((iss >> i) && iss.eof()) {
-       return i;
-      } else {
-       return T();
-      }
+  template<typename T> static T string_to(std::string s) {
+    std::istringstream iss(s);
+    T i;
+    if ((iss >> i) && iss.eof()) {
+      return i;
+    } else {
+      return T();
     }
     }
+  }
 
 
-  protected:
-    static std::list<std::string> lines; /**< backbuffer of lines sent to the console */
-    static std::map<std::string, std::list<ConsoleCommandReceiver*> > commands; /**< map of console commands and a list of associated ConsoleCommandReceivers */
-    Surface* background; /**< console background image */
-    Surface* background2; /**< second, moving console background image */
-    static int backgroundOffset; /**< current offset of scrolling background image */
-    static int height; /**< height of the console in px */
-    static int offset; /**< decrease to scroll text up */
-    static bool focused; /**< true if console has input focus */
-
-    static ConsoleStreamBuffer inputBuffer; /**< stream buffer used by input stream */
-    static ConsoleStreamBuffer outputBuffer; /**< stream buffer used by output stream */
-
-    static void addLine(std::string s); /**< display a line in the console */
-    static void parse(std::string s); /**< react to a given command */
+private:
+  std::list<std::string> lines; /**< backbuffer of lines sent to the console */
+  std::map<std::string, std::list<ConsoleCommandReceiver*> > commands; /**< map of console commands and a list of associated ConsoleCommandReceivers */
+  
+  std::auto_ptr<Surface> background; /**< console background image */
+  std::auto_ptr<Surface> background2; /**< second, moving console background image */
+  
+  int backgroundOffset; /**< current offset of scrolling background image */
+  float height; /**< height of the console in px */
+  int offset; /**< decrease to scroll text up */
+  bool focused; /**< true if console has input focus */
+
+  float stayOpen;
+
+  static ConsoleStreamBuffer inputBuffer; /**< stream buffer used by input stream */
+  static ConsoleStreamBuffer outputBuffer; /**< stream buffer used by output stream */
+
+  void addLine(std::string s); /**< display a line in the console */
+  void parse(std::string s); /**< react to a given command */
     
     
-    /** execute squirrel script and output result */
-    static void execute_script(const std::string& s);
+  /** execute squirrel script and output result */
+  void execute_script(const std::string& s);
     
     
-    static bool consoleCommand(std::string command, std::vector<std::string> arguments); /**< process internal command; return false if command was unknown, true otherwise */
+  bool consoleCommand(std::string command, std::vector<std::string> arguments); /**< process internal command; return false if command was unknown, true otherwise */
 
 
-    friend class ConsoleStreamBuffer;
-    static void flush(ConsoleStreamBuffer* buffer); /**< act upon changes in a ConsoleStreamBuffer */
+  friend class ConsoleStreamBuffer;
+  void flush(ConsoleStreamBuffer* buffer); /**< act upon changes in a ConsoleStreamBuffer */
 };
 
 class ConsoleStreamBuffer : public std::stringbuf 
 };
 
 class ConsoleStreamBuffer : public std::stringbuf 
@@ -107,7 +115,8 @@ class ConsoleStreamBuffer : public std::stringbuf
     int sync() 
     {
       int result = std::stringbuf::sync();
     int sync() 
     {
       int result = std::stringbuf::sync();
-      Console::flush(this);
+      if(Console::instance != NULL)
+        Console::instance->flush(this);
       return result;
     }
 };
       return result;
     }
 };
@@ -117,7 +126,7 @@ class ConsoleCommandReceiver
 public:
   virtual ~ConsoleCommandReceiver()
   {
 public:
   virtual ~ConsoleCommandReceiver()
   {
-    Console::unregisterCommands(this);
+    Console::instance->unregisterCommands(this);
   }
    
   /**
   }
    
   /**
index cffa6f5..d154f15 100644 (file)
@@ -343,12 +343,12 @@ JoystickKeyboardController::process_key_event(const SDL_Event& event)
   // if console key was pressed: toggle console
   if ((key_mapping != keymap.end()) && (key_mapping->second == CONSOLE)) {
     if (event.type != SDL_KEYDOWN) return;
   // if console key was pressed: toggle console
   if ((key_mapping != keymap.end()) && (key_mapping->second == CONSOLE)) {
     if (event.type != SDL_KEYDOWN) return;
-    Console::toggle();
+    Console::instance->toggle();
     return;
   }
 
   // if console is open: send key there
     return;
   }
 
   // if console is open: send key there
-  if (Console::hasFocus()) {
+  if (Console::instance->hasFocus()) {
     process_console_key_event(event);
     return;
   } 
     process_console_key_event(event);
     return;
   } 
@@ -375,27 +375,27 @@ JoystickKeyboardController::process_console_key_event(const SDL_Event& event)
 
   switch (event.key.keysym.sym) {
     case SDLK_RETURN:
 
   switch (event.key.keysym.sym) {
     case SDLK_RETURN:
-      Console::input << std::endl;
+      Console::instance->input << std::endl;
       break;
     case SDLK_BACKSPACE:
       break;
     case SDLK_BACKSPACE:
-      Console::backspace();
+      Console::instance->backspace();
       break;
     case SDLK_TAB:
       break;
     case SDLK_TAB:
-      Console::autocomplete();
+      Console::instance->autocomplete();
       break;
     case SDLK_PAGEUP:
       break;
     case SDLK_PAGEUP:
-      Console::scroll(-1);
+      Console::instance->scroll(-1);
       break;
     case SDLK_PAGEDOWN:
       break;
     case SDLK_PAGEDOWN:
-      Console::scroll(+1);
+      Console::instance->scroll(+1);
       break;
     case SDLK_END:
       break;
     case SDLK_END:
-      Console::scroll(+65535);
+      Console::instance->scroll(+65535);
       break;
     default:
       int c = event.key.keysym.unicode;
       if ((c >= 32) && (c <= 126)) {
       break;
     default:
       int c = event.key.keysym.unicode;
       if ((c >= 32) && (c <= 126)) {
-       Console::input << (char)c;
+       Console::instance->input << (char)c;
       }
       break;
   }
       }
       break;
   }
index 2d21d67..072e233 100644 (file)
@@ -111,10 +111,10 @@ GameSession::GameSession(const std::string& levelfile_, GameSessionMode mode,
   fps_fps = 0;
 
   for (uint16_t i=0; i < sizeof(::consoleCommands)/sizeof(typeof(consoleCommands[0])); i++) {
   fps_fps = 0;
 
   for (uint16_t i=0; i < sizeof(::consoleCommands)/sizeof(typeof(consoleCommands[0])); i++) {
-    Console::registerCommand(consoleCommands[i], this);
+    Console::instance->registerCommand(consoleCommands[i], this);
   }
 
   }
 
-  statistics_backdrop = new Surface("images/engine/menu/score-backdrop.png");
+  statistics_backdrop.reset(new Surface("images/engine/menu/score-backdrop.png"));
 
   restart_level(true);
 }
 
   restart_level(true);
 }
@@ -127,10 +127,9 @@ GameSession::restart_level(bool fromBeginning)
 
   main_controller->reset();
 
 
   main_controller->reset();
 
-  delete level;
   currentsector = 0;
 
   currentsector = 0;
 
-  level = new Level;
+  level.reset(new Level);
   level->load(levelfile);
 
   global_stats.reset();
   level->load(levelfile);
 
   global_stats.reset();
@@ -187,9 +186,6 @@ GameSession::~GameSession()
   delete demo_controller;
 
   delete end_sequence_controller;
   delete demo_controller;
 
   delete end_sequence_controller;
-  delete level;
-
-  delete statistics_backdrop;
 
   current_ = NULL;
 }
 
   current_ = NULL;
 }
@@ -802,7 +798,7 @@ GameSession::drawstatus(DrawingContext& context)
 
   // draw level stats while end_sequence is running
   if (end_sequence) {
 
   // draw level stats while end_sequence is running
   if (end_sequence) {
-    global_stats.draw_endseq_panel(context, best_level_statistics, statistics_backdrop);
+    global_stats.draw_endseq_panel(context, best_level_statistics, statistics_backdrop.get());
   }
 }
 
   }
 }
 
index 6b72450..69e93f6 100644 (file)
@@ -87,7 +87,7 @@ public:
   { return currentsector; }
 
   Level* get_current_level()
   { return currentsector; }
 
   Level* get_current_level()
-  { return level; }
+  { return level.get(); }
 
   void start_sequence(const std::string& sequencename);
 
 
   void start_sequence(const std::string& sequencename);
 
@@ -113,8 +113,8 @@ private:
   void process_menu();
 
   Timer endsequence_timer;
   void process_menu();
 
   Timer endsequence_timer;
-  Level* level;
-  Surface* statistics_backdrop; // FIXME: where to put this?
+  std::auto_ptr<Level> level;
+  std::auto_ptr<Surface> statistics_backdrop;
 
   Sector* currentsector;
 
 
   Sector* currentsector;
 
@@ -154,7 +154,6 @@ private:
   std::string capture_file;
   std::istream* playback_demo_stream;
   CodeController* demo_controller;
   std::string capture_file;
   std::istream* playback_demo_stream;
   CodeController* demo_controller;
-  Console* console;
 };
 
 #endif /*SUPERTUX_GAMELOOP_H*/
 };
 
 #endif /*SUPERTUX_GAMELOOP_H*/
index 7536cab..969e602 100644 (file)
@@ -256,6 +256,8 @@ static void init_sdl()
     msg << "Couldn't initialize SDL: " << SDL_GetError();
     throw std::runtime_error(msg.str());
   }
     msg << "Couldn't initialize SDL: " << SDL_GetError();
     throw std::runtime_error(msg.str());
   }
+  // just to be sure
+  atexit(SDL_Quit);
 
   SDL_EnableUNICODE(1);
 
 
   SDL_EnableUNICODE(1);
 
@@ -459,6 +461,8 @@ static inline void timelog(const char* )
 
 int main(int argc, char** argv) 
 {
 
 int main(int argc, char** argv) 
 {
+  int result = 0;
+    
   try {
     srand(time(0));
     init_physfs(argv[0]);
   try {
     srand(time(0));
     init_physfs(argv[0]);
@@ -476,6 +480,7 @@ int main(int argc, char** argv)
     init_audio();
     timelog("video");
     init_video();
     init_audio();
     timelog("video");
     init_video();
+    Console::instance = new Console();
     timelog("scripting");
     init_scripting();
 
     timelog("scripting");
     init_scripting();
 
@@ -504,17 +509,17 @@ int main(int argc, char** argv)
     }
 
     main_loop->run();
     }
 
     main_loop->run();
-
-    delete main_loop;
-    main_loop = NULL;
   } catch(std::exception& e) {
     msg_fatal << "Unexpected exception: " << e.what() << std::endl;
   } catch(std::exception& e) {
     msg_fatal << "Unexpected exception: " << e.what() << std::endl;
-    return 1;
+    result = 1;
   } catch(...) {
     msg_fatal << "Unexpected exception" << std::endl;
   } catch(...) {
     msg_fatal << "Unexpected exception" << std::endl;
-    return 1;
+    result = 1;
   }
 
   }
 
+  delete main_loop;
+  main_loop = NULL;
+
   free_menu();
   delete ScriptManager::instance;
   ScriptManager::instance = NULL;
   free_menu();
   delete ScriptManager::instance;
   ScriptManager::instance = NULL;
@@ -527,10 +532,12 @@ int main(int argc, char** argv)
   config = NULL;
   delete main_controller;
   main_controller = NULL;
   config = NULL;
   delete main_controller;
   main_controller = NULL;
+  delete Console::instance;
+  Console::instance = NULL;
   delete texture_manager;
   texture_manager = NULL;
   SDL_Quit();
   PHYSFS_deinit();
   
   delete texture_manager;
   texture_manager = NULL;
   SDL_Quit();
   PHYSFS_deinit();
   
-  return 0;
+  return result;
 }
 }
index 575005b..6c21a3a 100644 (file)
@@ -43,7 +43,6 @@ MainLoop* main_loop = NULL;
 MainLoop::MainLoop()
   : speed(1.0)
 {
 MainLoop::MainLoop()
   : speed(1.0)
 {
-  console.reset(new Console());
 }
 
 MainLoop::~MainLoop()
 }
 
 MainLoop::~MainLoop()
@@ -142,7 +141,7 @@ MainLoop::run()
       current_screen->draw(context);
       if(Menu::current() != NULL)
           Menu::current()->draw(context);
       current_screen->draw(context);
       if(Menu::current() != NULL)
           Menu::current()->draw(context);
-      console->draw(context);
+      Console::instance->draw(context);
 
       context.do_drawing();
 
 
       context.do_drawing();
 
@@ -165,6 +164,7 @@ MainLoop::run()
     game_time += elapsed_time;
     ScriptManager::instance->update();
     current_screen->update(elapsed_time);
     game_time += elapsed_time;
     ScriptManager::instance->update();
     current_screen->update(elapsed_time);
+    Console::instance->update(elapsed_time);
  
     main_controller->update();
     SDL_Event event;
  
     main_controller->update();
     SDL_Event event;
index 02a44e9..6c9d97b 100644 (file)
@@ -55,7 +55,7 @@ PlayerStatus::PlayerStatus()
   
   tux_life.reset(sprite_manager->create("images/creatures/tux_small/tux-life.sprite"));
 
   
   tux_life.reset(sprite_manager->create("images/creatures/tux_small/tux-life.sprite"));
 
-  Console::registerCommand("coins", this);
+  Console::instance->registerCommand("coins", this);
 }
 
 PlayerStatus::~PlayerStatus()
 }
 
 PlayerStatus::~PlayerStatus()
index d0c4a95..e392270 100644 (file)
@@ -473,6 +473,7 @@ Sector::activate(const Vector& player_pos)
 
   player->move(player_pos);
   camera->reset(player->get_pos());
 
   player->move(player_pos);
   camera->reset(player->get_pos());
+  update_game_objects();
 
   // Run init script
   if(init_script != "") {
 
   // Run init script
   if(init_script != "") {
@@ -675,9 +676,14 @@ Sector::try_unexpose(GameObject* object)
   ScriptInterface* interface = dynamic_cast<ScriptInterface*> (object);
   if(interface != NULL) {
     HSQUIRRELVM vm = script_manager->get_vm();
   ScriptInterface* interface = dynamic_cast<ScriptInterface*> (object);
   if(interface != NULL) {
     HSQUIRRELVM vm = script_manager->get_vm();
+    int oldtop = sq_gettop(vm);
     sq_pushobject(vm, sector_table);
     sq_pushobject(vm, sector_table);
-    interface->unexpose(vm, -1);
-    sq_pop(vm, 1);
+    try {
+      interface->unexpose(vm, -1);
+    } catch(std::exception& e) {
+      msg_warning << "Couldn't unregister object: " << e.what() << std::endl;
+    }
+    sq_settop(vm, oldtop);
   }
 } 
 
   }
 } 
 
index 187b6f0..7dca581 100644 (file)
@@ -430,11 +430,14 @@ TitleScreen::process_load_game_menu()
   stream << "save/" << worlddirname << "_" << slot << ".stsg";
   std::string slotfile = stream.str();
 
   stream << "save/" << worlddirname << "_" << slot << ".stsg";
   std::string slotfile = stream.str();
 
-  sound_manager->stop_music();
   fadeout(256);
 
   fadeout(256);
 
-  current_world->set_savegame_filename(slotfile);
-  current_world->run();
+  try {
+    current_world->set_savegame_filename(slotfile);
+    current_world->run();
+  } catch(std::exception& e) {
+    msg_fatal << "Couldn't start world: " << e.what() << std::endl;
+  }
 
   return true;
 }
 
   return true;
 }
index 85f3d9c..1c66ab4 100644 (file)
@@ -61,6 +61,22 @@ void
 World::set_savegame_filename(const std::string& filename)
 {
   this->savegame_filename = filename;
 World::set_savegame_filename(const std::string& filename)
 {
   this->savegame_filename = filename;
+  // make sure the savegame directory exists
+  std::string dirname = FileSystem::dirname(filename);
+  if(!PHYSFS_exists(dirname.c_str())) {
+      if(PHYSFS_mkdir(dirname.c_str())) {
+          std::ostringstream msg;
+          msg << "Couldn't create directory for savegames '"
+              << dirname << "': " <<PHYSFS_getLastError();
+          throw std::runtime_error(msg.str());
+      }
+  }
+  if(!PHYSFS_isDirectory(dirname.c_str())) {
+      std::ostringstream msg;
+      msg << "Savegame path '" << dirname << "' is not a directory";
+      throw std::runtime_error(msg.str());
+  }
 }
 
 void
 }
 
 void