- synced walk speed of walking enemies
authorIngo Ruhnke <grumbel@gmx.de>
Thu, 22 Apr 2004 16:25:32 +0000 (16:25 +0000)
committerIngo Ruhnke <grumbel@gmx.de>
Thu, 22 Apr 2004 16:25:32 +0000 (16:25 +0000)
- added standing tux

SVN-Revision: 638

src/badguy.cpp
src/player.cpp
src/player.h
src/resources.cpp

index 4c0fa0f..67d5540 100644 (file)
@@ -70,6 +70,8 @@ Sprite* img_snowball_right;
 Sprite* img_snowball_squished_left;
 Sprite* img_snowball_squished_right;
 
+#define BADGUY_WALK_SPEED .8f
+
 BadGuyKind  badguykind_from_string(const std::string& str)
 {
   if (str == "money")
@@ -166,13 +168,13 @@ BadGuy::init(float x, float y, BadGuyKind kind_, bool stay_on_platform_)
   timer.init(true);
 
   if(kind == BAD_BSOD) {
-    physic.set_velocity(-1.3, 0);
+    physic.set_velocity(-BADGUY_WALK_SPEED, 0);
     set_sprite(img_bsod_left, img_bsod_right);
   } else if(kind == BAD_MRBOMB) {
-    physic.set_velocity(-1.3, 0);
+    physic.set_velocity(-BADGUY_WALK_SPEED, 0);
     set_sprite(img_mrbomb_left, img_mrbomb_right);
   } else if (kind == BAD_LAPTOP) {
-    physic.set_velocity(-.8, 0);
+    physic.set_velocity(-BADGUY_WALK_SPEED, 0);
     set_sprite(img_laptop_left, img_laptop_right);
   } else if(kind == BAD_MONEY) {
     set_sprite(img_jumpy_left_up, img_jumpy_left_up);
@@ -185,7 +187,7 @@ BadGuy::init(float x, float y, BadGuyKind kind_, bool stay_on_platform_)
     physic.enable_gravity(false);
     set_sprite(img_flame, img_flame);
   } else if(kind == BAD_BOUNCINGSNOWBALL) {
-    physic.set_velocity(-1.3, 0);
+    physic.set_velocity(-BADGUY_WALK_SPEED, 0);
     set_sprite(img_bouncingsnowball_left, img_bouncingsnowball_right);
   } else if(kind == BAD_STALACTITE) {
     physic.enable_gravity(false);
@@ -197,10 +199,10 @@ BadGuy::init(float x, float y, BadGuyKind kind_, bool stay_on_platform_)
     set_sprite(img_flyingsnowball, img_flyingsnowball);
     physic.enable_gravity(false);
   } else if(kind == BAD_SPIKY) {
-    physic.set_velocity(-1.3, 0);
+    physic.set_velocity(-BADGUY_WALK_SPEED, 0);
     set_sprite(img_spiky_left, img_spiky_right);
   } else if(kind == BAD_SNOWBALL) {
-    physic.set_velocity(-1.3, 0);
+    physic.set_velocity(-BADGUY_WALK_SPEED, 0);
     set_sprite(img_snowball_left, img_snowball_right);
   }
 
index db17d73..0c1599b 100644 (file)
@@ -38,6 +38,8 @@ Surface* smalltux_stand_right;
 Sprite*  smalltux_gameover;
 Sprite*  smalltux_skid_left;
 Sprite*  smalltux_skid_right;
+Sprite*  largetux_stand_left;
+Sprite*  largetux_stand_right;
 
 Sprite* bigtux_right;
 Sprite* bigtux_left;
@@ -598,10 +600,20 @@ Player::draw()
                         {
                           if (physic.get_velocity_y() == 0)
                             {
-                              if (dir == RIGHT)
-                                bigtux_right->draw(base.x - scroll_x, base.y);
-                              else
-                                bigtux_left->draw(base.x - scroll_x, base.y);
+                              if (fabsf(physic.get_velocity_x()) < 1.0f) // standing
+                                {
+                                  if (dir == RIGHT)
+                                    largetux_stand_right->draw(base.x - scroll_x, base.y);
+                                  else
+                                    largetux_stand_left->draw(base.x - scroll_x, base.y);
+                                }
+                              else // walking
+                                {
+                                  if (dir == RIGHT)
+                                    bigtux_right->draw(base.x - scroll_x, base.y);
+                                  else
+                                    bigtux_left->draw(base.x - scroll_x, base.y);
+                                }
                             }
                           else
                             {
index 6a49a77..db73d8e 100644 (file)
@@ -84,6 +84,8 @@ extern Surface* smalltux_stand_right;
 extern Sprite*  smalltux_skid_left;
 extern Sprite*  smalltux_skid_right;
 extern Sprite*  smalltux_gameover;
+extern Sprite*  largetux_stand_left;
+extern Sprite*  largetux_stand_right;
 extern Sprite* bigtux_right;
 extern Sprite* bigtux_left;
 extern Sprite* bigtux_right_jump;
index b986b84..a433dad 100644 (file)
@@ -48,6 +48,9 @@ void loadshared()
   sprite_manager = new SpriteManager(datadir + "/supertux.strf");
 
   /* Tuxes: */
+  largetux_stand_left  = sprite_manager->load("largetux-stand-left");
+  largetux_stand_right = sprite_manager->load("largetux-stand-right");
+
   smalltux_gameover = sprite_manager->load("smalltux-gameover");
 
   smalltux_skid_left  = sprite_manager->load("smalltux-skid-left");