[Super-tux-commit] supertux/src gameloop.cpp,1.75,1.76 globals.cpp,1.11,1.12 globals.h,1.23,1.24 lev
Brought to you by:
wkendrick
From: Ingo R. <gr...@us...> - 2004-04-18 13:42:24
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12758 Modified Files: gameloop.cpp globals.cpp globals.h level.cpp level.h resources.cpp special.cpp world.cpp Log Message: - added constructor to level - changed framerate handling to avoid large frame_ratio's Index: special.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/special.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- special.cpp 16 Apr 2004 16:52:18 -0000 1.18 +++ special.cpp 18 Apr 2004 13:42:15 -0000 1.19 @@ -323,8 +323,7 @@ img_growup = new Surface(datadir + "/images/shared/egg.png", USE_ALPHA); img_iceflower = new Surface(datadir + "/images/shared/iceflower.png", USE_ALPHA); - img_golden_herring = new Surface(datadir + - "/images/shared/star.png", USE_ALPHA); + img_golden_herring = new Surface(datadir + "/images/shared/star.png", USE_ALPHA); img_1up = new Surface(datadir + "/images/shared/1up.png", USE_ALPHA); Index: globals.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/globals.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- globals.cpp 13 Apr 2004 12:25:22 -0000 1.11 +++ globals.cpp 18 Apr 2004 13:42:15 -0000 1.12 @@ -32,6 +32,7 @@ bool use_fullscreen; bool debug_mode; bool show_fps; +float game_speed = 1.0f; int joystick_num = 0; char* level_startup_file = 0; Index: level.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level.h,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- level.h 16 Apr 2004 14:26:19 -0000 1.30 +++ level.h 18 Apr 2004 13:42:15 -0000 1.31 @@ -73,6 +73,10 @@ std::vector<BadGuyData> badguy_data; public: + Level(); + Level(const std::string& subset, int level); + Level(const std::string& filename); + /** Will the Level structure with default values */ void init_defaults(); @@ -88,6 +92,7 @@ int load(const std::string& filename); void load_gfx(); + void free_gfx(); void load_song(); void free_song(); @@ -103,8 +108,6 @@ /** Return the id of the tile at position x/y */ unsigned int gettileid(float x, float y); - void free_gfx(); - void load_image(Surface** ptexture, std::string theme, const char * file, int use_alpha); }; Index: level.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level.cpp,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- level.cpp 16 Apr 2004 14:26:19 -0000 1.35 +++ level.cpp 18 Apr 2004 13:42:15 -0000 1.36 @@ -190,6 +190,20 @@ levels = 0; } +Level::Level() +{ +} + +Level::Level(const std::string& subset, int level) +{ + load(subset, level); +} + +Level::Level(const std::string& filename) +{ + load(filename); +} + void Level::init_defaults() { @@ -659,7 +673,6 @@ free(song_path); } - unsigned int Level::gettileid(float x, float y) { Index: globals.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/globals.h,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- globals.h 13 Apr 2004 12:25:22 -0000 1.23 +++ globals.h 18 Apr 2004 13:42:15 -0000 1.24 @@ -49,6 +49,7 @@ extern char* st_dir; extern char* st_save_dir; +extern float game_speed; extern SDL_Joystick * js; int wait_for_event(SDL_Event& event,unsigned int min_delay = 0, unsigned int max_delay = 0, bool empty_events = false); Index: world.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.cpp,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- world.cpp 18 Apr 2004 11:09:55 -0000 1.28 +++ world.cpp 18 Apr 2004 13:42:15 -0000 1.29 @@ -39,10 +39,9 @@ // world calls child functions current_ = this; - level = new Level; + level = new Level(filename); tux.init(); - level->load(filename); set_defaults(); get_level()->load_gfx(); @@ -57,10 +56,9 @@ // world calls child functions current_ = this; - level = new Level; + level = new Level(subset, level_nr); tux.init(); - level->load(subset, level_nr); set_defaults(); get_level()->load_gfx(); @@ -205,6 +203,8 @@ void World::action(double frame_ratio) { + tux.action(frame_ratio); + /* Handle bouncy distros: */ for (unsigned int i = 0; i < bouncy_distros.size(); i++) bouncy_distros[i].action(frame_ratio); Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.75 retrieving revision 1.76 diff -u -d -r1.75 -r1.76 --- gameloop.cpp 18 Apr 2004 12:03:06 -0000 1.75 +++ gameloop.cpp 18 Apr 2004 13:42:14 -0000 1.76 @@ -10,6 +10,7 @@ April 11, 2000 - March 15, 2004 */ +#include <iostream> #include <assert.h> #include <stdio.h> #include <stdlib.h> @@ -345,10 +346,7 @@ if (exit_status == NONE) { - Player* tux = world->get_tux(); - // Update Tux and the World - tux->action(frame_ratio); world->action(frame_ratio); } } @@ -410,12 +408,11 @@ draw(); + float overlap = 0.0f; while (exit_status == NONE) { /* Calculate the movement-factor */ double frame_ratio = ((double)(update_time-last_update_time))/((double)FRAME_RATE); - 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(!frame_timer.check()) { @@ -463,7 +460,15 @@ // Handle actions: if(!game_pause && !show_menu) { - action(frame_ratio); + frame_ratio *= game_speed; + frame_ratio += overlap; + while (frame_ratio > 0) + { + action(1.0f); + frame_ratio -= 1.0f; + } + overlap = frame_ratio; + if (exit_status != NONE) return exit_status; } Index: resources.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/resources.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- resources.cpp 17 Apr 2004 10:48:04 -0000 1.9 +++ resources.cpp 18 Apr 2004 13:42:15 -0000 1.10 @@ -145,11 +145,11 @@ ducktux_right = new Surface(datadir + - "/images/shared/ducktux-right.png", + "/images/shared/tux-duck-right.png", USE_ALPHA); ducktux_left = new Surface(datadir + - "/images/shared/ducktux-left.png", + "/images/shared/tux-duck-left.png", USE_ALPHA); skidtux_right = new Surface(datadir + |