From: Ryan Flegel Date: Tue, 25 May 2004 02:51:30 +0000 (+0000) Subject: - beginnings of a wingling X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=157cef71aeb9ae25b7bb90f37dda11bc09329d11;p=supertux.git - beginnings of a wingling SVN-Revision: 1321 --- diff --git a/data/images/shared/wingling-1.png b/data/images/shared/wingling-1.png new file mode 100644 index 000000000..1b065527e Binary files /dev/null and b/data/images/shared/wingling-1.png differ diff --git a/data/supertux.strf b/data/supertux.strf index 1c8a013b8..75375daee 100644 --- a/data/supertux.strf +++ b/data/supertux.strf @@ -617,27 +617,33 @@ ; Trampoline (sprite (name "trampoline-1") (x-hotspot 0) - (x-hotspot 0) + (y-hotspot 0) (images "shared/trampoline-1.png")) (sprite (name "trampoline-2") (x-hotspot 0) - (x-hotspot 0) + (y-hotspot 0) (images "shared/trampoline-2.png")) (sprite (name "trampoline-3") (x-hotspot 0) - (x-hotspot 0) + (y-hotspot 0) (images "shared/trampoline-3.png")) (sprite (name "trampoline-4") (x-hotspot 0) - (x-hotspot 0) + (y-hotspot 0) (images "shared/trampoline-4.png")) ; Flying platforms (sprite (name "flying_platform") (x-hotspot 0) - (x-hotspot 0) + (y-hotspot 0) (images "shared/flying_platform-1.png")) + ; Wingling + (sprite (name "wingling-left") + (x-hotspot 0) + (y-hotspot 0) + (images "shared/wingling-1.png")) + ) ;; EOF ;; diff --git a/src/badguy.cpp b/src/badguy.cpp index e8062321a..4f8175ed9 100644 --- a/src/badguy.cpp +++ b/src/badguy.cpp @@ -74,8 +74,10 @@ Sprite* img_snowball_left; Sprite* img_snowball_right; Sprite* img_snowball_squished_left; Sprite* img_snowball_squished_right; +Sprite* img_wingling_left; #define BADGUY_WALK_SPEED .8f +#define WINGLING_FLY_SPEED 1.6f BadGuyKind badguykind_from_string(const std::string& str) { @@ -99,6 +101,8 @@ BadGuyKind badguykind_from_string(const std::string& str) return BAD_SPIKY; else if (str == "snowball" || str == "bsod") // was bsod in old maps return BAD_SNOWBALL; + else if (str == "wingling") + return BAD_WINGLING; else { printf("Couldn't convert badguy: '%s'\n", str.c_str()); @@ -140,6 +144,9 @@ std::string badguykind_to_string(BadGuyKind kind) case BAD_SNOWBALL: return "snowball"; break; + case BAD_WINGLING: + return "wingling"; + break; default: return "snowball"; } @@ -271,6 +278,10 @@ BadGuy::activate(Direction activation_dir) } else if(kind == BAD_SNOWBALL) { physic.set_velocity(dirsign * BADGUY_WALK_SPEED, 0); set_sprite(img_snowball_left, img_snowball_right); + } else if(kind == BAD_WINGLING) { + physic.set_velocity(dirsign * WINGLING_FLY_SPEED, 0); + physic.enable_gravity(false); + set_sprite(img_wingling_left, img_wingling_left); } base.x = start_position.x; @@ -766,6 +777,30 @@ BadGuy::action_snowball(double elapsed_time) } void +BadGuy::action_wingling(double elapsed_time) +{ + if (dying != DYING_NOT) + physic.enable_gravity(true); + else + { + Player& tux = *World::current()->get_tux(); + + if (fabsf(tux.base.x - base.x) < 200 && base.y < tux.base.y && tux.dying == DYING_NOT) + physic.set_velocity(-2.0f, -2.0f); + else + physic.set_velocity(-WINGLING_FLY_SPEED, 0); + } + + physic.apply(elapsed_time, base.x, base.y); + + + // Handle dying timer: + if (dying == DYING_SQUISHED && !timer.check()) + remove_me(); +} + + +void BadGuy::action(float elapsed_time) { float scroll_x = World::current()->camera->get_translation().x; @@ -864,6 +899,11 @@ BadGuy::action(float elapsed_time) case BAD_SNOWBALL: action_snowball(elapsed_time); break; + + case BAD_WINGLING: + action_wingling(elapsed_time); + break; + default: break; } @@ -1040,7 +1080,12 @@ BadGuy::squish(Player* player) squish_me(player); set_sprite(img_snowball_squished_left, img_snowball_squished_right); return; + } else if(kind == BAD_WINGLING) { + squish_me(player); + set_sprite(img_wingling_left, img_wingling_left); } + + } void @@ -1123,6 +1168,7 @@ BadGuy::collision(void *p_c_object, int c_object, CollisionType type) case CO_BADGUY: pbad_c = (BadGuy*) p_c_object; + /* If we're a kicked mriceblock, kill [almost] any badguys we hit */ if(kind == BAD_MRICEBLOCK && mode == KICK && kind != BAD_FLAME && kind != BAD_BOMB && kind != BAD_STALACTITE) @@ -1168,7 +1214,11 @@ BadGuy::collision(void *p_c_object, int c_object, CollisionType type) /* When enemies run into eachother, make them change directions */ else { - // Jumpy, fish, flame, stalactites are exceptions + // Wingling doesn't interact with other badguys + if (pbad_c->kind == BAD_WINGLING || kind == BAD_WINGLING) + break; + + // Jumpy, fish, flame, stalactites, wingling are exceptions if (pbad_c->kind == BAD_JUMPY || pbad_c->kind == BAD_FLAME || pbad_c->kind == BAD_STALACTITE || pbad_c->kind == BAD_FISH) break; @@ -1283,6 +1333,7 @@ void load_badguy_gfx() img_snowball_right = sprite_manager->load("snowball-right"); img_snowball_squished_left = sprite_manager->load("snowball-squished-left"); img_snowball_squished_right = sprite_manager->load("snowball-squished-right"); + img_wingling_left = sprite_manager->load("wingling-left"); } void free_badguy_gfx() diff --git a/src/badguy.h b/src/badguy.h index b4c3f527f..cc3c70ab6 100644 --- a/src/badguy.h +++ b/src/badguy.h @@ -49,6 +49,7 @@ enum BadGuyKind { BAD_FLYINGSNOWBALL, BAD_SPIKY, BAD_SNOWBALL, + BAD_WINGLING, NUM_BadGuyKinds }; @@ -144,6 +145,7 @@ private: void action_flyingsnowball(double frame_ratio); void action_spiky(double frame_ratio); void action_snowball(double frame_ratio); + void action_wingling(double frame_ratio); /** initializes the badguy (when he appears on screen) */ void activate(Direction direction);