[Super-tux-commit] supertux/src badguy.cpp,1.25,1.26 gameloop.cpp,1.58,1.59 player.cpp,1.26,1.27 res
Brought to you by:
wkendrick
From: Ingo R. <gr...@us...> - 2004-04-11 15:21:10
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29561 Modified Files: badguy.cpp gameloop.cpp player.cpp resources.cpp scene.cpp scene.h special.cpp world.cpp Log Message: - moved some global variables into a seperate class Index: scene.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/scene.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- scene.cpp 11 Apr 2004 14:55:59 -0000 1.17 +++ scene.cpp 11 Apr 2004 15:07:29 -0000 1.18 @@ -13,11 +13,7 @@ #include <stdlib.h> #include "scene.h" -int score; -int distros; -int next_level; -int score_multiplier; -timer_type super_bkgd_timer; +PlayerStatus player_status; // FIXME: Move this into a view class float scroll_x; Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.58 retrieving revision 1.59 diff -u -d -r1.58 -r1.59 --- gameloop.cpp 11 Apr 2004 14:55:59 -0000 1.58 +++ gameloop.cpp 11 Apr 2004 15:07:29 -0000 1.59 @@ -249,11 +249,11 @@ break; case SDLK_END: if(debug_mode) - distros += 50; + player_status.distros += 50; break; case SDLK_SPACE: if(debug_mode) - next_level = 1; + player_status.next_level = 1; break; case SDLK_DELETE: if(debug_mode) @@ -269,7 +269,7 @@ break; case SDLK_s: if(debug_mode) - score += 1000; + player_status.score += 1000; case SDLK_f: if(debug_fps) debug_fps = false; @@ -342,16 +342,16 @@ { Player& tux = *world->get_tux(); - if (tux.is_dead() || next_level) + if (tux.is_dead() || player_status.next_level) { /* Tux either died, or reached the end of a level! */ halt_music(); - if (next_level) + if (player_status.next_level) { /* End of a level! */ levelnb++; - next_level = 0; + player_status.next_level = 0; if(st_gl_mode != ST_GL_TEST) { drawresultscreen(); @@ -381,8 +381,8 @@ if(st_gl_mode != ST_GL_TEST) { - if (score > hs_score) - save_hs(score); + if (player_status.score > hs_score) + save_hs(player_status.score); } world->get_level()->free_gfx(); @@ -660,7 +660,7 @@ Player& tux = *world->get_tux(); char str[60]; - sprintf(str, "%d", score); + sprintf(str, "%d", player_status.score); text_draw(&white_text, "SCORE", 0, 0, 1); text_draw(&gold_text, str, 96, 0, 1); @@ -682,7 +682,7 @@ text_draw(&gold_text, str, 304, 0, 1); } - sprintf(str, "%d", distros); + sprintf(str, "%d", player_status.distros); text_draw(&white_text, "DISTROS", screen->h, 0, 1); text_draw(&gold_text, str, 608, 0, 1); @@ -710,10 +710,10 @@ text_drawf(&blue_text, "GAMEOVER", 0, 200, A_HMIDDLE, A_TOP, 1); - sprintf(str, "SCORE: %d", score); + sprintf(str, "SCORE: %d", player_status.score); text_drawf(&gold_text, str, 0, 224, A_HMIDDLE, A_TOP, 1); - sprintf(str, "DISTROS: %d", distros); + sprintf(str, "DISTROS: %d", player_status.distros); text_drawf(&gold_text, str, 0, 256, A_HMIDDLE, A_TOP, 1); flipscreen(); @@ -731,10 +731,10 @@ text_drawf(&blue_text, "Result:", 0, 200, A_HMIDDLE, A_TOP, 1); - sprintf(str, "SCORE: %d", score); + sprintf(str, "SCORE: %d", player_status.score); text_drawf(&gold_text, str, 0, 224, A_HMIDDLE, A_TOP, 1); - sprintf(str, "DISTROS: %d", distros); + sprintf(str, "DISTROS: %d", player_status.distros); text_drawf(&gold_text, str, 0, 256, A_HMIDDLE, A_TOP, 1); flipscreen(); Index: special.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/special.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- special.cpp 11 Apr 2004 14:55:59 -0000 1.11 +++ special.cpp 11 Apr 2004 15:07:29 -0000 1.12 @@ -261,19 +261,16 @@ pplayer->base.y += 32; pplayer->duck = true; } - timer_start(&super_bkgd_timer, 350); } else if (kind == UPGRADE_COFFEE) { play_sound(sounds[SND_COFFEE], SOUND_CENTER_SPEAKER); pplayer->got_coffee = true; - timer_start(&super_bkgd_timer, 250); } else if (kind == UPGRADE_HERRING) { play_sound(sounds[SND_HERRING], SOUND_CENTER_SPEAKER); timer_start(&pplayer->invincible_timer,TUX_INVINCIBLE_TIME); - timer_start(&super_bkgd_timer, 250); /* play the herring song ^^ */ if (get_current_music() != HURRYUP_MUSIC) { Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- player.cpp 11 Apr 2004 14:44:19 -0000 1.26 +++ player.cpp 11 Apr 2004 15:07:29 -0000 1.27 @@ -201,7 +201,7 @@ physic.enable_gravity(false); /* Reset score multiplier (for multi-hits): */ - score_multiplier = 1; + player_status.score_multiplier = 1; } if(jumped_in_solid) @@ -289,7 +289,7 @@ if (base.x >= World::current()->get_level()->endpos && World::current()->get_level()->endpos != 0) { - next_level = 1; + player_status.next_level = 1; } } @@ -830,7 +830,7 @@ play_sound(sounds[SND_FALL], SOUND_CENTER_SPEAKER); World::current()->add_score(pbad_c->base.x - scroll_x, pbad_c->base.y, - 25 * score_multiplier); + 25 * player_status.score_multiplier); } } } @@ -845,7 +845,7 @@ pbad_c->kill_me(); } } - score_multiplier++; + player_status.score_multiplier++; } break; default: Index: badguy.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- badguy.cpp 11 Apr 2004 14:44:19 -0000 1.25 +++ badguy.cpp 11 Apr 2004 15:07:29 -0000 1.26 @@ -791,9 +791,10 @@ { make_player_jump(player); - World::current()->add_score(base.x - scroll_x, base.y, 50 * score_multiplier); + World::current()->add_score(base.x - scroll_x, + base.y, 50 * player_status.score_multiplier); play_sound(sounds[SND_SQUISH], SOUND_CENTER_SPEAKER); - score_multiplier++; + player_status.score_multiplier++; dying = DYING_SQUISHED; timer_start(&timer, 2000); @@ -808,9 +809,9 @@ World::current()->add_bad_guy(base.x, base.y, BAD_BOMB); make_player_jump(player); - World::current()->add_score(base.x - scroll_x, base.y, 50 * score_multiplier); + World::current()->add_score(base.x - scroll_x, base.y, 50 * player_status.score_multiplier); play_sound(sounds[SND_SQUISH], SOUND_CENTER_SPEAKER); - score_multiplier++; + player_status.score_multiplier++; remove_me(); return; @@ -849,14 +850,14 @@ make_player_jump(player); - World::current()->add_score(base.x - scroll_x, base.y, 25 * score_multiplier); - score_multiplier++; + World::current()->add_score(base.x - scroll_x, base.y, 25 * player_status.score_multiplier); + player_status.score_multiplier++; return; } else if(kind == BAD_FISH) { make_player_jump(player); - World::current()->add_score(base.x - scroll_x, base.y, 25 * score_multiplier); - score_multiplier++; + World::current()->add_score(base.x - scroll_x, base.y, 25 * player_status.score_multiplier); + player_status.score_multiplier++; // simply remove the fish... remove_me(); @@ -894,10 +895,10 @@ /* Gain some points: */ if (kind == BAD_BSOD) World::current()->add_score(base.x - scroll_x, base.y, - 50 * score_multiplier); + 50 * player_status.score_multiplier); else World::current()->add_score(base.x - scroll_x, base.y, - 25 * score_multiplier); + 25 * player_status.score_multiplier); /* Play death sound: */ play_sound(sounds[SND_FALL], SOUND_CENTER_SPEAKER); Index: world.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- world.cpp 11 Apr 2004 14:55:59 -0000 1.18 +++ world.cpp 11 Apr 2004 15:07:29 -0000 1.19 @@ -56,8 +56,7 @@ // Set defaults: scroll_x = 0; - score_multiplier = 1; - timer_init(&super_bkgd_timer, true); + player_status.score_multiplier = 1; counting_distros = false; distro_counter = 0; @@ -128,24 +127,18 @@ { int y,x; - /* Draw screen: */ - if(timer_check(&super_bkgd_timer)) - texture_draw(&img_super_bkgd, 0, 0); + /* Draw the real background */ + if(get_level()->bkgd_image[0] != '\0') + { + int s = (int)scroll_x / 30; + texture_draw_part(&level->img_bkgd, s, 0,0,0,level->img_bkgd.w - s, level->img_bkgd.h); + texture_draw_part(&level->img_bkgd, 0, 0,screen->w - s ,0,s,level->img_bkgd.h); + } else { - /* Draw the real background */ - if(get_level()->bkgd_image[0] != '\0') - { - int s = (int)scroll_x / 30; - texture_draw_part(&level->img_bkgd, s, 0,0,0,level->img_bkgd.w - s, level->img_bkgd.h); - texture_draw_part(&level->img_bkgd, 0, 0,screen->w - s ,0,s,level->img_bkgd.h); - } - else - { - clearscreen(level->bkgd_red, level->bkgd_green, level->bkgd_blue); - } + clearscreen(level->bkgd_red, level->bkgd_green, level->bkgd_blue); } - + /* Draw particle systems (background) */ std::vector<ParticleSystem*>::iterator p; for(p = particle_systems.begin(); p != particle_systems.end(); ++p) @@ -346,7 +339,7 @@ void World::add_score(float x, float y, int s) { - score += s; + player_status.score += s; FloatingScore new_floating_score; new_floating_score.init(x,y,s); @@ -439,8 +432,8 @@ plevel->change(x, y, TM_IA, tile->next_tile); play_sound(sounds[SND_DISTRO], SOUND_CENTER_SPEAKER); - score = score + SCORE_DISTRO; - distros++; + player_status.score = player_status.score + SCORE_DISTRO; + player_status.distros++; } else if (!small) { @@ -454,7 +447,7 @@ /* Get some score: */ play_sound(sounds[SND_BRICK], SOUND_CENTER_SPEAKER); - score = score + SCORE_BRICK; + player_status.score = player_status.score + SCORE_BRICK; } } } @@ -478,8 +471,8 @@ case 1: // Box with a distro! add_bouncy_distro(((int)(x + 1) / 32) * 32, (int)(y / 32) * 32 - 32); play_sound(sounds[SND_DISTRO], SOUND_CENTER_SPEAKER); - score = score + SCORE_DISTRO; - distros++; + player_status.score = player_status.score + SCORE_DISTRO; + player_status.distros++; break; case 2: // Add an upgrade! @@ -517,8 +510,8 @@ (int)(y / 32) * 32); } - score = score + SCORE_DISTRO; - distros++; + player_status.score = player_status.score + SCORE_DISTRO; + player_status.distros++; } } Index: scene.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/scene.h,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- scene.h 11 Apr 2004 14:55:59 -0000 1.20 +++ scene.h 11 Apr 2004 15:07:29 -0000 1.21 @@ -19,10 +19,15 @@ #define FRAME_RATE 10 // 100 Frames per second (10ms) // Player stats -extern int score; -extern int distros; -extern int next_level; -extern int score_multiplier; +struct PlayerStatus +{ + int score; + int distros; + int next_level; + int score_multiplier; +}; + +extern PlayerStatus player_status; extern timer_type super_bkgd_timer; extern float scroll_x; Index: resources.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/resources.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- resources.cpp 11 Apr 2004 14:55:59 -0000 1.5 +++ resources.cpp 11 Apr 2004 15:07:29 -0000 1.6 @@ -17,7 +17,6 @@ texture_type img_box_empty; texture_type img_mints; texture_type img_coffee; -texture_type img_super_bkgd; texture_type img_red_glow; /* Load graphics/sounds shared between all levels: */ @@ -284,12 +283,6 @@ USE_ALPHA); - /* Super background: */ - - texture_load(&img_super_bkgd, datadir + "/images/shared/super-bkgd.png", - IGNORE_ALPHA); - - /* Sound effects: */ /* if (use_sound) // this will introduce SERIOUS bugs here ! because "load_sound" |