From e50498b0a812cc8af84b0146ed917bb332471e8b Mon Sep 17 00:00:00 2001 From: Christoph Sommer Date: Tue, 25 Apr 2006 00:37:11 +0000 Subject: [PATCH] Moved some sprites from LAYER_OBJECTS to LAYER_FLOATINGOBJECTS SVN-Revision: 3424 --- src/badguy/badguy.cpp | 7 +++---- src/badguy/badguy.hpp | 7 +++++++ src/badguy/flame.cpp | 1 + src/badguy/willowisp.cpp | 5 +++-- src/object/falling_coin.cpp | 2 +- src/object/oneup.cpp | 2 +- src/object/player.cpp | 2 +- src/object/powerup.cpp | 2 +- src/video/drawing_context.hpp | 1 + 9 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/badguy/badguy.cpp b/src/badguy/badguy.cpp index 22f79349f..ee2e347e4 100644 --- a/src/badguy/badguy.cpp +++ b/src/badguy/badguy.cpp @@ -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); } } diff --git a/src/badguy/badguy.hpp b/src/badguy/badguy.hpp index eb0d0ccb1..8cbfb183a 100644 --- a/src/badguy/badguy.hpp +++ b/src/badguy/badguy.hpp @@ -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(); diff --git a/src/badguy/flame.cpp b/src/badguy/flame.cpp index d9a4fa9be..7807e98bd 100644 --- a/src/badguy/flame.cpp +++ b/src/badguy/flame.cpp @@ -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() diff --git a/src/badguy/willowisp.cpp b/src/badguy/willowisp.cpp index a6e4e5cf1..bc15ac6f3 100644 --- a/src/badguy/willowisp.cpp +++ b/src/badguy/willowisp.cpp @@ -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(); } diff --git a/src/object/falling_coin.cpp b/src/object/falling_coin.cpp index e6f79a458..b1365b61c 100644 --- a/src/object/falling_coin.cpp +++ b/src/object/falling_coin.cpp @@ -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 diff --git a/src/object/oneup.cpp b/src/object/oneup.cpp index d12965356..1d23ae686 100644 --- a/src/object/oneup.cpp +++ b/src/object/oneup.cpp @@ -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 diff --git a/src/object/player.cpp b/src/object/player.cpp index 35f874e83..f7c56054a 100644 --- a/src/object/player.cpp +++ b/src/object/player.cpp @@ -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() * diff --git a/src/object/powerup.cpp b/src/object/powerup.cpp index 5551e07c7..09d4d5804 100644 --- a/src/object/powerup.cpp +++ b/src/object/powerup.cpp @@ -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); diff --git a/src/video/drawing_context.hpp b/src/video/drawing_context.hpp index ec240cbf8..a94ada0aa 100644 --- a/src/video/drawing_context.hpp +++ b/src/video/drawing_context.hpp @@ -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, -- 2.11.0