Moved some sprites from LAYER_OBJECTS to LAYER_FLOATINGOBJECTS
authorChristoph Sommer <mail@christoph-sommer.de>
Tue, 25 Apr 2006 00:37:11 +0000 (00:37 +0000)
committerChristoph Sommer <mail@christoph-sommer.de>
Tue, 25 Apr 2006 00:37:11 +0000 (00:37 +0000)
SVN-Revision: 3424

src/badguy/badguy.cpp
src/badguy/badguy.hpp
src/badguy/flame.cpp
src/badguy/willowisp.cpp
src/object/falling_coin.cpp
src/object/oneup.cpp
src/object/player.cpp
src/object/powerup.cpp
src/video/drawing_context.hpp

index 22f7934..ee2e347 100644 (file)
@@ -33,8 +33,7 @@ static const float X_OFFSCREEN_DISTANCE = 1600;
 static const float Y_OFFSCREEN_DISTANCE = 1200;
 
 BadGuy::BadGuy()
-  : countMe(true), sprite(0), dir(LEFT), state(STATE_INIT)
-{
+  : countMe(true), sprite(0), dir(LEFT), layer(LAYER_OBJECTS), state(STATE_INIT) {
   set_group(COLGROUP_DISABLED);
 }
 
@@ -53,10 +52,10 @@ BadGuy::draw(DrawingContext& context)
   if(state == STATE_FALLING) {
     DrawingEffect old_effect = context.get_drawing_effect();
     context.set_drawing_effect((DrawingEffect) (old_effect | VERTICAL_FLIP));
-    sprite->draw(context, get_pos(), LAYER_OBJECTS);
+    sprite->draw(context, get_pos(), layer);
     context.set_drawing_effect(old_effect);
   } else {
-    sprite->draw(context, get_pos(), LAYER_OBJECTS);
+    sprite->draw(context, get_pos(), layer);
   }
 }
 
index eb0d0cc..8cbfb18 100644 (file)
@@ -154,6 +154,13 @@ protected:
   Vector start_position;
 
   Direction dir;
+
+  /**
+   * z-position at which to draw the sprite.
+   * e.g. LAYER_OBJECTS, LAYER_OBJECTS - 1, LAYER_FLOATINGOBJECTS
+   */
+  int layer;
+
 private:
   void try_activate();
   
index d9a4fa9..7807e98 100644 (file)
@@ -34,6 +34,7 @@ Flame::Flame(const lisp::Lisp& reader)
   bbox.set_size(32, 32);  
   sprite = sprite_manager->create("images/creatures/flame/flame.sprite");
   countMe = false;
+  layer = LAYER_FLOATINGOBJECTS;
 }
 
 Flame::~Flame()
index a6e4e5c..bc15ac6 100644 (file)
@@ -38,6 +38,7 @@ WillOWisp::WillOWisp(const lisp::Lisp& reader)
   bbox.set_size(32, 32);  
   sprite = sprite_manager->create("images/creatures/willowisp/willowisp.sprite");
   countMe = false;
+  layer = LAYER_FLOATINGOBJECTS;
 }
 
 WillOWisp::~WillOWisp()
@@ -61,12 +62,12 @@ WillOWisp::write(lisp::Writer& writer)
 void
 WillOWisp::draw(DrawingContext& context)
 {
-  sprite->draw(context, get_pos(), LAYER_OBJECTS);
+  sprite->draw(context, get_pos(), layer);
   
   context.push_target();
   context.set_target(DrawingContext::LIGHTMAP);
 
-  sprite->draw(context, get_pos(), LAYER_OBJECTS);
+  sprite->draw(context, get_pos(), layer);
   
   context.pop_target();
 }
index e6f79a4..b1365b6 100644 (file)
@@ -41,7 +41,7 @@ FallingCoin::~FallingCoin()
 void
 FallingCoin::draw(DrawingContext& context)
 {
-  sprite->draw(context, pos, LAYER_OBJECTS + 5);
+  sprite->draw(context, pos, LAYER_FLOATINGOBJECTS + 5);
 }
 
 void
index d129653..1d23ae6 100644 (file)
@@ -53,7 +53,7 @@ OneUp::update(float elapsed_time)
 void
 OneUp::draw(DrawingContext& context)
 {
-  sprite->draw(context, get_pos(), LAYER_OBJECTS);
+  sprite->draw(context, get_pos(), LAYER_FLOATINGOBJECTS);
 }
 
 HitResponse
index 35f874e..f7c5605 100644 (file)
@@ -719,7 +719,7 @@ Player::draw(DrawingContext& context)
 
   /* Draw Tux */
   if(dying) {
-    smalltux_gameover->draw(context, get_pos(), layer);
+    smalltux_gameover->draw(context, get_pos(), LAYER_FLOATINGOBJECTS + 1);
   } else if(growing_timer.get_timeleft() > 0) {
       if (dir == RIGHT) {
         context.draw_surface(growingtux_right[int((growing_timer.get_timegone() *
index 5551e07..09d4d58 100644 (file)
@@ -33,7 +33,7 @@ PowerUp::PowerUp(const lisp::Lisp& lisp)
 {
   lisp.get("x", bbox.p1.x);
   lisp.get("y", bbox.p1.y);
-  lisp.get("sprite", sprite_name);
+  if (!lisp.get("sprite", sprite_name)) throw std::runtime_error("no sprite file set for powerup");
   lisp.get("script", script);
   no_physics = false;
   lisp.get("disable-physics", no_physics);
index ec240cb..a94ada0 100644 (file)
@@ -45,6 +45,7 @@ enum {
   LAYER_BACKGROUNDTILES = -100,
   LAYER_OBJECTS = -50,
   LAYER_TILES = 0,
+  LAYER_FLOATINGOBJECTS = 50,
   LAYER_FOREGROUNDTILES = 200,
   LAYER_FOREGROUND0 = 300,
   LAYER_FOREGROUND1 = 400,