/* Local variables: */
-int score, highscore, distros, level, lives, scroll_x, next_level,
+int score, highscore, distros, level, lives, scroll_x, next_level, game_pause, done, quit,
tux_dir, tux_size, tux_duck, tux_x, tux_xm, tux_y, tux_ym,
tux_dying, tux_safe, jumping, jump_counter, frame, score_multiplier,
tux_frame_main, tux_frame, tux_got_coffee, tux_skidding,
* bigcape_right[2], * bigcape_left[2],
* ducktux_right, * ducktux_left,
* skidtux_right, * skidtux_left;
+SDL_Event event;
+SDL_Rect src, dest;
+SDLKey key;
unsigned char * tiles[15];
bouncy_distro_type bouncy_distros[NUM_BOUNCY_DISTROS];
broken_brick_type broken_bricks[NUM_BROKEN_BRICKS];
char song_title[20];
char levelname[20];
char leveltheme[20];
+char str[10];
/* Local function prototypes: */
void drawendscreen(void);
void drawresultscreen(void);
+/* --- GAME EVENT! --- */
-/* --- GAME LOOP! --- */
-
-int gameloop(void)
+void game_event(void)
{
- int done, quit, x, y, i, j;
- SDL_Event event;
- SDL_Rect src, dest;
- SDLKey key;
- Uint32 last_time, now_time;
- char str[10];
-
-
- /* Clear screen: */
-
- clearscreen(0, 0, 0);
- updatescreen();
-
-
- /* Init the game: */
-
- initgame();
- loadshared();
- loadlevel();
- loadlevelgfx();
- loadlevelsong();
- highscore = load_hs();
-
-
- /* --- MAIN GAME LOOP!!! --- */
-
- done = 0;
- quit = 0;
- frame = 0;
- tux_frame_main = 0;
- tux_frame = 0;
-
- do
- {
- last_time = SDL_GetTicks();
- frame++;
-
-
- /* Handle events: */
- old_fire = fire;
-
while (SDL_PollEvent(&event))
{
+
if (event.type == SDL_QUIT)
{
/* Quit event - quit: */
{
fire = UP;
}
+ else if (key == SDLK_p)
+ {
+ if(game_pause)
+ game_pause = 0;
+ else
+ game_pause = 1;
+ }
else if (key == SDLK_TAB)
{
tux_size = !tux_size;
}
#endif
}
-
-
+
+}
+
+/* --- GAME ACTION! --- */
+
+int game_action(void)
+{
+int i,j;
+
/* --- HANDLE TUX! --- */
/* Handle key and joystick state: */
if (tux_x >= endpos && endpos != 0)
{
- /* FIXME: No need to kill Tux to end the level! ;^) */
next_level = 1;
}
{
tux_skidding--;
}
-
-
- /* Draw screen: */
+
+return -1;
+}
+
+/* --- GAME DRAW! --- */
+
+void game_draw()
+{
+int x, y, i;
+
+ /* Draw screen: */
if (tux_dying && (frame % 4) == 0)
clearscreen(255, 255, 255);
drawtext("DISTROS", 480, 0, letters_blue, NO_UPDATE);
drawtext(str, 608, 0, letters_gold, NO_UPDATE);
+ if(game_pause)
+ drawcenteredtext("PAUSE",230,letters_red, NO_UPDATE);
/* (Update it all!) */
updatescreen();
+}
+
+/* --- GAME LOOP! --- */
+
+int gameloop(void)
+{
+
+ Uint32 last_time, now_time;
+
+ /* Clear screen: */
+
+ clearscreen(0, 0, 0);
+ updatescreen();
+
+
+ /* Init the game: */
+
+ initgame();
+ loadshared();
+ loadlevel();
+ loadlevelgfx();
+ loadlevelsong();
+ highscore = load_hs();
+
+
+ /* --- MAIN GAME LOOP!!! --- */
+
+ done = 0;
+ quit = 0;
+ frame = 0;
+ tux_frame_main = 0;
+ tux_frame = 0;
+
+ do
+ {
+ last_time = SDL_GetTicks();
+ frame++;
+
+
+ /* Handle events: */
+
+ old_fire = fire;
+
+ game_event();
+ /* Handle actions: */
+
+ if(game_pause != 1)
+ {
+ int ret;
+ if((ret = game_action()) != -1) { return ret; }
+ }
+
+ /*Draw the current scene to the screen */
+ game_draw();
+
/* Keep playing music: */
if (use_sound)
}
}
+ /* Time stops in pause mode */
+ if(game_pause) { continue; }
/* Pause til next frame: */
}
+
/* Load data for this level: */
void loadlevel(void)