a few fixes that I had lying around here, select walk animation in worldmap when...
authorMatthias Braun <matze@braunis.de>
Mon, 16 Jan 2006 15:38:25 +0000 (15:38 +0000)
committerMatthias Braun <matze@braunis.de>
Mon, 16 Jan 2006 15:38:25 +0000 (15:38 +0000)
SVN-Revision: 3001

data/images/sprites.strf
data/images/worldmap.strf
data/images/worldmap/common/tux.sprite
src/badguy/bomb.cpp
src/badguy/bomb.hpp
src/object/player.cpp
src/object/scripted_object.cpp
src/object/scripted_object.hpp
src/worldmap.cpp

index 343b99f..f10bb23 100644 (file)
                  "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
index 952880d..1301f18 100644 (file)
        (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)
index d863e23..f5160a5 100644 (file)
@@ -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"
 "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")
  )
 )
+
index 741d161..45fb892 100644 (file)
@@ -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();
 }
 
index bc64ac5..eb74a62 100644 (file)
@@ -37,7 +37,12 @@ public:
   void explode();
 
 private:
-  int state;
+  enum State {
+    STATE_TICKING,
+    STATE_EXPLODING
+  };
+  
+  State state;
   Timer timer;
 };
 
index 002c422..1748059 100644 (file)
@@ -715,10 +715,16 @@ Player::collision(GameObject& other, const CollisionHit& hit)
     return CONTINUE;
   }
 
-  TriggerBase* trigger = dynamic_cast<TriggerBase*> (&other);
-  if(trigger) {
-    if(controller->pressed(Controller::UP))
-      trigger->event(*this, TriggerBase::EVENT_ACTIVATE);
+#ifdef DEBUG
+  assert(dynamic_cast<MovingObject*> (&other) != NULL);
+#endif
+  MovingObject* moving_object = static_cast<MovingObject*> (&other); 
+  if(moving_object->get_group() == COLGROUP_TOUCHABLE) {
+    TriggerBase* trigger = dynamic_cast<TriggerBase*> (&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<MovingObject*> (&other);
-  if(moving_object->get_group() == COLGROUP_TOUCHABLE)
-    return FORCE_MOVE;
-
-  if(is_invincible())
-    return FORCE_MOVE;
-
-  return CONTINUE;
-#endif
   return FORCE_MOVE;
 }
 
index 6293881..9cb154b 100644 (file)
@@ -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
index 507466a..5a285a5 100644 (file)
@@ -41,6 +41,7 @@ private:
   bool physic_enabled;
   bool visible;
   bool new_vel_set;
+  int layer;
   Vector new_vel;
   Physic physic;
   Sprite* sprite;
index c4a5082..3d6b6f9 100644 (file)
@@ -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;
   }