From c3f9468882de1fd44f41ccfa7dae6d776bf306a7 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Mon, 16 Jan 2006 15:38:25 +0000 Subject: [PATCH] a few fixes that I had lying around here, select walk animation in worldmap when tux is walking, fix bad tile attributes in a worldmap tile SVN-Revision: 3001 --- data/images/sprites.strf | 16 ---------------- data/images/worldmap.strf | 17 +++++++++-------- data/images/worldmap/common/tux.sprite | 27 +++++++++++++++++++++------ src/badguy/bomb.cpp | 17 ++++++++++------- src/badguy/bomb.hpp | 7 ++++++- src/object/player.cpp | 24 ++++++++++-------------- src/object/scripted_object.cpp | 6 ++++-- src/object/scripted_object.hpp | 1 + src/worldmap.cpp | 8 ++++---- 9 files changed, 65 insertions(+), 58 deletions(-) diff --git a/data/images/sprites.strf b/data/images/sprites.strf index 343b99f9f..f10bb23de 100644 --- a/data/images/sprites.strf +++ b/data/images/sprites.strf @@ -1012,22 +1012,6 @@ "powerups/ice_flower/ice_flower-1.png" "powerups/ice_flower/ice_flower-2.png"))) - (sprite (name "firebullet") - (action - (x-offset 12) - (x-offset 12) - (fps 20) - (images "objects/bullets/fire_bullet-0.png" - "objects/bullets/fire_bullet-1.png" - "objects/bullets/fire_bullet-2.png" - "objects/bullets/fire_bullet-3.png"))) - (sprite (name "icebullet") - (action - (x-offset 12) - (x-offset 12) - (fps 20) - (images "objects/bullets/ice_bullet.png"))) - ;; Game Objects follow ; Flying platform diff --git a/data/images/worldmap.strf b/data/images/worldmap.strf index 952880d31..1301f1865 100644 --- a/data/images/worldmap.strf +++ b/data/images/worldmap.strf @@ -3051,14 +3051,15 @@ (stop #t) ) (tile - (id 719) - (images - (region "worldmap/forest/ghostwood.png" 32 64 32 32) - ) (north #t) - (south #f) - (east #f) - (west #t) - (stop #t) + (id 719) + (images + (region "worldmap/forest/ghostwood.png" 32 64 32 32) + ) + (north #t) + (south #f) + (east #f) + (west #t) + (stop #f) ) (tile (id 720) diff --git a/data/images/worldmap/common/tux.sprite b/data/images/worldmap/common/tux.sprite index d863e234b..f5160a5e6 100644 --- a/data/images/worldmap/common/tux.sprite +++ b/data/images/worldmap/common/tux.sprite @@ -1,8 +1,14 @@ (supertux-sprite (action - (name "small") + (name "small-stop") + (x-offset 5) + (y-offset 20) + (images "smalltux.png") + ) + (action + (name "small-walking") + (x-offset 5) (y-offset 20) - (x-offset 5) (images "smalltux.png" "smalltux.png" "smalltux.png" @@ -37,18 +43,27 @@ "smalltux1.png" "smalltux.png" "smalltux.png" - - ) ) (action - (name "large") + (name "large-walking") + (y-offset 10) + (images "tux.png") + ) + (action + (name "large-stop") (y-offset 10) (images "tux.png") ) (action - (name "fire") + (name "fire-walking") + (y-offset 10) + (images "firetux.png") + ) + (action + (name "fire-stop") (y-offset 10) (images "firetux.png") ) ) + diff --git a/src/badguy/bomb.cpp b/src/badguy/bomb.cpp index 741d161d1..45fb89280 100644 --- a/src/badguy/bomb.cpp +++ b/src/badguy/bomb.cpp @@ -30,11 +30,13 @@ Bomb::Bomb(const Vector& pos, Direction dir) bbox.set_pos(pos); bbox.set_size(31.8, 31.8); sprite = sprite_manager->create("images/creatures/mr_bomb/bomb.sprite"); - state = 0; + state = STATE_TICKING; timer.start(TICKINGTIME); this->dir = dir; sprite->set_action(dir == LEFT ? "ticking-left" : "ticking-right"); countMe = false; + + set_group(COLGROUP_TOUCHABLE); } void @@ -55,7 +57,7 @@ Bomb::collision_solid(GameObject& , const CollisionHit& hit) HitResponse Bomb::collision_player(Player& player, const CollisionHit& ) { - if(state == 1) { + if(state == STATE_EXPLODING) { player.kill(Player::SHRINK); } return ABORT_MOVE; @@ -64,7 +66,7 @@ Bomb::collision_player(Player& player, const CollisionHit& ) HitResponse Bomb::collision_badguy(BadGuy& badguy, const CollisionHit& ) { - if(state == 1) + if(state == STATE_EXPLODING) badguy.kill_fall(); return ABORT_MOVE; } @@ -73,12 +75,12 @@ void Bomb::active_update(float ) { switch(state) { - case 0: + case STATE_TICKING: if(timer.check()) { explode(); } break; - case 1: + case STATE_EXPLODING: if(timer.check()) { remove_me(); } @@ -89,7 +91,8 @@ Bomb::active_update(float ) void Bomb::explode() { - state = 1; + state = STATE_EXPLODING; + set_group(COLGROUP_TOUCHABLE); sprite->set_action("explosion"); sound_manager->play("sounds/explosion.wav", get_pos()); timer.start(EXPLOSIONTIME); @@ -98,7 +101,7 @@ Bomb::explode() void Bomb::kill_fall() { - if (state != 1) // we don't want it exploding again + if (state != STATE_EXPLODING) // we don't want it exploding again explode(); } diff --git a/src/badguy/bomb.hpp b/src/badguy/bomb.hpp index bc64ac54d..eb74a626d 100644 --- a/src/badguy/bomb.hpp +++ b/src/badguy/bomb.hpp @@ -37,7 +37,12 @@ public: void explode(); private: - int state; + enum State { + STATE_TICKING, + STATE_EXPLODING + }; + + State state; Timer timer; }; diff --git a/src/object/player.cpp b/src/object/player.cpp index 002c422fd..1748059fc 100644 --- a/src/object/player.cpp +++ b/src/object/player.cpp @@ -715,10 +715,16 @@ Player::collision(GameObject& other, const CollisionHit& hit) return CONTINUE; } - TriggerBase* trigger = dynamic_cast (&other); - if(trigger) { - if(controller->pressed(Controller::UP)) - trigger->event(*this, TriggerBase::EVENT_ACTIVATE); +#ifdef DEBUG + assert(dynamic_cast (&other) != NULL); +#endif + MovingObject* moving_object = static_cast (&other); + if(moving_object->get_group() == COLGROUP_TOUCHABLE) { + TriggerBase* trigger = dynamic_cast (&other); + if(trigger) { + if(controller->pressed(Controller::UP)) + trigger->event(*this, TriggerBase::EVENT_ACTIVATE); + } return FORCE_MOVE; } @@ -727,16 +733,6 @@ Player::collision(GameObject& other, const CollisionHit& hit) if(badguy != NULL) return CONTINUE; -#if 0 - MovingObject* moving_object = static_cast (&other); - if(moving_object->get_group() == COLGROUP_TOUCHABLE) - return FORCE_MOVE; - - if(is_invincible()) - return FORCE_MOVE; - - return CONTINUE; -#endif return FORCE_MOVE; } diff --git a/src/object/scripted_object.cpp b/src/object/scripted_object.cpp index 6293881a3..9cb154b11 100644 --- a/src/object/scripted_object.cpp +++ b/src/object/scripted_object.cpp @@ -10,7 +10,8 @@ #include "math/vector.hpp" ScriptedObject::ScriptedObject(const lisp::Lisp& lisp) - : solid(true), physic_enabled(true), visible(true), new_vel_set(false) + : solid(true), physic_enabled(true), visible(true), new_vel_set(false), + layer(LAYER_OBJECTS) { lisp.get("name", name); if(name == "") @@ -33,6 +34,7 @@ ScriptedObject::ScriptedObject(const lisp::Lisp& lisp) lisp.get("solid", solid); lisp.get("physic-enabled", physic_enabled); lisp.get("visible", visible); + lisp.get("layer", layer); if(solid) flags |= FLAG_SOLID; } @@ -134,7 +136,7 @@ ScriptedObject::draw(DrawingContext& context) if(!visible) return; - sprite->draw(context, get_pos(), LAYER_OBJECTS); + sprite->draw(context, get_pos(), layer); } HitResponse diff --git a/src/object/scripted_object.hpp b/src/object/scripted_object.hpp index 507466ad4..5a285a51d 100644 --- a/src/object/scripted_object.hpp +++ b/src/object/scripted_object.hpp @@ -41,6 +41,7 @@ private: bool physic_enabled; bool visible; bool new_vel_set; + int layer; Vector new_vel; Physic physic; Sprite* sprite; diff --git a/src/worldmap.cpp b/src/worldmap.cpp index c4a508230..3d6b6f96c 100644 --- a/src/worldmap.cpp +++ b/src/worldmap.cpp @@ -136,19 +136,19 @@ Tux::draw(DrawingContext& context) { switch (player_status->bonus) { case GROWUP_BONUS: - tux_sprite->set_action("large"); + tux_sprite->set_action(moving ? "large-walking" : "large-stop"); break; case FIRE_BONUS: - tux_sprite->set_action("fire"); + tux_sprite->set_action(moving ? "fire-walking" : "fire-stop"); break; case NO_BONUS: - tux_sprite->set_action("small"); + tux_sprite->set_action(moving ? "small-walking" : "small-stop"); break; default: #ifdef DEBUG std::cerr << "Bonus type not handled in worldmap.\n"; #endif - tux_sprite->set_action("large"); + tux_sprite->set_action("large-stop"); break; } -- 2.11.0