Worldmap now supports an additional level sprite action that indicates completion...
authorLMH <lmh.0013@gmail.com>
Tue, 3 Sep 2013 03:01:16 +0000 (17:01 -1000)
committerLMH <lmh.0013@gmail.com>
Tue, 3 Sep 2013 03:01:16 +0000 (17:01 -1000)
A potential future improvement to this mechanism would be adding an optional "target_time" to levels which needs to be reached before the level is marked as "perfect".

Note that this change will cause a one-time reset of all level stats- sorry.

15 files changed:
WHATSNEW.txt
data/images/worldmap/common/bonusdot.sprite
data/images/worldmap/common/hiddendot.sprite
data/images/worldmap/common/leveldot.sprite
data/images/worldmap/common/leveldot_green_perfect-0.png [new file with mode: 0644]
data/images/worldmap/common/leveldot_green_perfect-1.png [new file with mode: 0644]
data/images/worldmap/common/leveldot_green_perfect-2.png [new file with mode: 0644]
data/images/worldmap/common/leveldot_green_perfect-3.png [new file with mode: 0644]
data/images/worldmap/common/shroom.sprite
src/supertux/statistics.cpp
src/supertux/statistics.hpp
src/worldmap/level.cpp
src/worldmap/level.hpp
src/worldmap/tux.cpp
src/worldmap/worldmap.cpp

index fb01b86..26dee86 100644 (file)
@@ -5,6 +5,7 @@ Tracking major changes in-situ:
 glow effects
 new badguys: iceflame, ghostflame, livefire, goldbomb, smartblock
 new bonuses: coinrain, coinexplode
+statistics improved
 
 Supertux Release 0.3.4 (2013-07)
 --------------------------------
index 9183d5b..1bb24a4 100644 (file)
     (hitbox 16 16 0 0)
     (images "leveldot_green.png")
   )
+  (action
+    (name "perfect")
+    (hitbox 16 16 0 0)
+    (images "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green_perfect-0.png"
+      "leveldot_green_perfect-1.png"
+      "leveldot_green_perfect-2.png"
+      "leveldot_green_perfect-3.png"
+      "leveldot_green_perfect-2.png"
+      "leveldot_green_perfect-1.png"
+      "leveldot_green_perfect-0.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png")
+  )
 )
index ee82890..8761039 100644 (file)
@@ -9,4 +9,33 @@
     (hitbox 16 16 0 0)
     (images "leveldot_green.png")
   )
+  (action
+    (name "perfect")
+    (hitbox 16 16 0 0)
+    (images "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green_perfect-0.png"
+      "leveldot_green_perfect-1.png"
+      "leveldot_green_perfect-2.png"
+      "leveldot_green_perfect-3.png"
+      "leveldot_green_perfect-2.png"
+      "leveldot_green_perfect-1.png"
+      "leveldot_green_perfect-0.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png")
+  )
 )
index afa203b..6d103cc 100644 (file)
@@ -9,4 +9,33 @@
     (hitbox 16 16 0 0)
     (images "leveldot_green.png")
   )
+  (action
+    (name "perfect")
+    (hitbox 16 16 0 0)
+    (images "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green_perfect-0.png"
+      "leveldot_green_perfect-1.png"
+      "leveldot_green_perfect-2.png"
+      "leveldot_green_perfect-3.png"
+      "leveldot_green_perfect-2.png"
+      "leveldot_green_perfect-1.png"
+      "leveldot_green_perfect-0.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png"
+      "leveldot_green.png")
+  )
 )
diff --git a/data/images/worldmap/common/leveldot_green_perfect-0.png b/data/images/worldmap/common/leveldot_green_perfect-0.png
new file mode 100644 (file)
index 0000000..b4a7a30
Binary files /dev/null and b/data/images/worldmap/common/leveldot_green_perfect-0.png differ
diff --git a/data/images/worldmap/common/leveldot_green_perfect-1.png b/data/images/worldmap/common/leveldot_green_perfect-1.png
new file mode 100644 (file)
index 0000000..825374a
Binary files /dev/null and b/data/images/worldmap/common/leveldot_green_perfect-1.png differ
diff --git a/data/images/worldmap/common/leveldot_green_perfect-2.png b/data/images/worldmap/common/leveldot_green_perfect-2.png
new file mode 100644 (file)
index 0000000..313ec87
Binary files /dev/null and b/data/images/worldmap/common/leveldot_green_perfect-2.png differ
diff --git a/data/images/worldmap/common/leveldot_green_perfect-3.png b/data/images/worldmap/common/leveldot_green_perfect-3.png
new file mode 100644 (file)
index 0000000..dd5eb84
Binary files /dev/null and b/data/images/worldmap/common/leveldot_green_perfect-3.png differ
index 5ed151b..e432a29 100644 (file)
   (action
     (name "solved")
     (hitbox 16 16 0 0)
+    (images "level_star.png")
+  )
+  (action
+    (name "perfect")
+    (hitbox 16 16 0 0)
     (images "level_star.png"
 "level_star1.png"
 "level_star1.png"
index c749bd6..95ad4ed 100644 (file)
@@ -258,6 +258,14 @@ Statistics::operator+=(const Statistics& s2)
   if (s2.total_secrets != nv_secrets) total_secrets += s2.total_secrets;
 }
 
+bool
+Statistics::completed(const Statistics& stats)
+{
+  return (stats.coins == stats.total_coins && 
+      stats.badguys == stats.total_badguys && 
+      stats.secrets == stats.total_secrets);
+}
+
 void
 Statistics::declare_invalid()
 {
index 5de05c8..880cd47 100644 (file)
@@ -48,11 +48,6 @@ public:
   Statistics(); /**< Creates new statistics, call reset() before counting */
   ~Statistics();
 
-  /// read statistics from lisp file
-  //void parse(const Reader& lisp);
-  /// write statistics to lisp file
-  //void write(Writer& writer);
-
   /**
    * serialize statistics object as squirrel table "statistics"
    */
@@ -70,6 +65,7 @@ public:
   void reset(); /**< Set stats (but not totals) to zero */
   void merge(const Statistics& stats); /**< Given another Statistics object finds the best of each one */
   void operator+=(const Statistics& o); /**< Add two Statistics objects */
+  bool completed(const Statistics& stats); /* Check if stats match total stats */
 
   void declare_invalid(); /**< marks statistics as invalid for their entire lifetime (e.g. after cheating). Invalid statistics will not be merged or drawn. */
   
index 1f3ec1a..569f31f 100644 (file)
@@ -33,6 +33,7 @@ LevelTile::LevelTile(const std::string& basedir, const Reader& lisp) :
   pos(),
   title(),
   solved(false), 
+  perfect(false),
   auto_play(false), 
   sprite(),
   statistics(),
index 54b62e6..8730d29 100644 (file)
@@ -43,6 +43,7 @@ public:
   Vector pos;
   std::string title;
   bool solved;
+  bool perfect;
   bool auto_play; /**< true if Tux should automatically enter this level if it's unfinished */
 
   SpritePtr sprite;
index 41a28f0..1e6ba7b 100644 (file)
@@ -147,7 +147,7 @@ Tux::tryStartWalking()
 
   // We got a new direction, so lets start walking when possible
   Vector next_tile;
-  if ((!level || level->solved)
+  if ((!level || level->solved || level->perfect)
       && worldmap->path_ok(input_direction, tile_pos, &next_tile)) {
     tile_pos = next_tile;
     moving = true;
index dc57331..3d608d5 100644 (file)
@@ -461,6 +461,10 @@ WorldMap::finished_level(Level* gamelevel)
   // deal with statistics
   level->statistics.merge(gamelevel->stats);
   calculate_total_stats();
+  if(level->statistics.completed(level->statistics)) {
+    level->perfect = true;
+    level->sprite->set_action("perfect");
+  }
 
   save_state();
 
@@ -987,6 +991,7 @@ WorldMap::save_state()
       sq_newtable(vm);
 
       store_bool(vm, "solved", level->solved);
+      store_bool(vm, "perfect", level->perfect);
       level->statistics.serialize_to_squirrel(vm);
 
       sq_createslot(vm, -3);
@@ -1058,7 +1063,11 @@ WorldMap::load_state()
       sq_pushstring(vm, level->get_name().c_str(), -1);
       if(SQ_SUCCEEDED(sq_get(vm, -2))) {
         level->solved = read_bool(vm, "solved");
-        level->sprite->set_action(level->solved ? "solved" : "default");
+        level->perfect = read_bool(vm, "perfect");
+        if(!level->solved)
+          level->sprite->set_action("default");
+        else
+          level->sprite->set_action((level->sprite->has_action("perfect") && level->perfect) ? "perfect" : "solved");
         level->statistics.unserialize_from_squirrel(vm);
         sq_pop(vm, 1);
       }