From: Ingo Ruhnke Date: Sun, 11 Apr 2004 16:23:08 +0000 (+0000) Subject: started to convert timer into a class X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=e147eea9f117721dbcf79d1465452b6ae91fe33c;p=supertux.git started to convert timer into a class SVN-Revision: 479 --- diff --git a/src/badguy.cpp b/src/badguy.cpp index 2c803c95d..b36e075dc 100644 --- a/src/badguy.cpp +++ b/src/badguy.cpp @@ -148,7 +148,7 @@ BadGuy::init(float x, float y, BadGuyKind kind_) animation_offset = 0; texture_left = texture_right = 0; physic.reset(); - timer_init(&timer, true); + timer.init(true); if(kind == BAD_BSOD) { physic.set_velocity(-1.3, 0); @@ -215,7 +215,7 @@ BadGuy::action_bsod(float frame_ratio) } // Handle dying timer: - if (dying == DYING_SQUISHED && !timer_check(&timer)) + if (dying == DYING_SQUISHED && !timer.check()) { /* Remove it if time's up: */ remove_me(); @@ -296,7 +296,7 @@ BadGuy::action_laptop(float frame_ratio) /* Handle mode timer: */ if (mode == FLAT) { - if(!timer_check(&timer)) + if(!timer.check()) { mode = NORMAL; set_texture(img_laptop_left, img_laptop_right, 4, 5); @@ -442,13 +442,13 @@ BadGuy::action_bomb(float frame_ratio) if(mode == NORMAL) { mode = BOMB_TICKING; - timer_start(&timer, TICKINGTIME); - } else if(!timer_check(&timer)) { + timer.start(TICKINGTIME); + } else if(!timer.check()) { if(mode == BOMB_TICKING) { mode = BOMB_EXPLODE; set_texture(img_mrbomb_explosion, img_mrbomb_explosion, 1); dying = DYING_NOT; // now the bomb hurts - timer_start(&timer, EXPLODETIME); + timer.start(EXPLODETIME); } else if(mode == BOMB_EXPLODE) { remove_me(); return; @@ -473,12 +473,12 @@ BadGuy::action_stalactite(float frame_ratio) // near if(tux.base.x + 32 > base.x - RANGE && tux.base.x < base.x + 32 + RANGE && tux.base.y + tux.base.height > base.y) { - timer_start(&timer, SHAKETIME); + timer.start(SHAKETIME); mode = STALACTITE_SHAKING; } } if(mode == STALACTITE_SHAKING) { base.x = old_base.x + (rand() % 6) - 3; // TODO this could be done nicer... - if(!timer_check(&timer)) { + if(!timer.check()) { mode = STALACTITE_FALL; } } else if(mode == STALACTITE_FALL) { @@ -486,7 +486,7 @@ BadGuy::action_stalactite(float frame_ratio) /* Destroy if we collides with land */ if(issolid(base.x+base.width/2, base.y+base.height)) { - timer_start(&timer, 2000); + timer.start(2000); dying = DYING_SQUISHED; mode = FLAT; set_texture(img_stalactite_broken, img_stalactite_broken, 1); @@ -498,7 +498,7 @@ BadGuy::action_stalactite(float frame_ratio) // move physic.apply(frame_ratio, base.x, base.y); - if(dying == DYING_SQUISHED && !timer_check(&timer)) + if(dying == DYING_SQUISHED && !timer.check()) remove_me(); } @@ -527,9 +527,9 @@ BadGuy::action_fish(float frame_ratio) set_texture(0, 0); physic.set_velocity(0, 0); physic.enable_gravity(false); - timer_start(&timer, WAITTIME); + timer.start(WAITTIME); } - else if(mode == FISH_WAIT && !timer_check(&timer)) + else if(mode == FISH_WAIT && !timer.check()) { // jump again set_texture(img_fish, img_fish, 2, 1.5); @@ -570,7 +570,7 @@ BadGuy::action_bouncingsnowball(float frame_ratio) collision_swept_object_map(&old_base, &base); // Handle dying timer: - if (dying == DYING_SQUISHED && !timer_check(&timer)) + if (dying == DYING_SQUISHED && !timer.check()) { /* Remove it if time's up: */ remove_me(); @@ -588,10 +588,10 @@ BadGuy::action_flyingsnowball(float frame_ratio) if(dying == DYING_NOT && mode == NORMAL) { mode = FLY_UP; physic.set_velocity(physic.get_velocity_x(), FLYINGSPEED); - timer_start(&timer, DIRCHANGETIME/2); + timer.start(DIRCHANGETIME/2); } - if(dying == DYING_NOT && !timer_check(&timer)) { + if(dying == DYING_NOT && !timer.check()) { if(mode == FLY_UP) { mode = FLY_DOWN; physic.set_velocity(physic.get_velocity_x(), -FLYINGSPEED); @@ -599,7 +599,7 @@ BadGuy::action_flyingsnowball(float frame_ratio) mode = FLY_UP; physic.set_velocity(physic.get_velocity_x(), FLYINGSPEED); } - timer_start(&timer, DIRCHANGETIME); + timer.start(DIRCHANGETIME); } if(dying != DYING_NOT) @@ -610,7 +610,7 @@ BadGuy::action_flyingsnowball(float frame_ratio) collision_swept_object_map(&old_base, &base); // Handle dying timer: - if (dying == DYING_SQUISHED && !timer_check(&timer)) + if (dying == DYING_SQUISHED && !timer.check()) { /* Remove it if time's up: */ remove_me(); @@ -797,7 +797,7 @@ BadGuy::squish_me(Player* player) player_status.score_multiplier++; dying = DYING_SQUISHED; - timer_start(&timer, 2000); + timer.start(2000); physic.set_velocity(0, 0); } @@ -831,7 +831,7 @@ BadGuy::squish(Player* player) set_texture(img_laptop_flat_left, img_laptop_flat_right, 1); physic.set_velocity(0, physic.get_velocity_y()); - timer_start(&timer, 4000); + timer.start(4000); } else if (mode == FLAT) { /* Kick! */ play_sound(sounds[SND_KICK], SOUND_CENTER_SPEAKER); diff --git a/src/button.cpp b/src/button.cpp index 54f889e7e..c348a2368 100644 --- a/src/button.cpp +++ b/src/button.cpp @@ -21,7 +21,7 @@ timer_type Button::popup_timer; Button::Button(std::string icon_file, std::string ninfo, SDLKey nshortcut, int x, int y, int mw, int mh) { - timer_init(&popup_timer,false); + popup_timer.init(false); char filename[1024]; @@ -90,7 +90,7 @@ void Button::change_icon(std::string icon_file, int mw, int mh) void Button::draw() { if(state == BUTTON_HOVER) - if(!timer_check(&popup_timer)) + if(!popup_timer.check()) show_info = true; fillrect(rect.x,rect.y,rect.w,rect.h,75,75,75,200); @@ -181,7 +181,7 @@ void Button::event(SDL_Event &event) } else if(event.type == SDL_MOUSEMOTION) { - timer_start(&popup_timer, 1500); + popup_timer.start(1500); if(show_info) { diff --git a/src/gameloop.cpp b/src/gameloop.cpp index d2aadba86..e99cee020 100644 --- a/src/gameloop.cpp +++ b/src/gameloop.cpp @@ -67,8 +67,8 @@ GameSession::GameSession(const std::string& filename) world = new World; // &::global_world; - timer_init(&fps_timer, true); - timer_init(&frame_timer, true); + fps_timer.init(true); + frame_timer.init(true); world->load(filename); } @@ -83,8 +83,8 @@ GameSession::GameSession(const std::string& subset_, int levelnb_, int mode) world = new World; // &::global_world; - timer_init(&fps_timer, true); - timer_init(&frame_timer, true); + fps_timer.init(true); + frame_timer.init(true); st_gl_mode = mode; @@ -116,7 +116,7 @@ GameSession::GameSession(const std::string& subset_, int levelnb_, int mode) if(st_gl_mode == ST_GL_PLAY || st_gl_mode == ST_GL_LOAD_LEVEL_FILE) levelintro(); - timer_init(&time_left,true); + time_left.init(true); start_timers(); if(st_gl_mode == ST_GL_LOAD_GAME) @@ -156,7 +156,7 @@ GameSession::levelintro(void) void GameSession::start_timers() { - timer_start(&time_left, world->get_level()->time_left*1000); + time_left.start(world->get_level()->time_left*1000); st_pause_ticks_init(); update_time = st_get_ticks(); } @@ -261,7 +261,7 @@ GameSession::process_events() break; case SDLK_INSERT: if(debug_mode) - timer_start(&tux.invincible_timer,TUX_INVINCIBLE_TIME); + tux.invincible_timer.start(TUX_INVINCIBLE_TIME); break; case SDLK_l: if(debug_mode) @@ -473,8 +473,10 @@ GameSession::run() global_frame_counter = 0; game_pause = false; - timer_init(&fps_timer,true); - timer_init(&frame_timer,true); + + fps_timer.init(true); + frame_timer.init(true); + last_update_time = st_get_ticks(); fps_cnt = 0; @@ -500,9 +502,9 @@ GameSession::run() if(frame_ratio > 1.5) /* Quick hack to correct the unprecise CPU clocks a little bit. */ frame_ratio = 1.5 + (frame_ratio - 1.5) * 0.85; - if(!timer_check(&frame_timer)) + if(!frame_timer.check()) { - timer_start(&frame_timer,25); + frame_timer.start(25); ++global_frame_counter; } @@ -604,7 +606,7 @@ GameSession::run() SDL_Delay((11 - (update_time - last_update_time))/2);*/ /* Handle time: */ - if (timer_check(&time_left)) + if (time_left.check()) { /* are we low on time ? */ if ((timer_get_left(&time_left) < TIME_WARNING) @@ -624,9 +626,9 @@ GameSession::run() ++fps_cnt; fps_fps = (1000.0 / (float)timer_get_gone(&fps_timer)) * (float)fps_cnt; - if(!timer_check(&fps_timer)) + if(!fps_timer.check()) { - timer_start(&fps_timer,1000); + fps_timer.start(1000); fps_cnt = 0; } } diff --git a/src/gameobjs.cpp b/src/gameobjs.cpp index 228814fa1..db4b38639 100644 --- a/src/gameobjs.cpp +++ b/src/gameobjs.cpp @@ -59,8 +59,8 @@ BrokenBrick::init(Tile* tile_, float x, float y, float xm, float ym) base.xm = xm; base.ym = ym; - timer_init(&timer, true); - timer_start(&timer,200); + timer.init(true); + timer.start(200); } void @@ -69,7 +69,7 @@ BrokenBrick::action(double frame_ratio) base.x = base.x + base.xm * frame_ratio; base.y = base.y + base.ym * frame_ratio; - if (!timer_check(&timer)) + if (!timer.check()) World::current()->broken_bricks.erase(static_cast::iterator>(this)); } @@ -159,8 +159,8 @@ FloatingScore::init(float x, float y, int s) { base.x = x; base.y = y - 16; - timer_init(&timer,true); - timer_start(&timer,1000); + timer.init(true); + timer.start(1000); value = s; } @@ -169,7 +169,7 @@ FloatingScore::action(double frame_ratio) { base.y = base.y - 2 * frame_ratio; - if(!timer_check(&timer)) + if(!timer.check()) World::current()->floating_scores.erase(static_cast::iterator>(this)); } diff --git a/src/globals.cpp b/src/globals.cpp index fc4bc6198..e8419f5b9 100644 --- a/src/globals.cpp +++ b/src/globals.cpp @@ -41,14 +41,15 @@ int wait_for_event(SDL_Event& event,unsigned int min_delay, unsigned int max_del int i; timer_type maxdelay; timer_type mindelay; - timer_init(&maxdelay,false); - timer_init(&mindelay,false); + + maxdelay.init(false); + mindelay.init(false); if(max_delay < min_delay) max_delay = min_delay; - timer_start(&maxdelay,max_delay); - timer_start(&mindelay,min_delay); + maxdelay.start(max_delay); + mindelay.start(min_delay); if(empty_events) while (SDL_PollEvent(&event)) @@ -56,11 +57,11 @@ int wait_for_event(SDL_Event& event,unsigned int min_delay, unsigned int max_del /* Handle events: */ - for(i = 0; timer_check(&maxdelay) || !i; ++i) + for(i = 0; maxdelay.check() || !i; ++i) { while (SDL_PollEvent(&event)) { - if(!timer_check(&mindelay)) + if(!mindelay.check()) { if (event.type == SDL_QUIT) { diff --git a/src/intro.cpp b/src/intro.cpp index d005e47f0..66fb3dbdc 100644 --- a/src/intro.cpp +++ b/src/intro.cpp @@ -89,10 +89,10 @@ int intro(void) scene = 0; i = 0; - timer_init(&timer, false); - timer_start(&timer,10000); + timer.init(false); + timer.start(10000); - while (timer_check(&timer) && !done && !quit) + while (timer.check() && !done && !quit) { diff --git a/src/leveleditor.cpp b/src/leveleditor.cpp index b800c12c4..a3a741f1f 100644 --- a/src/leveleditor.cpp +++ b/src/leveleditor.cpp @@ -156,7 +156,7 @@ int leveleditor(int levelnb) if(current_menu == select_tilegroup_menu) { - if(timer_check(&select_tilegroup_menu_effect)) + 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); } @@ -354,7 +354,7 @@ int le_init() texture_load(&le_selection, datadir + "/images/leveleditor/select.png", USE_ALPHA); - timer_init(&select_tilegroup_menu_effect,false); + select_tilegroup_menu_effect.init(false); /* Load buttons */ le_save_level_bt = new Button("/images/icons/save.png","Save level", SDLK_F6,screen->w-64,32); @@ -988,7 +988,7 @@ void le_checkevents() if(le_tilegroup_bt->get_state() == BUTTON_CLICKED) { Menu::set_current(select_tilegroup_menu); - timer_start(&select_tilegroup_menu_effect,200); + select_tilegroup_menu_effect.start(200); select_tilegroup_menu->set_pos(screen->w - 64,100,-0.5,0.5); show_menu = true; } diff --git a/src/menu.cpp b/src/menu.cpp index 99073f500..1f38a924c 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -64,7 +64,7 @@ Menu::set_current(Menu* pmenu) if(tmp->last_menu != pmenu) current_menu->last_menu = tmp; - timer_start(&pmenu->effect, 500); + pmenu->effect.start(500); } } @@ -136,13 +136,13 @@ Menu::Menu() active_item = 0; last_menu = 0; item = NULL; - timer_init(&effect,false); + effect.init(false); } void Menu::set_pos(int x, int y, float rw, float rh) { - pos_x = x + (int)((float)width() * rw); - pos_y = y + (int)((float)height() * rh); + pos_x = x + (int)((float)width() * rw); + pos_y = y + (int)((float)height() * rh); } void @@ -331,7 +331,7 @@ Menu::draw_item(int index, // Position of the current item in the menu int effect_offset = 0; { int effect_time = 0; - if(timer_check(&effect)) + if(effect.check()) effect_time = timer_get_left(&effect) / 4; effect_offset = (index % 2) ? effect_time : -effect_time; diff --git a/src/mousecursor.cpp b/src/mousecursor.cpp index 0d5f829f4..9814fa84b 100644 --- a/src/mousecursor.cpp +++ b/src/mousecursor.cpp @@ -21,8 +21,8 @@ MouseCursor::MouseCursor(std::string cursor_file, int frames) cur_frame = 0; tot_frames = frames; - timer_init(&timer, false); - timer_start(&timer,MC_FRAME_PERIOD); + timer.init(false); + timer.start(MC_FRAME_PERIOD); SDL_ShowCursor(SDL_DISABLE); } @@ -70,7 +70,7 @@ void MouseCursor::draw() if(cur_frame++ >= tot_frames) cur_frame = 0; - timer_start(&timer,MC_FRAME_PERIOD); + timer.start(MC_FRAME_PERIOD); } texture_draw_part(&cursor, w*cur_frame, h*cur_state , x, y, w, h); diff --git a/src/player.cpp b/src/player.cpp index af3df7bea..0af32406b 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -95,10 +95,10 @@ Player::init() keymap.right = SDLK_RIGHT; keymap.fire = SDLK_LCTRL; - timer_init(&invincible_timer,true); - timer_init(&skidding_timer,true); - timer_init(&safe_timer,true); - timer_init(&frame_timer,true); + invincible_timer.init(true); + skidding_timer.init(true); + safe_timer.init(true); + frame_timer.init(true); physic.reset(); } @@ -149,10 +149,11 @@ Player::level_begin() player_input_init(&input); - timer_init(&invincible_timer,true); - timer_init(&skidding_timer,true); - timer_init(&safe_timer,true); - timer_init(&frame_timer,true); + invincible_timer.init(true); + skidding_timer.init(true); + safe_timer.init(true); + frame_timer.init(true); + physic.reset(); } @@ -247,13 +248,13 @@ Player::action(double frame_ratio) } - timer_check(&safe_timer); + safe_timer.check(); /* ---- DONE HANDLING TUX! --- */ /* Handle invincibility timer: */ - if (get_current_music() == HERRING_MUSIC && !timer_check(&invincible_timer)) + if (get_current_music() == HERRING_MUSIC && !invincible_timer.check()) { /* no, we are no more invincible @@ -320,15 +321,15 @@ Player::handle_horizontal_input(int newdir) // skid if we're too fast if(dir != newdir && on_ground() && fabs(physic.get_velocity_x()) > SKID_XM - && !timer_started(&skidding_timer)) + && !skidding_timer.started()) { - timer_start(&skidding_timer, SKID_TIME); + skidding_timer.start(SKID_TIME); play_sound(sounds[SND_SKID], SOUND_CENTER_SPEAKER); return; } if ((newdir ? (vx < 0) : (vx > 0)) && !isice(base.x, base.y + base.height) && - !timer_started(&skidding_timer)) + !skidding_timer.started()) { //vx = 0; } @@ -521,9 +522,9 @@ Player::handle_input() /* (Tux): */ - if(!timer_check(&frame_timer)) + if(!frame_timer.check()) { - timer_start(&frame_timer,25); + frame_timer.start(25); if (input.right == UP && input.left == UP) { frame_main = 1; @@ -578,11 +579,11 @@ Player::grabdistros() void Player::draw() { - if (!timer_started(&safe_timer) || (global_frame_counter % 2) == 0) + if (!safe_timer.started() || (global_frame_counter % 2) == 0) { if (size == SMALL) { - if (timer_started(&invincible_timer)) + if (invincible_timer.started()) { /* Draw cape: */ @@ -644,7 +645,7 @@ Player::draw() } else { - if (timer_started(&invincible_timer)) + if (invincible_timer.started()) { /* Draw cape: */ if (dir == RIGHT) @@ -663,7 +664,7 @@ Player::draw() { if (!duck) { - if (!timer_started(&skidding_timer)) + if (!skidding_timer.started()) { if (!jumping || physic.get_velocity_y() > 0) { @@ -724,7 +725,7 @@ Player::draw() if (!duck) { - if (!timer_started(&skidding_timer)) + if (!skidding_timer.started()) { if (!jumping || physic.get_velocity_y() > 0) { @@ -798,7 +799,7 @@ Player::collision(void* p_c_object, int c_object) /* Hurt the player if he just touched it: */ if (!pbad_c->dying && !dying && - !timer_started(&safe_timer) && + !safe_timer.started() && pbad_c->mode != HELD) { if (pbad_c->mode == FLAT && input.fire == DOWN) @@ -818,7 +819,7 @@ Player::collision(void* p_c_object, int c_object) else { /* Hurt if you get hit by kicked laptop: */ - if (!timer_started(&invincible_timer)) + if (!invincible_timer.started()) { kill(SHRINK); } @@ -834,7 +835,7 @@ Player::collision(void* p_c_object, int c_object) } else { - if (!timer_started(&invincible_timer )) + if (!invincible_timer.started()) { kill(SHRINK); } @@ -869,7 +870,7 @@ Player::kill(int mode) size = SMALL; base.height = 32; - timer_start(&safe_timer,TUX_SAFE_TIME); + safe_timer.start(TUX_SAFE_TIME); } else { diff --git a/src/special.cpp b/src/special.cpp index 787537fce..59c6d6e30 100644 --- a/src/special.cpp +++ b/src/special.cpp @@ -270,7 +270,7 @@ Upgrade::collision(void* p_c_object, int c_object) else if (kind == UPGRADE_HERRING) { play_sound(sounds[SND_HERRING], SOUND_CENTER_SPEAKER); - timer_start(&pplayer->invincible_timer,TUX_INVINCIBLE_TIME); + pplayer->invincible_timer.start(TUX_INVINCIBLE_TIME); /* play the herring song ^^ */ if (get_current_music() != HURRYUP_MUSIC) { diff --git a/src/timer.cpp b/src/timer.cpp index 52b1b0861..9848f2928 100644 --- a/src/timer.cpp +++ b/src/timer.cpp @@ -44,41 +44,46 @@ return; st_pause_count = 0; } -void timer_init(timer_type* ptimer, bool st_ticks) +void +timer_type::init(bool st_ticks) { - ptimer->period = 0; - ptimer->time = 0; - ptimer->get_ticks = st_ticks ? st_get_ticks : SDL_GetTicks; + period = 0; + time = 0; + get_ticks = st_ticks ? st_get_ticks : SDL_GetTicks; } -void timer_start(timer_type* ptimer, unsigned int period) +void +timer_type::start(unsigned int period_) { - ptimer->time = ptimer->get_ticks(); - ptimer->period = period; + time = get_ticks(); + period = period_; } -void timer_stop(timer_type* ptimer) +void +timer_type::stop() { - if(ptimer->get_ticks == st_get_ticks) - timer_init(ptimer,true); + if(get_ticks == st_get_ticks) + init(true); else - timer_init(ptimer,false); + init(false); } -int timer_check(timer_type* ptimer) +int +timer_type::check() { - if((ptimer->time != 0) && (ptimer->time + ptimer->period > ptimer->get_ticks())) + if((time != 0) && (time + period > get_ticks())) return true; else { - ptimer->time = 0; + time = 0; return false; } } -int timer_started(timer_type* ptimer) +int +timer_type::started() { - if(ptimer->time != 0) + if(time != 0) return true; else return false; diff --git a/src/timer.h b/src/timer.h index 3328e80ac..8c69b3d67 100644 --- a/src/timer.h +++ b/src/timer.h @@ -13,40 +13,43 @@ #ifndef SUPERTUX_TIMER_H #define SUPERTUX_TIMER_H -/* Timer type */ -struct timer_type -{ - unsigned int period; - unsigned int time; - unsigned int (*get_ticks) (void); -}; - extern unsigned int st_pause_ticks, st_pause_count; unsigned int st_get_ticks(void); void st_pause_ticks_init(void); void st_pause_ticks_start(void); void st_pause_ticks_stop(void); -void timer_init(timer_type* ptimer, bool st_ticks); -void timer_start(timer_type* ptimer, unsigned int period); -void timer_stop(timer_type* ptimer); -/*====================================================================== - int timer_check(timer_type* ptimer); + +class timer_type +{ + public: + unsigned int period; + unsigned int time; + unsigned int (*get_ticks) (void); + + public: + void init(bool st_ticks); + void start(unsigned int period); + void stop(); + + /*====================================================================== + int timer_check(timer_type* ptimer); - param : pointer to a timer which needs to be checked - return: NO = the timer is not started - or it is over - YES = otherwise -======================================================================*/ -int timer_check(timer_type* ptimer); -int timer_started(timer_type* ptimer); + param : pointer to a timer which needs to be checked + return: NO = the timer is not started + or it is over + YES = otherwise + ======================================================================*/ + int check(); + int started(); +}; /*====================================================================== - int timer_get_left(timer_type* ptimer); + 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 -======================================================================*/ + 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); @@ -54,3 +57,6 @@ void timer_fread(timer_type* ptimer, FILE* fi); #endif /*SUPERTUX_TIMER_H*/ +/* Local Variables: */ +/* mode:c++ */ +/* End */ diff --git a/src/title.cpp b/src/title.cpp index 3acba935f..016b13df3 100644 --- a/src/title.cpp +++ b/src/title.cpp @@ -98,7 +98,7 @@ void draw_demo(GameSession* session, double frame_ratio) global_frame_counter++; tux->key_event(SDLK_RIGHT,DOWN); - if(timer_check(&random_timer)) + if(random_timer.check()) { if(walking) tux->key_event(SDLK_UP,UP); @@ -107,7 +107,7 @@ void draw_demo(GameSession* session, double frame_ratio) } else { - timer_start(&random_timer, rand() % 3000 + 3000); + random_timer.start(rand() % 3000 + 3000); walking = !walking; } @@ -139,7 +139,7 @@ bool title(void) string_list_type level_subsets; st_subset subset; level_subsets = dsubdirs("/levels", "info"); - timer_init(&random_timer, true); + random_timer.init(true); walking = true; @@ -173,7 +173,7 @@ bool title(void) load_hs(); update_time = st_get_ticks(); - timer_start(&random_timer, rand() % 2000 + 2000); + random_timer.start(rand() % 2000 + 2000); while (!done) { @@ -416,8 +416,8 @@ void display_credits() } - timer_init(&timer, SDL_GetTicks()); - timer_start(&timer, 50); + timer.init(SDL_GetTicks()); + timer.start(50); scroll = 0; speed = 2; @@ -505,7 +505,7 @@ void display_credits() if(timer_get_left(&timer) < 0) { frame++; - timer_start(&timer, 50); + timer.start(50); } } string_list_free(&names);