level++;
next_level = 0;
if(st_gl_mode != ST_GL_TEST)
- {
- drawresultscreen();
- }
- else
- {
- level_free_gfx();
+ {
+ drawresultscreen();
+ }
+ else
+ {
+ level_free_gfx();
level_free(¤t_level);
level_free_song();
unloadshared();
arrays_free();
return(0);
- }
+ }
player_level_begin(&tux);
}
else
set_defaults();
level_free(¤t_level);
if(level_load(¤t_level,level_subset,level) != 0)
- exit(1);
+ return 0;
arrays_free();
arrays_init();
activate_bad_guys();
timer_type fps_timer, frame_timer;
timer_init(&fps_timer, YES);
timer_init(&frame_timer, YES);
-
+
game_started = YES;
st_gl_mode = mode;
level = levelnb;
strcpy(level_subset,subset);
- if(st_gl_mode != ST_GL_LOAD_GAME)
- {
- /* Init the game: */
- arrays_init();
- set_defaults();
+ /* Init the game: */
+ arrays_init();
+ set_defaults();
- if(level_load(¤t_level,level_subset,level) != 0)
- exit(1);
- level_load_gfx(¤t_level);
- activate_bad_guys();
- level_load_song(¤t_level);
+ if(level_load(¤t_level,level_subset,level) != 0)
+ exit(1);
+ level_load_gfx(¤t_level);
+ activate_bad_guys();
+ level_load_song(¤t_level);
- }
-
player_init(&tux);
if(st_gl_mode != ST_GL_TEST)
levelintro();
- timer_init(&time_left,YES);
+ timer_init(&time_left,YES);
start_timers();
if(st_gl_mode == ST_GL_LOAD_GAME)
/* Handle events: */
tux.input.old_fire = tux.input.fire;
-
+
game_event();
if(show_menu)
fwrite(&level,sizeof(int),1,fi);
fwrite(&score,sizeof(int),1,fi);
fwrite(&distros,sizeof(int),1,fi);
- fwrite(&tux,sizeof(player_type),1,fi);
fwrite(&scroll_x,sizeof(float),1,fi);
- fwrite(&time_left,sizeof(float),1,fi);
+ fwrite(&tux,sizeof(player_type),1,fi);
+ timer_fwrite(&tux.invincible_timer,fi);
+ printf("Time inv LEFT: %d\n",timer_get_left(&tux.invincible_timer));
+ timer_fwrite(&tux.skidding_timer,fi);
+ timer_fwrite(&tux.safe_timer,fi);
+ timer_fwrite(&tux.frame_timer,fi);
+ timer_fwrite(&time_left,fi);
+ printf("Time LEFT: %d\n",timer_get_left(&time_left));
ui = st_get_ticks();
fwrite(&ui,sizeof(int),1,fi);
}
level_free_song();
level_load_song(¤t_level);
levelintro();
- timer_start(&time_left,current_level.time_left*1000);
update_time = st_get_ticks();
fread(&score,sizeof(int),1,fi);
fread(&distros,sizeof(int),1,fi);
- fread(&tux,sizeof(player_type),1,fi);
fread(&scroll_x,sizeof(float),1,fi);
- fread(&time_left,sizeof(float),1,fi);
+ fread(&tux,sizeof(player_type),1,fi);
+ timer_fread(&tux.invincible_timer,fi);
+ printf("Time inv LEFT: %d - %d\n",timer_get_left(&tux.invincible_timer),tux.invincible_timer.time);
+ timer_fread(&tux.skidding_timer,fi);
+ timer_fread(&tux.safe_timer,fi);
+ timer_fread(&tux.frame_timer,fi);
+ timer_fread(&time_left,fi);
+ printf("Time LEFT: %d\n",timer_get_left(&time_left));
fread(&ui,sizeof(int),1,fi);
- time_left.time += st_get_ticks() - ui;
- tux.invincible_timer.time += st_get_ticks() - ui;
- tux.skidding_timer.time += st_get_ticks() - ui;
- tux.safe_timer.time += st_get_ticks() - ui;
- tux.vphysic.start_time += st_get_ticks() - ui;
tux.hphysic.start_time += st_get_ticks() - ui;
tux.vphysic.start_time += st_get_ticks() - ui;
fclose(fi);
else
{
if(game_started == NO)
- gameloop("whatever",slot,ST_GL_LOAD_GAME);
+ {
+ gameloop("default",slot,ST_GL_LOAD_GAME);
+ show_menu = YES;
+ menu_set_current(&main_menu);
+ }
else
loadgame(slot);
}
//
// C Implementation: timer
//
-// Description:
+// Description:
//
//
// Author: Tobias Glaesser <tobi.web@gmx.de>, (C) 2004
unsigned int st_get_ticks(void)
{
-if(st_pause_count != 0)
-return SDL_GetTicks() - st_pause_ticks - SDL_GetTicks() + st_pause_count;
-else
-return SDL_GetTicks() - st_pause_ticks;
+ if(st_pause_count != 0)
+ return SDL_GetTicks() - st_pause_ticks - SDL_GetTicks() + st_pause_count;
+ else
+ return SDL_GetTicks() - st_pause_ticks;
}
void st_pause_ticks_init(void)
{
-st_pause_ticks = 0;
-st_pause_count = 0;
+ st_pause_ticks = 0;
+ st_pause_count = 0;
}
void st_pause_ticks_start(void)
{
-st_pause_count = SDL_GetTicks();
+ st_pause_count = SDL_GetTicks();
}
void st_pause_ticks_stop(void)
{
-st_pause_ticks += SDL_GetTicks() - st_pause_count;
-st_pause_count = 0;
+ st_pause_ticks += SDL_GetTicks() - st_pause_count;
+ st_pause_count = 0;
}
void timer_init(timer_type* ptimer, int st_ticks)
{
ptimer->period = 0;
ptimer->time = 0;
-
+
if(st_ticks == YES)
- ptimer->get_ticks = st_get_ticks;
+ ptimer->get_ticks = st_get_ticks;
else
- ptimer->get_ticks = SDL_GetTicks;
-
+ ptimer->get_ticks = SDL_GetTicks;
+
}
void timer_start(timer_type* ptimer, unsigned int period)
void timer_stop(timer_type* ptimer)
{
-if(ptimer->get_ticks == st_get_ticks)
- timer_init(ptimer,YES);
-else
- timer_init(ptimer,NO);
+ if(ptimer->get_ticks == st_get_ticks)
+ timer_init(ptimer,YES);
+ else
+ timer_init(ptimer,NO);
}
int timer_check(timer_type* ptimer)
{
return (ptimer->get_ticks() - ptimer->time);
}
+
+int timer_fwrite(timer_type* ptimer, FILE* fi)
+{
+ unsigned int diff_ticks;
+ int tick_mode;
+ if(ptimer->time != 0)
+ diff_ticks = ptimer->get_ticks() - ptimer->time;
+ else
+ diff_ticks = 0;
+
+ fwrite(&ptimer->period,sizeof(unsigned int),1,fi);
+ fwrite(&diff_ticks,sizeof(unsigned int),1,fi);
+ if(ptimer->get_ticks == st_get_ticks)
+ tick_mode = YES;
+ else
+ tick_mode = NO;
+ fwrite(&tick_mode,sizeof(unsigned int),1,fi);
+}
+
+int timer_fread(timer_type* ptimer, FILE* fi)
+{
+ unsigned int diff_ticks;
+ int tick_mode;
+ fread(&ptimer->period,sizeof(unsigned int),1,fi);
+ fread(&diff_ticks,sizeof(unsigned int),1,fi);
+ fread(&tick_mode,sizeof(unsigned int),1,fi);
+ if(tick_mode == YES)
+ ptimer->get_ticks = st_get_ticks;
+ else
+ ptimer->get_ticks = SDL_GetTicks;
+ if(diff_ticks != 0)
+ ptimer->time = ptimer->get_ticks() - diff_ticks;
+ else
+ ptimer->time = 0;
+
+}
+
======================================================================*/
int timer_get_left(timer_type* ptimer);
int timer_get_gone(timer_type* ptimer);
+int timer_fwrite(timer_type* ptimer, FILE* fi);
+int timer_fread(timer_type* ptimer, FILE* fi);
#endif /*SUPERTUX_TIMER_H*/
int done;
int scroll, speed;
timer_type timer;
- int n,d;
+ int n,d,e;
int length;
FILE* fi;
char temp[1024];
done = 0;
n = d = 0;
+ e = -20;
length = names.num_items;
else if(names.item[i][0] == ' ')
text_drawf(&white_text, names.item[i], 0, 60+screen->h+(n*18)+(d*18)-scroll, A_HMIDDLE, A_TOP, 1, NO_UPDATE);
else if(names.item[i+1][0] == '-' || names.item[i][0] == '-')
- text_drawf(&white_big_text, names.item[i], 0, 60+screen->h+(n*18)+(d*18)-scroll, A_HMIDDLE, A_TOP, 1, NO_UPDATE);
+ text_drawf(&white_big_text, names.item[i], 0, 60+screen->h+(n*18)+(d*18)-scroll, A_HMIDDLE, A_TOP, 3+e%7, NO_UPDATE);
else
- text_drawf(&blue_text, names.item[i], 0, 60+screen->h+(n*18)+(d*18)-scroll, A_HMIDDLE, A_TOP, 1, NO_UPDATE);
+ text_drawf(&blue_text, names.item[i], 0 + e % 20, 60+screen->h+(n*18)+(d*18)-scroll, A_HMIDDLE, A_TOP, 1, NO_UPDATE);
}
}
-
+ if(e == 20)
+ {
+ e = -19;
+ }
+ e++;
+
+
texture_draw_part(&bkg_title, 0, 0, 0, 0, 640, 130, NO_UPDATE);
flipscreen();
if(scroll < 0)
scroll = 0;
- SDL_Delay(20);
+ SDL_Delay(35);
if(timer_get_left(&timer) < 0)
{