[Super-tux-commit] supertux/src player.cpp,1.52,1.53 world.cpp,1.36,1.37
Brought to you by:
wkendrick
From: Ingo R. <gr...@us...> - 2004-04-22 13:24:24
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17655 Modified Files: player.cpp world.cpp Log Message: - merged a few duplicated if's in player - added live-lost tux Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.52 retrieving revision 1.53 diff -u -d -r1.52 -r1.53 --- player.cpp 22 Apr 2004 00:13:33 -0000 1.52 +++ player.cpp 22 Apr 2004 13:24:15 -0000 1.53 @@ -177,15 +177,15 @@ { bool jumped_in_solid = false; - /* --- HANDLE TUX! --- */ + /* Move tux: */ + previous_base = base; + /* --- HANDLE TUX! --- */ if(dying == DYING_NOT) handle_input(); - /* Move tux: */ - previous_base = base; - physic.apply(frame_ratio, base.x, base.y); + if(dying == DYING_NOT) { base_type target = base; @@ -206,14 +206,9 @@ previous_base = old_base = base; } keep_in_bounds(); - } - - if (dying == DYING_NOT) - { - /* Land: */ - - if( !on_ground()) + // Land: + if (!on_ground()) { physic.enable_gravity(true); if(under_solid()) @@ -394,7 +389,7 @@ { if (on_ground()) { - // jump + // jump higher if we are running if (physic.get_velocity_x() > MAX_WALK_XM) physic.set_velocity_y(5.8); else @@ -513,159 +508,163 @@ { if (!safe_timer.started() || (global_frame_counter % 2) == 0) { - if (size == SMALL) + if (dying == DYING_SQUISHED) { - if (invincible_timer.started()) - { - /* Draw cape: */ - - if (dir == RIGHT) - cape_right[global_frame_counter % 2]->draw(base.x- scroll_x, base.y); - else - cape_left[global_frame_counter % 2]->draw(base.x- scroll_x, base.y); - } - - - if (!got_coffee) + smalltux_gameover->draw(base.x - scroll_x, base.y); + } + else + { + if (size == SMALL) { - if (!skidding_timer.started()) + if (invincible_timer.started()) { - 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); - } + if (dir == RIGHT) + cape_right[global_frame_counter % 2]->draw(base.x- scroll_x, base.y); else + cape_left[global_frame_counter % 2]->draw(base.x- scroll_x, base.y); + } + + if (!got_coffee) + { + if (!skidding_timer.started()) { - if (fabsf(physic.get_velocity_x()) < 1.0f) // standing + if (physic.get_velocity_y() != 0) { if (dir == RIGHT) - smalltux_stand_right->draw( base.x - scroll_x, base.y - 9); + smalltux_jump_right->draw( base.x - scroll_x, base.y - 10); else - smalltux_stand_left->draw( base.x - scroll_x, base.y - 9); + smalltux_jump_left->draw( base.x - scroll_x, base.y - 10); } - else // moving + else { - 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 (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); + } } } + 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) - smalltux_skid_right->draw(base.x - scroll_x, base.y); + { + firetux_right[frame_]->draw( base.x- scroll_x, base.y); + } else - smalltux_skid_left->draw(base.x - scroll_x, base.y); + { + firetux_left[frame_]->draw( base.x- scroll_x, base.y); + } } } - else + else // Large Tux { - /* Tux got coffee! */ - - if (dir == RIGHT) - { - firetux_right[frame_]->draw( base.x- scroll_x, base.y); - } - else + if (invincible_timer.started()) { - firetux_left[frame_]->draw( base.x- scroll_x, base.y); - } - } - } - else // Large Tux - { - if (invincible_timer.started()) - { - float capex = base.x + (base.width - bigcape_right[0]->w) / 2; - capex -= scroll_x; - float capey = base.y + (base.height - bigcape_right[0]->h) / 2; + float capex = base.x + (base.width - bigcape_right[0]->w) / 2; + capex -= scroll_x; + float capey = base.y + (base.height - bigcape_right[0]->h) / 2; - /* Draw cape (just not in ducked mode since that looks silly): */ - if (dir == RIGHT) - bigcape_right[global_frame_counter % 2]->draw(capex, capey); - else - bigcape_left[global_frame_counter % 2]->draw(capex, capey); - } + /* Draw cape (just not in ducked mode since that looks silly): */ + if (dir == RIGHT) + bigcape_right[global_frame_counter % 2]->draw(capex, capey); + else + bigcape_left[global_frame_counter % 2]->draw(capex, capey); + } - if (!got_coffee) - { - if (!duck) + if (!got_coffee) { - if (!skidding_timer.started()) + if (!duck) { - if (physic.get_velocity_y() == 0) + if (!skidding_timer.started()) { - if (dir == RIGHT) - bigtux_right->draw(base.x - scroll_x, base.y); + 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); + } else - bigtux_left->draw(base.x - scroll_x, base.y); + { + if (dir == RIGHT) + bigtux_right_jump->draw(base.x - scroll_x, base.y); + else + bigtux_left_jump->draw(base.x - scroll_x, base.y); + } } else { if (dir == RIGHT) - bigtux_right_jump->draw(base.x - scroll_x, base.y); + skidtux_right->draw(base.x - scroll_x - 8, base.y); else - bigtux_left_jump->draw(base.x - scroll_x, base.y); + skidtux_left->draw(base.x - scroll_x - 8, base.y); } } else { if (dir == RIGHT) - skidtux_right->draw(base.x - scroll_x - 8, base.y); + ducktux_right->draw(base.x - scroll_x, base.y); else - skidtux_left->draw(base.x - scroll_x - 8, base.y); + ducktux_left->draw(base.x - scroll_x, base.y); } } else { - if (dir == RIGHT) - ducktux_right->draw(base.x - scroll_x, base.y); - else - ducktux_left->draw(base.x - scroll_x, base.y); - } - } - else - { - /* Tux has coffee! */ - if (!duck) - { - if (!skidding_timer.started()) + /* Tux has coffee! */ + if (!duck) { - if (!jumping || physic.get_velocity_y() > 0) + if (!skidding_timer.started()) { - if (dir == RIGHT) - bigfiretux_right[frame_]->draw(base.x- scroll_x - 8, base.y); + if (!jumping || physic.get_velocity_y() > 0) + { + if (dir == RIGHT) + bigfiretux_right[frame_]->draw(base.x- scroll_x - 8, base.y); + else + bigfiretux_left[frame_]->draw(base.x- scroll_x - 8, base.y); + } else - bigfiretux_left[frame_]->draw(base.x- scroll_x - 8, base.y); + { + if (dir == RIGHT) + bigfiretux_right_jump->draw(base.x- scroll_x - 8, base.y); + else + bigfiretux_left_jump->draw(base.x- scroll_x - 8, base.y); + } } else { if (dir == RIGHT) - bigfiretux_right_jump->draw(base.x- scroll_x - 8, base.y); + skidfiretux_right->draw(base.x- scroll_x - 8, base.y); else - bigfiretux_left_jump->draw(base.x- scroll_x - 8, base.y); + skidfiretux_left->draw(base.x- scroll_x - 8, base.y); } } else { if (dir == RIGHT) - skidfiretux_right->draw(base.x- scroll_x - 8, base.y); + duckfiretux_right->draw( base.x- scroll_x - 8, base.y - 16); else - skidfiretux_left->draw(base.x- scroll_x - 8, base.y); + duckfiretux_left->draw( base.x- scroll_x - 8, base.y - 16); } } - else - { - if (dir == RIGHT) - duckfiretux_right->draw( base.x- scroll_x - 8, base.y - 16); - else - duckfiretux_left->draw( base.x- scroll_x - 8, base.y - 16); - } } } } @@ -741,7 +740,7 @@ { play_sound(sounds[SND_HURT], SOUND_CENTER_SPEAKER); - physic.set_velocity(0, physic.get_velocity_y()); + physic.set_velocity_x(0); if (mode == SHRINK && size == BIG) { Index: world.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.cpp,v retrieving revision 1.36 retrieving revision 1.37 diff -u -d -r1.36 -r1.37 --- world.cpp 22 Apr 2004 11:17:34 -0000 1.36 +++ world.cpp 22 Apr 2004 13:24:15 -0000 1.37 @@ -554,7 +554,7 @@ void World::trybumpbadguy(float x, float y) { - /* Bad guys: */ + // Bad guys: for (unsigned int i = 0; i < bad_guys.size(); i++) { if (bad_guys[i].base.x >= x - 32 && bad_guys[i].base.x <= x + 32 && @@ -564,8 +564,7 @@ } } - - /* Upgrades: */ + // Upgrades: for (unsigned int i = 0; i < upgrades.size(); i++) { if (upgrades[i].base.height == 32 && |