[Super-tux-commit] supertux/src worldmap.cpp,1.58,1.59 worldmap.h,1.27,1.28
Brought to you by:
wkendrick
From: Ingo R. <gr...@us...> - 2004-04-27 18:44:27
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4262 Modified Files: worldmap.cpp worldmap.h Log Message: - made worldmap CPU independend, needs testing Index: worldmap.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.cpp,v retrieving revision 1.58 retrieving revision 1.59 diff -u -d -r1.58 -r1.59 --- worldmap.cpp 27 Apr 2004 15:15:18 -0000 1.58 +++ worldmap.cpp 27 Apr 2004 18:44:19 -0000 1.59 @@ -627,7 +627,7 @@ } void -WorldMap::update() +WorldMap::update(float delta) { if (enter_level && !tux->is_moving()) { @@ -674,7 +674,7 @@ if (dir != NONE) { tux->set_direction(dir); - tux->update(0.33f); + tux->update(delta); } std::cout << "Walk to dir: " << dir << std::endl; @@ -723,7 +723,7 @@ else { tux->set_direction(input_direction); - tux->update(0.33f); + tux->update(delta); } Menu* menu = Menu::current(); @@ -853,33 +853,46 @@ song = music_manager->load_music(datadir + "/music/" + music); music_manager->play_music(song); - while(!quit) { - Point tux_pos = tux->get_pos(); - if (1) - { - offset.x = -tux_pos.x + screen->w/2; - offset.y = -tux_pos.y + screen->h/2; + unsigned int last_update_time; + unsigned int update_time; - if (offset.x > 0) offset.x = 0; - if (offset.y > 0) offset.y = 0; + last_update_time = update_time = st_get_ticks(); - if (offset.x < screen->w - width*32) offset.x = screen->w - width*32; - if (offset.y < screen->h - height*32) offset.y = screen->h - height*32; - } + while(!quit) + { + float delta = ((float)(update_time-last_update_time))/100.0; - draw(offset); - get_input(); - update(); + delta *= 1.3f; - if(Menu::current()) - { - Menu::current()->draw(); - mouse_cursor->draw(); - } - flipscreen(); + last_update_time = update_time; + update_time = st_get_ticks(); - SDL_Delay(20); - } + Point tux_pos = tux->get_pos(); + if (1) + { + offset.x = -tux_pos.x + screen->w/2; + offset.y = -tux_pos.y + screen->h/2; + + if (offset.x > 0) offset.x = 0; + if (offset.y > 0) offset.y = 0; + + if (offset.x < screen->w - width*32) offset.x = screen->w - width*32; + if (offset.y < screen->h - height*32) offset.y = screen->h - height*32; + } + + draw(offset); + get_input(); + update(delta); + + if(Menu::current()) + { + Menu::current()->draw(); + mouse_cursor->draw(); + } + flipscreen(); + + SDL_Delay(20); + } } void Index: worldmap.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.h,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- worldmap.h 27 Apr 2004 15:15:18 -0000 1.27 +++ worldmap.h 27 Apr 2004 18:44:19 -0000 1.28 @@ -191,7 +191,7 @@ void get_input(); /** Update Tux position */ - void update(); + void update(float delta); /** Draw one frame */ void draw(const Point& offset); |