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);
}
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);
}
}
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();
bbox.set_size(32, 32);
sprite = sprite_manager->create("images/creatures/flame/flame.sprite");
countMe = false;
+ layer = LAYER_FLOATINGOBJECTS;
}
Flame::~Flame()
bbox.set_size(32, 32);
sprite = sprite_manager->create("images/creatures/willowisp/willowisp.sprite");
countMe = false;
+ layer = LAYER_FLOATINGOBJECTS;
}
WillOWisp::~WillOWisp()
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();
}
void
FallingCoin::draw(DrawingContext& context)
{
- sprite->draw(context, pos, LAYER_OBJECTS + 5);
+ sprite->draw(context, pos, LAYER_FLOATINGOBJECTS + 5);
}
void
void
OneUp::draw(DrawingContext& context)
{
- sprite->draw(context, get_pos(), LAYER_OBJECTS);
+ sprite->draw(context, get_pos(), LAYER_FLOATINGOBJECTS);
}
HitResponse
/* 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() *
{
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);
LAYER_BACKGROUNDTILES = -100,
LAYER_OBJECTS = -50,
LAYER_TILES = 0,
+ LAYER_FLOATINGOBJECTS = 50,
LAYER_FOREGROUNDTILES = 200,
LAYER_FOREGROUND0 = 300,
LAYER_FOREGROUND1 = 400,