void killtux(int mode);
void add_bullet(int x, int y, int dir, int xm);
void drawendscreen(void);
+void drawresultscreen(void);
/* --- GAME LOOP! --- */
{
distros += 50;
}
+ else if (key == SDLK_SPACE)
+ {
+ next_level = 1;
+ }
}
#ifdef JOY_YES
else if (event.type == SDL_JOYAXISMOTION)
/* Handle key and joystick state: */
- if (!tux_dying && !next_level)
+ if (!(tux_dying || next_level))
{
if (right == DOWN && left == UP)
{
if (tux_x >= endpos && endpos != 0)
{
- /* FIXME: No need to kill Tux to end the level! ;^) */
next_level = 1;
- tux_dying = 1;
}
else
tux_duck = NO;
}
- } /* !tux_dying && !next_level */
+ } /* (tux_dying || next_level) */
else
{
/* Tux either died, or reached the end of a level! */
+
+ if (use_sound)
+ {
+ if (Mix_PlayingMusic())
+ Mix_HaltMusic();
+ }
+
+
+ if (next_level)
+ {
+ /* End of a level! */
+ level++;
+ next_level = 0;
+ drawresultscreen();
+ }
+ else
+ {
+
tux_ym = tux_ym + GRAVITY;
- if (tux_y >= 480)
- {
- if (use_sound)
- {
- if (Mix_PlayingMusic())
- Mix_HaltMusic();
- }
-
- if (next_level)
- {
- /* End of a level! */
-
- level++;
- next_level = 0;
- }
- else
- {
- /* He died :^( */
-
- lives--;
- }
- /* No more lives!? */
+ /* He died :^( */
+
+ lives--;
+
+ /* No more lives!? */
- if (lives < 0)
- {
- drawendscreen();
+ if (lives < 0)
+ {
+ drawendscreen();
if (score > highscore)
save_hs(score);
return(0);
}
-
+ }
/* Either way, (re-)load the (next) level... */
unloadlevelgfx();
loadlevelgfx();
- }
}
/* Move tux: */
if (distros >= DISTROS_LIFEUP)
{
- /* FIXME: Play a special sound or flash or both! */
-
distros = distros - DISTROS_LIFEUP;
- lives++;
- playsound(sounds[SND_LIFEUP]);
+ if(lives < MAX_LIVES)
+ lives++;
+ playsound(sounds[SND_LIFEUP]); /*We want to hear the sound even, if MAX_LIVES is reached*/
}
void loadlevelsong(void)
{
+
char * song_path;
song_path = (char *) malloc(sizeof(char) * (strlen(DATA_PREFIX) +
SDL_Delay(2000);
}
+void drawresultscreen(void)
+{
+ char str[80];
+
+ clearscreen(0, 0, 0);
+
+ drawcenteredtext("Result:", 200, letters_red, NO_UPDATE);
+
+ sprintf(str, "SCORE: %d", score);
+ drawcenteredtext(str, 224, letters_gold, NO_UPDATE);
+
+ sprintf(str, "DISTROS: %d", distros);
+ drawcenteredtext(str, 256, letters_blue, NO_UPDATE);
+
+ SDL_Flip(screen);
+ SDL_Delay(2000);
+}
+
return Mix_PlayingMusic();
}
else {
- // we are in --disable-sound or NOSOUND, we can't be playing music !
+ /* we are in --disable-sound we can't be playing music */
return 0;
}
}
return Mix_PlayMusic(music, loops);
}
else {
- // return error since you're trying to play music in --disable-sound mode
+ /* return error since you're trying to play music in --disable-sound mode */
return -1;
}
}