From: Ingo Ruhnke Date: Thu, 22 Apr 2004 16:25:32 +0000 (+0000) Subject: - synced walk speed of walking enemies X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=6c83e03d87c595495137b60d27966008f5afad19;p=supertux.git - synced walk speed of walking enemies - added standing tux SVN-Revision: 638 --- diff --git a/src/badguy.cpp b/src/badguy.cpp index 4c0fa0f71..67d55406c 100644 --- a/src/badguy.cpp +++ b/src/badguy.cpp @@ -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); } diff --git a/src/player.cpp b/src/player.cpp index db17d731e..0c1599b05 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -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 { diff --git a/src/player.h b/src/player.h index 6a49a7779..db73d8e1d 100644 --- a/src/player.h +++ b/src/player.h @@ -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; diff --git a/src/resources.cpp b/src/resources.cpp index b986b8466..a433dad6c 100644 --- a/src/resources.cpp +++ b/src/resources.cpp @@ -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");