{
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);
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;
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();
/* 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);
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)
break;
case SDLK_s:
if(debug_mode)
- score += 1000;
+ player_status.score += 1000;
case SDLK_f:
if(debug_fps)
debug_fps = false;
{
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();
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();
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);
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);
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();
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();
physic.enable_gravity(false);
/* Reset score multiplier (for multi-hits): */
- score_multiplier = 1;
+ player_status.score_multiplier = 1;
}
if(jumped_in_solid)
if (base.x >= World::current()->get_level()->endpos
&& World::current()->get_level()->endpos != 0)
{
- next_level = 1;
+ player_status.next_level = 1;
}
}
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);
}
}
}
pbad_c->kill_me();
}
}
- score_multiplier++;
+ player_status.score_multiplier++;
}
break;
default:
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: */
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"
#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;
#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;
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)
{
// 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;
{
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)
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);
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)
{
/* Get some score: */
play_sound(sounds[SND_BRICK], SOUND_CENTER_SPEAKER);
- score = score + SCORE_BRICK;
+ player_status.score = player_status.score + SCORE_BRICK;
}
}
}
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!
(int)(y / 32) * 32);
}
- score = score + SCORE_DISTRO;
- distros++;
+ player_status.score = player_status.score + SCORE_DISTRO;
+ player_status.distros++;
}
}