if (time_left.check())
{
/* are we low on time ? */
- if ((timer_get_left(&time_left) < TIME_WARNING)
+ if (time_left.get_left() < TIME_WARNING
&& (get_current_music() != HURRYUP_MUSIC)) /* play the fast music */
{
set_current_music(HURRYUP_MUSIC);
if(show_fps)
{
++fps_cnt;
- fps_fps = (1000.0 / (float)timer_get_gone(&fps_timer)) * (float)fps_cnt;
+ fps_fps = (1000.0 / (float)fps_timer.get_gone()) * (float)fps_cnt;
if(!fps_timer.check())
{
text_draw(&white_text,"Press ESC To Return",0,20,1);
}
- if (timer_get_left(&time_left) > TIME_WARNING || (global_frame_counter % 10) < 5)
+ if (time_left.get_left() > TIME_WARNING || (global_frame_counter % 10) < 5)
{
- sprintf(str, "%d", timer_get_left(&time_left) / 1000 );
+ sprintf(str, "%d", time_left.get_left() / 1000 );
text_draw(&white_text, "TIME", 224, 0, 1);
text_draw(&gold_text, str, 304, 0, 1);
}
/* Draw things: */
- if (timer_get_gone(&timer) < 2000 && scene == 0)
+ if (timer.get_gone() < 2000 && scene == 0)
{
++scene;
/* Gown and tux sitting: */
}
- if (timer_get_gone(&timer) >= 2000 && scene == 1)
+ if (timer.get_gone() >= 2000 && scene == 1)
{
++scene;
/* Helicopter begins to fly in: */
}
- if (timer_get_gone(&timer) >= 2000 && timer_get_gone(&timer) < 4000)
+ if (timer.get_gone() >= 2000 && timer.get_gone() < 4000)
{
/* Helicopter flying in: */
texture_draw_part(&bkgd,0,32, 0, 32, screen->w, (copter[0].h));
texture_draw(&copter[i % 2],
- (float)(timer_get_gone(&timer) - 2000) / 5 - (copter[0].w), 32);
+ (float)(timer.get_gone() - 2000) / 5 - (copter[0].w), 32);
update_rect(screen, 0, 32, screen->w, (copter[0].h));
}
- if (timer_get_gone(&timer) >= 2500 && scene == 2)
+ if (timer.get_gone() >= 2500 && scene == 2)
{
++scene;
/* Gown notices something... */
}
- if (timer_get_gone(&timer) >= 3500 && scene == 3)
+ if (timer.get_gone() >= 3500 && scene == 3)
{
++scene;
/* Gown realizes it's bad! */
}
- if (timer_get_gone(&timer) >= 4000 && timer_get_gone(&timer) < 8000)
+ if (timer.get_gone() >= 4000 && timer.get_gone() < 8000)
{
/* Helicopter sits: */
texture_draw_part(&bkgd,0,32, 0, 32, screen->w, (copter[0].h));
}
- if (timer_get_gone(&timer) >= 5000 && scene == 4)
+ if (timer.get_gone() >= 5000 && scene == 4)
{
++scene;
/* Tux realizes something's happening: */
}
- if (timer_get_gone(&timer) >= 5000 && timer_get_gone(&timer) <= 8000)
+ if (timer.get_gone() >= 5000 && timer.get_gone() <= 8000)
{
/* Beam gown up! */
texture_draw_part(&gown_upset,src.x,src.y,dest.x,dest.y,dest.w,dest.h);
- height[j] = 400 + rand() % 10 - (int)(300. * ((float)(timer_get_gone(&timer) - 5000)/(float)3000.));
+ height[j] = 400 + rand() % 10 - (int)(300. * ((float)(timer.get_gone() - 5000)/(float)3000.));
if(height[j] < 105)
height[j] = 105;
}
}
- if (timer_get_gone(&timer) >= 8000 && scene == 5)
+ if (timer.get_gone() >= 8000 && scene == 5)
{
texture_draw_part(&bkgd,
310, 32 + (copter[0].h), 310,
}
- if (timer_get_gone(&timer) >= 8000 && timer_get_gone(&timer) <= 8250)
+ if (timer.get_gone() >= 8000 && timer.get_gone() <= 8250)
{
/* Helicopter starting to speed off: */
}
- if (timer_get_gone(&timer) >= 8250)
+ if (timer.get_gone() >= 8250)
{
/* Helicopter speeding off: */
texture_draw_part(&bkgd, 0, 32, 0, 32, screen->w, (copter_stretch.h));
texture_draw(&copter_stretch,
- (timer_get_gone(&timer) - 8250) /*(i - (8250 / FPS)) * 30*/ + 400 - (copter[0].w),
+ (timer.get_gone() - 8250) /*(i - (8250 / FPS)) * 30*/ + 400 - (copter[0].w),
32);
update_rect(screen, 0, 32, screen->w, (copter_stretch.h));
{
if(select_tilegroup_menu_effect.check())
{
- select_tilegroup_menu->set_pos(screen->w - 64 + timer_get_left(&select_tilegroup_menu_effect),82,-0.5,0.5);
+ select_tilegroup_menu->set_pos(screen->w - 64 + select_tilegroup_menu_effect.get_left(),
+ 82,-0.5,0.5);
}
else
select_tilegroup_menu->set_pos(screen->w - 64,82,-0.5,0.5);
{
int effect_time = 0;
if(effect.check())
- effect_time = timer_get_left(&effect) / 4;
+ effect_time = effect.get_left() / 4;
effect_offset = (index % 2) ? effect_time : -effect_time;
}
cur_state = state_before_click;
}
- if(timer_get_left(&timer) < 0 && tot_frames > 1)
+ if(timer.get_left() < 0 && tot_frames > 1)
{
cur_frame++;
if(cur_frame++ >= tot_frames)
*/
// FIXME: Move this to gamesession
- if (timer_get_left(&GameSession::current()->time_left) < TIME_WARNING)
+ if (GameSession::current()->time_left.get_left() < TIME_WARNING)
{
/* yes, we are in hurry
stop the herring_song, prepare to play the correct
return false;
}
-int timer_get_left(timer_type* ptimer)
+int
+timer_type::get_left()
{
- return (ptimer->period - (ptimer->get_ticks() - ptimer->time));
+ return (period - (get_ticks() - time));
}
-int timer_get_gone(timer_type* ptimer)
+int
+timer_type::get_gone()
{
- return (ptimer->get_ticks() - ptimer->time);
+ return (get_ticks() - time);
}
-void timer_fwrite(timer_type* ptimer, FILE* fi)
+void
+timer_type::fwrite(FILE* fi)
{
unsigned int diff_ticks;
int tick_mode;
- if(ptimer->time != 0)
- diff_ticks = ptimer->get_ticks() - ptimer->time;
+ if(time != 0)
+ diff_ticks = get_ticks() - 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)
+ ::fwrite(&period,sizeof(unsigned int),1,fi);
+ ::fwrite(&diff_ticks,sizeof(unsigned int),1,fi);
+ if(get_ticks == st_get_ticks)
tick_mode = true;
else
tick_mode = false;
- fwrite(&tick_mode,sizeof(unsigned int),1,fi);
+ ::fwrite(&tick_mode,sizeof(unsigned int),1,fi);
}
-void timer_fread(timer_type* ptimer, FILE* fi)
+void
+timer_type::fread(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);
+
+ ::fread(&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)
- ptimer->get_ticks = st_get_ticks;
+ get_ticks = st_get_ticks;
else
- ptimer->get_ticks = SDL_GetTicks;
+ get_ticks = SDL_GetTicks;
if (diff_ticks != 0)
- ptimer->time = ptimer->get_ticks() - diff_ticks;
+ time = get_ticks() - diff_ticks;
else
- ptimer->time = 0;
+ time = 0;
}
+/* EOF */
======================================================================*/
int check();
int started();
+
+ /*======================================================================
+ int timer_get_left(timer_type* ptimer);
+
+ param : pointer to a timer that you want to get the time left
+ return: the time left (in millisecond)
+ note : the returned value can be negative
+ ======================================================================*/
+ int get_left();
+
+ int get_gone();
+ void fwrite(FILE* fi);
+ void fread(FILE* fi);
};
-/*======================================================================
- int timer_get_left(timer_type* ptimer);
-
- param : pointer to a timer that you want to get the time left
- return: the time left (in millisecond)
- note : the returned value can be negative
- ======================================================================*/
-int timer_get_left(timer_type* ptimer);
-int timer_get_gone(timer_type* ptimer);
-void timer_fwrite(timer_type* ptimer, FILE* fi);
-void timer_fread(timer_type* ptimer, FILE* fi);
#endif /*SUPERTUX_TIMER_H*/
SDL_Delay(35);
- if(timer_get_left(&timer) < 0)
+ if(timer.get_left() < 0)
{
frame++;
timer.start(50);