[Super-tux-commit] supertux/src badguy.cpp,1.58,1.59 gameloop.cpp,1.115,1.116 gameloop.h,1.47,1.48 m
Brought to you by:
wkendrick
From: Ingo R. <gr...@us...> - 2004-04-29 00:15:32
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24974/src Modified Files: badguy.cpp gameloop.cpp gameloop.h music_manager.cpp music_manager.h player.cpp player.h special.cpp text.cpp worldmap.cpp Log Message: <MatzeB> -updates the TODO file <MatzeB> -should really fix the problems when picking up specials <MatzeB> -should fix mriceblock not falling down <MatzeB> -you can duck again while jumping <MatzeB> -textscroller isn't framerate limited anymore <MatzeB> -changes to the endsequence code, so that you can always hear the complete music single grumbel: removed the duck while jumping thing, since that is reserved for the butt-jump Index: text.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/text.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- text.cpp 28 Apr 2004 14:58:24 -0000 1.18 +++ text.cpp 29 Apr 2004 00:15:11 -0000 1.19 @@ -222,7 +222,7 @@ /* --- SCROLL TEXT FUNCTION --- */ #define MAX_VEL 10 -#define SPEED_INC 1.0 +#define SPEED_INC 0.01 #define SCROLL 60 #define ITEMS_SPACE 4 @@ -236,7 +236,7 @@ void display_text_file(const std::string& file, Surface* surface, float scroll_speed) { int done; - int scroll; + float scroll; float speed; int y; int length; @@ -266,13 +266,14 @@ scroll = 0; - speed = scroll_speed; + speed = scroll_speed / 50; done = 0; length = names.num_items; SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); + Uint32 lastticks = SDL_GetTicks(); while(done == 0) { /* in case of input, exit */ @@ -322,19 +323,23 @@ switch(names.item[i][0]) { case ' ': - white_small_text->drawf(names.item[i]+1, 0, screen->h+y-scroll, A_HMIDDLE, A_TOP, 1); + white_small_text->drawf(names.item[i]+1, 0, screen->h+y-int(scroll), + A_HMIDDLE, A_TOP, 1); y += white_small_text->h+ITEMS_SPACE; break; case ' ': - white_text->drawf(names.item[i]+1, 0, screen->h+y-scroll, A_HMIDDLE, A_TOP, 1); + white_text->drawf(names.item[i]+1, 0, screen->h+y-int(scroll), + A_HMIDDLE, A_TOP, 1); y += white_text->h+ITEMS_SPACE; break; case '-': - white_big_text->drawf(names.item[i]+1, 0, screen->h+y-scroll, A_HMIDDLE, A_TOP, 3); + white_big_text->drawf(names.item[i]+1, 0, screen->h+y-int(scroll), + A_HMIDDLE, A_TOP, 3); y += white_big_text->h+ITEMS_SPACE; break; default: - blue_text->drawf(names.item[i], 0, screen->h+y-scroll, A_HMIDDLE, A_TOP, 1); + blue_text->drawf(names.item[i], 0, screen->h+y-int(scroll), + A_HMIDDLE, A_TOP, 1); y += blue_text->h+ITEMS_SPACE; break; } @@ -345,11 +350,13 @@ if(screen->h+y-scroll < 0 && 20+screen->h+y-scroll < 0) done = 1; - scroll += (int)speed; + Uint32 ticks = SDL_GetTicks(); + scroll += speed * (ticks - lastticks); + lastticks = ticks; if(scroll < 0) scroll = 0; - SDL_Delay(35); + SDL_Delay(10); } string_list_free(&names); Index: player.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.h,v retrieving revision 1.43 retrieving revision 1.44 diff -u -d -r1.43 -r1.44 --- player.h 26 Apr 2004 14:40:17 -0000 1.43 +++ player.h 29 Apr 2004 00:15:10 -0000 1.44 @@ -146,6 +146,7 @@ void keep_in_bounds(); bool on_ground(); bool under_solid(); + void grow(); private: void handle_horizontal_input(); Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.71 retrieving revision 1.72 diff -u -d -r1.71 -r1.72 --- player.cpp 28 Apr 2004 14:12:37 -0000 1.71 +++ player.cpp 29 Apr 2004 00:15:10 -0000 1.72 @@ -455,11 +455,30 @@ duck = false; base.y -= 32; base.height = 64; - old_base = previous_base = base; } } void +Player::grow() +{ + if(size == BIG) + return; + + size = BIG; + base.height = 64; + base.y -= 32; + // eventually go in duck mode if there's no space + if(collision_object_map(base)) + { + base.height = 32; + base.y += 32; + duck = true; + } + + old_base = previous_base = base; +} + +void Player::grabdistros() { /* Grab distros: */ Index: special.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/special.cpp,v retrieving revision 1.38 retrieving revision 1.39 diff -u -d -r1.38 -r1.39 --- special.cpp 28 Apr 2004 20:34:24 -0000 1.38 +++ special.cpp 29 Apr 2004 00:15:10 -0000 1.39 @@ -330,20 +330,13 @@ if (kind == UPGRADE_GROWUP) { play_sound(sounds[SND_EXCELLENT], SOUND_CENTER_SPEAKER); - pplayer->size = BIG; - pplayer->base.height = 64; - pplayer->base.y -= 32; + pplayer->grow(); } else if (kind == UPGRADE_ICEFLOWER) { play_sound(sounds[SND_COFFEE], SOUND_CENTER_SPEAKER); + pplayer->grow(); pplayer->got_coffee = true; - if (pplayer->size == SMALL) - { - pplayer->size = BIG; - pplayer->base.height = 64; - pplayer->base.y -= 32; - } } else if (kind == UPGRADE_HERRING) { Index: music_manager.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/music_manager.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- music_manager.h 24 Apr 2004 14:49:03 -0000 1.1 +++ music_manager.h 29 Apr 2004 00:15:10 -0000 1.2 @@ -38,7 +38,7 @@ MusicRef load_music(const std::string& file); bool exists_music(const std::string& filename); - void play_music(const MusicRef& music); + void play_music(const MusicRef& music, int loops = -1); void halt_music(); void enable_music(bool enable); Index: badguy.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.cpp,v retrieving revision 1.58 retrieving revision 1.59 diff -u -d -r1.58 -r1.59 --- badguy.cpp 28 Apr 2004 21:23:14 -0000 1.58 +++ badguy.cpp 29 Apr 2004 00:15:10 -0000 1.59 @@ -205,11 +205,11 @@ { Player& tux = *World::current()->get_tux(); - if(dying == DYING_NOT) + if(mode != HELD) fall(); /* Move left/right: */ - if (mode == NORMAL || mode == KICK) + if (mode != HELD) { // move physic.apply(frame_ratio, base.x, base.y); Index: worldmap.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.cpp,v retrieving revision 1.63 retrieving revision 1.64 diff -u -d -r1.63 -r1.64 --- worldmap.cpp 28 Apr 2004 14:58:24 -0000 1.63 +++ worldmap.cpp 29 Apr 2004 00:15:11 -0000 1.64 @@ -681,7 +681,11 @@ } if (!level->extro_filename.empty()) - { // Display final credits and go back to the main menu + { + MusicRef theme = + music_manager->load_music(datadir + "/music/theme.mod"); + music_manager->play_music(theme); + // Display final credits and go back to the main menu display_text_file(level->extro_filename, "/images/background/extro.jpg", SCROLL_SPEED_MESSAGE); display_text_file("CREDITS", Index: gameloop.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.h,v retrieving revision 1.47 retrieving revision 1.48 diff -u -d -r1.47 -r1.48 --- gameloop.h 26 Apr 2004 19:11:53 -0000 1.47 +++ gameloop.h 29 Apr 2004 00:15:10 -0000 1.48 @@ -59,7 +59,12 @@ /** If true the end_sequence will be played, user input will be ignored while doing that */ - bool end_sequence; + enum EndSequenceState { + NO_ENDSEQUENCE, + ENDSEQUENCE_RUNNING, // tux is running right + ENDSEQUENCE_WAITING // waiting for the end of the music + }; + EndSequenceState end_sequence; float last_x_pos; bool game_pause; Index: music_manager.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/music_manager.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- music_manager.cpp 25 Apr 2004 14:27:49 -0000 1.2 +++ music_manager.cpp 29 Apr 2004 00:15:10 -0000 1.3 @@ -82,7 +82,7 @@ } void -MusicManager::play_music(const MusicRef& musicref) +MusicManager::play_music(const MusicRef& musicref, int loops) { if(!audio_device) return; @@ -97,7 +97,7 @@ current_music->refcount++; if(music_enabled) - Mix_PlayMusic(current_music->music, -1); + Mix_PlayMusic(current_music->music, loops); } void Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.115 retrieving revision 1.116 diff -u -d -r1.115 -r1.116 --- gameloop.cpp 28 Apr 2004 17:27:14 -0000 1.115 +++ gameloop.cpp 29 Apr 2004 00:15:10 -0000 1.116 @@ -58,7 +58,7 @@ GameSession* GameSession::current_ = 0; GameSession::GameSession(const std::string& subset_, int levelnb_, int mode) - : world(0), st_gl_mode(mode), levelnb(levelnb_), end_sequence(false), + : world(0), st_gl_mode(mode), levelnb(levelnb_), end_sequence(NO_ENDSEQUENCE), subset(subset_) { current_ = this; @@ -77,7 +77,7 @@ { game_pause = false; exit_status = NONE; - end_sequence = false; + end_sequence = NO_ENDSEQUENCE; fps_timer.init(true); frame_timer.init(true); @@ -194,12 +194,13 @@ void GameSession::process_events() { - if (end_sequence) + if (end_sequence != NO_ENDSEQUENCE) { Player& tux = *world->get_tux(); - + + tux.input.fire = UP; tux.input.left = UP; - tux.input.right = DOWN; + tux.input.right = DOWN; tux.input.down = UP; if (int(last_x_pos) == int(tux.base.x)) @@ -246,7 +247,7 @@ } } } - else + else // normal mode { if(!Menu::current() && !game_pause) st_pause_ticks_stop(); @@ -417,19 +418,28 @@ Tile* endtile = collision_goal(tux->base); // fallback in case the other endpositions don't trigger - if (tux->base.x >= endpos || (endtile && endtile->data >= 1) - || (end_sequence && !endsequence_timer.check())) + if (!end_sequence && tux->base.x >= endpos) + { + end_sequence = ENDSEQUENCE_WAITING; + last_x_pos = -1; + music_manager->play_music(level_end_song, 0); + endsequence_timer.start(7000); + } + else if(end_sequence && !endsequence_timer.check()) { exit_status = LEVEL_FINISHED; return; } + else if(end_sequence == ENDSEQUENCE_RUNNING && endtile && endtile->data >= 1) + { + end_sequence = ENDSEQUENCE_WAITING; + } else if(!end_sequence && endtile && endtile->data == 0) { - end_sequence = true; + end_sequence = ENDSEQUENCE_RUNNING; last_x_pos = -1; - music_manager->halt_music(); - music_manager->play_music(level_end_song); - endsequence_timer.start(5000); // 5 seconds until we finish the map + music_manager->play_music(level_end_song, 0); + endsequence_timer.start(7000); // 5 seconds until we finish the map } else if (!end_sequence && tux->is_dead()) { @@ -455,8 +465,6 @@ void GameSession::action(double frame_ratio) { - check_end_conditions(); - if (exit_status == NONE) { // Update Tux and the World @@ -570,9 +578,10 @@ while (frame_ratio > 0) { // Update the world - if (end_sequence) + check_end_conditions(); + if (end_sequence == ENDSEQUENCE_RUNNING) action(.5f); - else + else if(end_sequence == NO_ENDSEQUENCE) action(1.0f); frame_ratio -= 1.0f; } |