From e78991d9c85199eb542f1d90c58f82221a5eb4f7 Mon Sep 17 00:00:00 2001 From: Ingo Ruhnke Date: Thu, 22 Apr 2004 20:14:49 +0000 Subject: [PATCH] - made shrink behaviour more mariobros3 like, ie. firetux will go to largetux to smalltux, removed small-firetux SVN-Revision: 651 --- src/defines.h | 5 ---- src/gameloop.cpp | 2 +- src/player.cpp | 71 +++++++++++++++++++++++--------------------------------- src/player.h | 4 +++- src/special.cpp | 9 +++++++ 5 files changed, 42 insertions(+), 49 deletions(-) diff --git a/src/defines.h b/src/defines.h index aec1e3bab..e2cb949de 100644 --- a/src/defines.h +++ b/src/defines.h @@ -48,11 +48,6 @@ enum DyingType { DYING_FALLING = 2 }; -/* Hurt modes: */ - -#define KILL 0 -#define SHRINK 1 - /* Sizes: */ #define SMALL 0 diff --git a/src/gameloop.cpp b/src/gameloop.cpp index b43a0a9f7..dd6da60ca 100644 --- a/src/gameloop.cpp +++ b/src/gameloop.cpp @@ -555,7 +555,7 @@ GameSession::run() /* Handle time: */ if (!time_left.check() && world->get_tux()->dying == DYING_NOT) - world->get_tux()->kill(KILL); + world->get_tux()->kill(Player::KILL); /* Handle music: */ if(world->get_tux()->invincible_timer.check()) diff --git a/src/player.cpp b/src/player.cpp index 7a387a283..031fe0470 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -527,55 +527,39 @@ Player::draw() cape_left[global_frame_counter % 2]->draw(base.x- scroll_x, base.y); } - if (!got_coffee) + if (!skidding_timer.started()) { - if (!skidding_timer.started()) + if (physic.get_velocity_y() != 0) { - if (physic.get_velocity_y() != 0) + if (dir == RIGHT) + smalltux_jump_right->draw( base.x - scroll_x, base.y - 10); + else + smalltux_jump_left->draw( base.x - scroll_x, base.y - 10); + } + else + { + if (fabsf(physic.get_velocity_x()) < 1.0f) // standing { if (dir == RIGHT) - smalltux_jump_right->draw( base.x - scroll_x, base.y - 10); + smalltux_stand_right->draw( base.x - scroll_x, base.y - 9); else - smalltux_jump_left->draw( base.x - scroll_x, base.y - 10); + smalltux_stand_left->draw( base.x - scroll_x, base.y - 9); } - else + else // moving { - if (fabsf(physic.get_velocity_x()) < 1.0f) // standing - { - if (dir == RIGHT) - smalltux_stand_right->draw( base.x - scroll_x, base.y - 9); - else - smalltux_stand_left->draw( base.x - scroll_x, base.y - 9); - } - else // moving - { - if (dir == RIGHT) - tux_right[(global_frame_counter/2) % tux_right.size()]->draw(base.x - scroll_x, base.y - 9); - else - tux_left[(global_frame_counter/2) % tux_left.size()]->draw(base.x - scroll_x, base.y - 9); - } + if (dir == RIGHT) + tux_right[(global_frame_counter/2) % tux_right.size()]->draw(base.x - scroll_x, base.y - 9); + else + tux_left[(global_frame_counter/2) % tux_left.size()]->draw(base.x - scroll_x, base.y - 9); } } - else - { - if (dir == RIGHT) - smalltux_skid_right->draw(base.x - scroll_x, base.y); - else - smalltux_skid_left->draw(base.x - scroll_x, base.y); - } } else { - /* Tux got coffee! */ - if (dir == RIGHT) - { - firetux_right[frame_]->draw( base.x- scroll_x, base.y); - } + smalltux_skid_right->draw(base.x - scroll_x, base.y); else - { - firetux_left[frame_]->draw( base.x- scroll_x, base.y); - } + smalltux_skid_left->draw(base.x - scroll_x, base.y); } } else // Large Tux @@ -749,7 +733,7 @@ Player::collision(void* p_c_object, int c_object) /* Kill Player! */ void -Player::kill(int mode) +Player::kill(HurtMode mode) { play_sound(sounds[SND_HURT], SOUND_CENTER_SPEAKER); @@ -758,12 +742,15 @@ Player::kill(int mode) if (mode == SHRINK && size == BIG) { if (got_coffee) - got_coffee = false; - - size = SMALL; - base.height = 32; - duck = false; - + { + got_coffee = false; + } + else + { + size = SMALL; + base.height = 32; + duck = false; + } safe_timer.start(TUX_SAFE_TIME); } else diff --git a/src/player.h b/src/player.h index db73d8e1d..2a055bb74 100644 --- a/src/player.h +++ b/src/player.h @@ -112,6 +112,8 @@ extern Surface* bigcape_left[2]; class Player { public: + enum HurtMode { KILL, SHRINK }; + player_input_type input; bool got_coffee; int size; @@ -142,7 +144,7 @@ public: void grabdistros(); void draw(); void collision(void* p_c_object, int c_object); - void kill(int mode); + void kill(HurtMode mode); void is_dying(); bool is_dead(); void player_remove_powerups(); diff --git a/src/special.cpp b/src/special.cpp index 33878cfff..ee7dacc97 100644 --- a/src/special.cpp +++ b/src/special.cpp @@ -306,6 +306,15 @@ Upgrade::collision(void* p_c_object, int c_object) { play_sound(sounds[SND_COFFEE], SOUND_CENTER_SPEAKER); pplayer->got_coffee = true; + pplayer->size = BIG; + pplayer->base.height = 64; + pplayer->base.y -= 32; + if(collision_object_map(pplayer->base)) + { + pplayer->base.height = 32; + pplayer->base.y += 32; + pplayer->duck = true; + } } else if (kind == UPGRADE_HERRING) { -- 2.11.0