super-tux-commit Mailing List for Super Tux (Page 98)
Brought to you by:
wkendrick
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
(94) |
Apr
(500) |
May
(531) |
Jun
(196) |
Jul
(224) |
Aug
(193) |
Sep
(117) |
Oct
(115) |
Nov
(319) |
Dec
(97) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(19) |
Feb
|
Mar
(105) |
Apr
(41) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(6) |
2007 |
Jan
(1) |
Feb
(2) |
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
(2) |
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
|
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
(4) |
Jul
|
Aug
|
Sep
(7) |
Oct
(12) |
Nov
(26) |
Dec
(39) |
2009 |
Jan
(6) |
Feb
(15) |
Mar
(10) |
Apr
(25) |
May
(29) |
Jun
(21) |
Jul
(26) |
Aug
(8) |
Sep
(3) |
Oct
|
Nov
|
Dec
(10) |
2010 |
Jan
(5) |
Feb
(5) |
Mar
(2) |
Apr
|
May
(5) |
Jun
|
Jul
(1) |
Aug
(2) |
Sep
(2) |
Oct
(2) |
Nov
|
Dec
|
From: Ingo R. <gr...@us...> - 2004-04-11 17:24:31
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18210 Modified Files: title.cpp Log Message: - fixed missing menu on level editor exit Index: title.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/title.cpp,v retrieving revision 1.36 retrieving revision 1.37 diff -u -d -r1.36 -r1.37 --- title.cpp 11 Apr 2004 17:09:10 -0000 1.36 +++ title.cpp 11 Apr 2004 17:10:48 -0000 1.37 @@ -328,6 +328,8 @@ case 3: done = true; done = leveleditor(1); + menu_reset(); + show_menu = 1; Menu::set_current(main_menu); break; case 4: |
From: Ingo R. <gr...@us...> - 2004-04-11 17:22:50
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17923 Modified Files: title.cpp Log Message: - moved loadshared() to the right point Index: title.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/title.cpp,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- title.cpp 11 Apr 2004 16:58:06 -0000 1.35 +++ title.cpp 11 Apr 2004 17:09:10 -0000 1.36 @@ -326,8 +326,9 @@ // Contrib Menu break; case 3: - done = 1; + done = true; done = leveleditor(1); + Menu::set_current(main_menu); break; case 4: display_credits(); |
From: Ingo R. <gr...@us...> - 2004-04-11 17:17:43
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16890 Modified Files: supertux.cpp Log Message: - moved loadshared() to the right point Index: supertux.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/supertux.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- supertux.cpp 11 Apr 2004 16:58:06 -0000 1.8 +++ supertux.cpp 11 Apr 2004 17:04:03 -0000 1.9 @@ -25,6 +25,7 @@ st_joystick_setup(); st_general_setup(); st_menu(); + loadshared(); if (launch_worldmap_mode) { @@ -40,15 +41,14 @@ done = false; while (!done) { - loadshared(); done = title(); - unloadshared(); } } clearscreen(0, 0, 0); updatescreen(); + unloadshared(); st_shutdown(); return 0; |
From: Ingo R. <gr...@us...> - 2004-04-11 17:11:50
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15830 Modified Files: gameloop.cpp leveleditor.cpp supertux.cpp title.cpp Log Message: - removed local (un)loadshared() stuff and replaced it my a global one, fixes crash on entering a level twice Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.62 retrieving revision 1.63 diff -u -d -r1.62 -r1.63 --- gameloop.cpp 11 Apr 2004 16:33:11 -0000 1.62 +++ gameloop.cpp 11 Apr 2004 16:58:05 -0000 1.63 @@ -104,7 +104,6 @@ } world->get_level()->load_gfx(); - loadshared(); world->activate_bad_guys(); world->activate_particle_systems(); @@ -363,7 +362,6 @@ world->get_level()->free_song(); world->arrays_free(); - unloadshared(); return(0); } tux.level_begin(); @@ -390,7 +388,6 @@ world->get_level()->free_song(); world->arrays_free(); - unloadshared(); return(0); } /* if (lives < 0) */ } @@ -640,7 +637,6 @@ world->get_level()->cleanup(); world->get_level()->free_song(); - unloadshared(); world->arrays_free(); return quit; Index: title.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/title.cpp,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- title.cpp 11 Apr 2004 16:38:58 -0000 1.34 +++ title.cpp 11 Apr 2004 16:58:06 -0000 1.35 @@ -146,7 +146,6 @@ st_pause_ticks_init(); GameSession session(datadir + "/levels/misc/menu.stl"); - loadshared(); //FIXME:activate_particle_systems(); Index: supertux.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/supertux.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- supertux.cpp 11 Apr 2004 01:24:58 -0000 1.7 +++ supertux.cpp 11 Apr 2004 16:58:06 -0000 1.8 @@ -11,9 +11,7 @@ */ #include "supertux.h" - - -/* --- MAIN --- */ +#include "resources.h" int main(int argc, char * argv[]) { @@ -42,7 +40,9 @@ done = false; while (!done) { + loadshared(); done = title(); + unloadshared(); } } Index: leveleditor.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/leveleditor.cpp,v retrieving revision 1.40 retrieving revision 1.41 diff -u -d -r1.40 -r1.41 --- leveleditor.cpp 11 Apr 2004 16:38:58 -0000 1.40 +++ leveleditor.cpp 11 Apr 2004 16:58:05 -0000 1.41 @@ -242,7 +242,6 @@ leveleditor_menu->item[3].kind = MN_GOTO; le_level = 1; global_world.arrays_free(); - loadshared(); le_current_level = new Level; if(le_current_level->load(le_level_subset.name.c_str(), le_level) != 0) { @@ -273,7 +272,6 @@ leveleditor_menu->item[3].kind = MN_GOTO; le_level = 1; global_world.arrays_free(); - loadshared(); le_current_level = new Level; if(le_current_level->load(le_level_subset.name.c_str(), le_level) != 0) { @@ -595,7 +593,6 @@ le_current_level->free_gfx(); le_current_level->cleanup(); global_world.arrays_free(); - unloadshared(); } } @@ -1194,7 +1191,6 @@ Menu::set_current(leveleditor_menu); global_world.arrays_free(); le_current_level->load_gfx(); - loadshared(); global_world.activate_bad_guys(); } |
From: Ingo R. <gr...@us...> - 2004-04-11 16:52:43
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12680 Modified Files: badguy.h button.cpp button.h gameloop.h gameobjs.h globals.cpp intro.cpp leveleditor.cpp menu.h mousecursor.h player.h timer.cpp timer.h title.cpp Log Message: renamed timer_type to Timer Index: mousecursor.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/mousecursor.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- mousecursor.h 28 Mar 2004 01:00:16 -0000 1.2 +++ mousecursor.h 11 Apr 2004 16:38:58 -0000 1.3 @@ -40,7 +40,7 @@ int cur_state; int cur_frame, tot_frames; texture_type cursor; - timer_type timer; + Timer timer; }; #endif /*SUPERTUX_MOUSECURSOR_H*/ Index: player.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.h,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- player.h 11 Apr 2004 15:28:26 -0000 1.23 +++ player.h 11 Apr 2004 16:38:58 -0000 1.24 @@ -111,10 +111,10 @@ base_type base; base_type old_base; base_type previous_base; - timer_type invincible_timer; - timer_type skidding_timer; - timer_type safe_timer; - timer_type frame_timer; + Timer invincible_timer; + Timer skidding_timer; + Timer safe_timer; + Timer frame_timer; Physic physic; public: Index: timer.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/timer.h,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- timer.h 11 Apr 2004 16:33:11 -0000 1.10 +++ timer.h 11 Apr 2004 16:38:58 -0000 1.11 @@ -20,7 +20,7 @@ void st_pause_ticks_start(void); void st_pause_ticks_stop(void); -class timer_type +class Timer { public: unsigned int period; @@ -33,9 +33,6 @@ 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 @@ -44,9 +41,6 @@ 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 ======================================================================*/ Index: intro.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/intro.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- intro.cpp 11 Apr 2004 16:33:11 -0000 1.12 +++ intro.cpp 11 Apr 2004 16:38:58 -0000 1.13 @@ -48,7 +48,7 @@ SDL_Rect src, dest; int done, i, quit, j, scene; int * height, * height_speed; - timer_type timer; + Timer timer; /* Load sprite images: */ texture_load(&bkgd, datadir + "/images/intro/intro.png", IGNORE_ALPHA); Index: leveleditor.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/leveleditor.cpp,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- leveleditor.cpp 11 Apr 2004 16:33:11 -0000 1.39 +++ leveleditor.cpp 11 Apr 2004 16:38:58 -0000 1.40 @@ -111,7 +111,7 @@ static Menu* subset_settings_menu; static Menu* level_settings_menu; static Menu* select_tilegroup_menu; -static timer_type select_tilegroup_menu_effect; +static Timer select_tilegroup_menu_effect; static std::map<std::string, ButtonPanel* > tilegroups_map; static std::string cur_tilegroup; Index: gameobjs.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameobjs.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- gameobjs.h 11 Apr 2004 15:28:26 -0000 1.4 +++ gameobjs.h 11 Apr 2004 16:38:58 -0000 1.5 @@ -50,7 +50,7 @@ { public: base_type base; - timer_type timer; + Timer timer; Tile* tile; void init(Tile* tile, float x, float y, float xm, float ym); @@ -75,7 +75,7 @@ { public: int value; - timer_type timer; + Timer timer; base_type base; void init(float x, float y, int s); Index: button.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/button.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- button.cpp 11 Apr 2004 16:23:07 -0000 1.11 +++ button.cpp 11 Apr 2004 16:38:58 -0000 1.12 @@ -17,7 +17,7 @@ #include "globals.h" #include "button.h" -timer_type Button::popup_timer; +Timer Button::popup_timer; Button::Button(std::string icon_file, std::string ninfo, SDLKey nshortcut, int x, int y, int mw, int mh) { Index: badguy.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.h,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- badguy.h 11 Apr 2004 15:28:26 -0000 1.22 +++ badguy.h 11 Apr 2004 16:38:58 -0000 1.23 @@ -96,7 +96,7 @@ private: bool seen; base_type old_base; - timer_type timer; + Timer timer; Physic physic; texture_type* texture_left; Index: menu.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/menu.h,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- menu.h 10 Apr 2004 18:56:17 -0000 1.27 +++ menu.h 11 Apr 2004 16:38:58 -0000 1.28 @@ -65,7 +65,7 @@ int height(); public: - timer_type effect; + Timer effect; int arrange_left; int active_item; menu_item_type *item; Index: globals.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/globals.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- globals.cpp 11 Apr 2004 16:23:07 -0000 1.9 +++ globals.cpp 11 Apr 2004 16:38:58 -0000 1.10 @@ -39,8 +39,8 @@ int wait_for_event(SDL_Event& event,unsigned int min_delay, unsigned int max_delay, bool empty_events) { int i; - timer_type maxdelay; - timer_type mindelay; + Timer maxdelay; + Timer mindelay; maxdelay.init(false); mindelay.init(false); Index: timer.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/timer.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- timer.cpp 11 Apr 2004 16:33:11 -0000 1.8 +++ timer.cpp 11 Apr 2004 16:38:58 -0000 1.9 @@ -45,7 +45,7 @@ } void -timer_type::init(bool st_ticks) +Timer::init(bool st_ticks) { period = 0; time = 0; @@ -53,14 +53,14 @@ } void -timer_type::start(unsigned int period_) +Timer::start(unsigned int period_) { time = get_ticks(); period = period_; } void -timer_type::stop() +Timer::stop() { if(get_ticks == st_get_ticks) init(true); @@ -69,7 +69,7 @@ } int -timer_type::check() +Timer::check() { if((time != 0) && (time + period > get_ticks())) return true; @@ -81,7 +81,7 @@ } int -timer_type::started() +Timer::started() { if(time != 0) return true; @@ -90,19 +90,19 @@ } int -timer_type::get_left() +Timer::get_left() { return (period - (get_ticks() - time)); } int -timer_type::get_gone() +Timer::get_gone() { return (get_ticks() - time); } void -timer_type::fwrite(FILE* fi) +Timer::fwrite(FILE* fi) { unsigned int diff_ticks; int tick_mode; @@ -121,7 +121,7 @@ } void -timer_type::fread(FILE* fi) +Timer::fread(FILE* fi) { unsigned int diff_ticks; int tick_mode; Index: gameloop.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.h,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- gameloop.h 11 Apr 2004 15:33:53 -0000 1.37 +++ gameloop.h 11 Apr 2004 16:38:58 -0000 1.38 @@ -36,8 +36,8 @@ { private: bool quit; - timer_type fps_timer; - timer_type frame_timer; + Timer fps_timer; + Timer frame_timer; World* world; int st_gl_mode; @@ -53,7 +53,7 @@ int levelnb; public: - timer_type time_left; + Timer time_left; GameSession(); GameSession(const std::string& filename); Index: title.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/title.cpp,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- title.cpp 11 Apr 2004 16:33:11 -0000 1.33 +++ title.cpp 11 Apr 2004 16:38:58 -0000 1.34 @@ -46,7 +46,7 @@ static texture_type img_choose_subset; static bool walking; -static timer_type random_timer; +static Timer random_timer; static SDL_Event event; static SDLKey key; @@ -389,7 +389,7 @@ { int done; int scroll, speed; - timer_type timer; + Timer timer; int n,d; int length; FILE* fi; Index: button.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/button.h,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- button.h 4 Apr 2004 00:32:10 -0000 1.12 +++ button.h 11 Apr 2004 16:38:58 -0000 1.13 @@ -42,7 +42,7 @@ } private: - static timer_type popup_timer; + static Timer popup_timer; texture_type icon; texture_type* bkgd; std::string info; |
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11662 Modified Files: gameloop.cpp intro.cpp leveleditor.cpp menu.cpp mousecursor.cpp player.cpp timer.cpp timer.h title.cpp Log Message: started to convert timer into a class Index: menu.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/menu.cpp,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- menu.cpp 11 Apr 2004 16:23:08 -0000 1.28 +++ menu.cpp 11 Apr 2004 16:33:11 -0000 1.29 @@ -332,7 +332,7 @@ { 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; } Index: timer.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/timer.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- timer.h 11 Apr 2004 16:23:08 -0000 1.9 +++ timer.h 11 Apr 2004 16:33:11 -0000 1.10 @@ -42,18 +42,20 @@ ======================================================================*/ 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 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); + /*====================================================================== + 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); +}; #endif /*SUPERTUX_TIMER_H*/ Index: intro.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/intro.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- intro.cpp 11 Apr 2004 16:23:07 -0000 1.11 +++ intro.cpp 11 Apr 2004 16:33:11 -0000 1.12 @@ -108,7 +108,7 @@ /* Draw things: */ - if (timer_get_gone(&timer) < 2000 && scene == 0) + if (timer.get_gone() < 2000 && scene == 0) { ++scene; /* Gown and tux sitting: */ @@ -120,7 +120,7 @@ } - if (timer_get_gone(&timer) >= 2000 && scene == 1) + if (timer.get_gone() >= 2000 && scene == 1) { ++scene; /* Helicopter begins to fly in: */ @@ -130,19 +130,19 @@ } - 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... */ @@ -151,7 +151,7 @@ } - if (timer_get_gone(&timer) >= 3500 && scene == 3) + if (timer.get_gone() >= 3500 && scene == 3) { ++scene; /* Gown realizes it's bad! */ @@ -160,7 +160,7 @@ } - 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)); @@ -170,7 +170,7 @@ } - if (timer_get_gone(&timer) >= 5000 && scene == 4) + if (timer.get_gone() >= 5000 && scene == 4) { ++scene; /* Tux realizes something's happening: */ @@ -183,7 +183,7 @@ } - if (timer_get_gone(&timer) >= 5000 && timer_get_gone(&timer) <= 8000) + if (timer.get_gone() >= 5000 && timer.get_gone() <= 8000) { /* Beam gown up! */ @@ -210,7 +210,7 @@ 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; } @@ -223,7 +223,7 @@ } - 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, @@ -241,7 +241,7 @@ } - 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: */ @@ -254,14 +254,14 @@ } - 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)); Index: timer.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/timer.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- timer.cpp 11 Apr 2004 16:23:08 -0000 1.7 +++ timer.cpp 11 Apr 2004 16:33:11 -0000 1.8 @@ -89,51 +89,57 @@ 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 */ Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- player.cpp 11 Apr 2004 16:23:08 -0000 1.30 +++ player.cpp 11 Apr 2004 16:33:11 -0000 1.31 @@ -263,7 +263,7 @@ */ // 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 Index: mousecursor.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/mousecursor.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- mousecursor.cpp 11 Apr 2004 16:23:08 -0000 1.3 +++ mousecursor.cpp 11 Apr 2004 16:33:11 -0000 1.4 @@ -64,7 +64,7 @@ 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) Index: title.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/title.cpp,v retrieving revision 1.32 retrieving revision 1.33 diff -u -d -r1.32 -r1.33 --- title.cpp 11 Apr 2004 16:23:08 -0000 1.32 +++ title.cpp 11 Apr 2004 16:33:11 -0000 1.33 @@ -502,7 +502,7 @@ SDL_Delay(35); - if(timer_get_left(&timer) < 0) + if(timer.get_left() < 0) { frame++; timer.start(50); Index: leveleditor.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/leveleditor.cpp,v retrieving revision 1.38 retrieving revision 1.39 diff -u -d -r1.38 -r1.39 --- leveleditor.cpp 11 Apr 2004 16:23:07 -0000 1.38 +++ leveleditor.cpp 11 Apr 2004 16:33:11 -0000 1.39 @@ -158,7 +158,8 @@ { 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); Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.61 retrieving revision 1.62 diff -u -d -r1.61 -r1.62 --- gameloop.cpp 11 Apr 2004 16:23:07 -0000 1.61 +++ gameloop.cpp 11 Apr 2004 16:33:11 -0000 1.62 @@ -609,7 +609,7 @@ 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); @@ -624,7 +624,7 @@ 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()) { @@ -677,9 +677,9 @@ 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); } |
From: Ingo R. <gr...@us...> - 2004-04-11 16:36:54
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9640 Modified Files: badguy.cpp button.cpp gameloop.cpp gameobjs.cpp globals.cpp intro.cpp leveleditor.cpp menu.cpp mousecursor.cpp player.cpp special.cpp timer.cpp timer.h title.cpp Log Message: started to convert timer into a class Index: timer.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/timer.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- timer.h 23 Mar 2004 17:25:15 -0000 1.8 +++ timer.h 11 Apr 2004 16:23:08 -0000 1.9 @@ -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 @@ #endif /*SUPERTUX_TIMER_H*/ +/* Local Variables: */ +/* mode:c++ */ +/* End */ Index: intro.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/intro.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- intro.cpp 3 Apr 2004 13:31:14 -0000 1.10 +++ intro.cpp 11 Apr 2004 16:23:07 -0000 1.11 @@ -89,10 +89,10 @@ 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) { Index: special.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/special.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- special.cpp 11 Apr 2004 15:28:26 -0000 1.13 +++ special.cpp 11 Apr 2004 16:23:08 -0000 1.14 @@ -270,7 +270,7 @@ 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) { Index: leveleditor.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/leveleditor.cpp,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- leveleditor.cpp 11 Apr 2004 14:44:19 -0000 1.37 +++ leveleditor.cpp 11 Apr 2004 16:23:07 -0000 1.38 @@ -156,7 +156,7 @@ 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 @@ 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 @@ 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; } Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.60 retrieving revision 1.61 diff -u -d -r1.60 -r1.61 --- gameloop.cpp 11 Apr 2004 15:28:26 -0000 1.60 +++ gameloop.cpp 11 Apr 2004 16:23:07 -0000 1.61 @@ -67,8 +67,8 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ ++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; } } Index: badguy.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.cpp,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- badguy.cpp 11 Apr 2004 15:28:26 -0000 1.27 +++ badguy.cpp 11 Apr 2004 16:23:07 -0000 1.28 @@ -148,7 +148,7 @@ 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 @@ } // 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 @@ /* 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 @@ 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 @@ // 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 @@ /* 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 @@ // 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ player_status.score_multiplier++; dying = DYING_SQUISHED; - timer_start(&timer, 2000); + timer.start(2000); physic.set_velocity(0, 0); } @@ -831,7 +831,7 @@ 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); Index: button.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/button.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- button.cpp 4 Apr 2004 00:32:10 -0000 1.10 +++ button.cpp 11 Apr 2004 16:23:07 -0000 1.11 @@ -21,7 +21,7 @@ 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::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 @@ } else if(event.type == SDL_MOUSEMOTION) { - timer_start(&popup_timer, 1500); + popup_timer.start(1500); if(show_info) { Index: menu.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/menu.cpp,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- menu.cpp 10 Apr 2004 20:37:36 -0000 1.27 +++ menu.cpp 11 Apr 2004 16:23:08 -0000 1.28 @@ -64,7 +64,7 @@ if(tmp->last_menu != pmenu) current_menu->last_menu = tmp; - timer_start(&pmenu->effect, 500); + pmenu->effect.start(500); } } @@ -136,13 +136,13 @@ 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 @@ 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; Index: globals.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/globals.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- globals.cpp 29 Mar 2004 13:24:41 -0000 1.8 +++ globals.cpp 11 Apr 2004 16:23:07 -0000 1.9 @@ -41,14 +41,15 @@ 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 @@ /* 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) { Index: timer.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/timer.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- timer.cpp 4 Apr 2004 00:32:10 -0000 1.6 +++ timer.cpp 11 Apr 2004 16:23:08 -0000 1.7 @@ -44,41 +44,46 @@ 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; Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- player.cpp 11 Apr 2004 15:33:53 -0000 1.29 +++ player.cpp 11 Apr 2004 16:23:08 -0000 1.30 @@ -95,10 +95,10 @@ 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_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 @@ } - 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 @@ // 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 @@ /* (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 @@ 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 @@ } else { - if (timer_started(&invincible_timer)) + if (invincible_timer.started()) { /* Draw cape: */ if (dir == RIGHT) @@ -663,7 +664,7 @@ { if (!duck) { - if (!timer_started(&skidding_timer)) + if (!skidding_timer.started()) { if (!jumping || physic.get_velocity_y() > 0) { @@ -724,7 +725,7 @@ if (!duck) { - if (!timer_started(&skidding_timer)) + if (!skidding_timer.started()) { if (!jumping || physic.get_velocity_y() > 0) { @@ -798,7 +799,7 @@ /* 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 @@ else { /* Hurt if you get hit by kicked laptop: */ - if (!timer_started(&invincible_timer)) + if (!invincible_timer.started()) { kill(SHRINK); } @@ -834,7 +835,7 @@ } else { - if (!timer_started(&invincible_timer )) + if (!invincible_timer.started()) { kill(SHRINK); } @@ -869,7 +870,7 @@ size = SMALL; base.height = 32; - timer_start(&safe_timer,TUX_SAFE_TIME); + safe_timer.start(TUX_SAFE_TIME); } else { Index: mousecursor.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/mousecursor.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- mousecursor.cpp 28 Mar 2004 01:00:16 -0000 1.2 +++ mousecursor.cpp 11 Apr 2004 16:23:08 -0000 1.3 @@ -21,8 +21,8 @@ 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 @@ 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); Index: title.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/title.cpp,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- title.cpp 11 Apr 2004 15:28:26 -0000 1.31 +++ title.cpp 11 Apr 2004 16:23:08 -0000 1.32 @@ -98,7 +98,7 @@ 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 @@ } else { - timer_start(&random_timer, rand() % 3000 + 3000); + random_timer.start(rand() % 3000 + 3000); walking = !walking; } @@ -139,7 +139,7 @@ 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 @@ 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 @@ } - timer_init(&timer, SDL_GetTicks()); - timer_start(&timer, 50); + timer.init(SDL_GetTicks()); + timer.start(50); scroll = 0; speed = 2; @@ -505,7 +505,7 @@ if(timer_get_left(&timer) < 0) { frame++; - timer_start(&timer, 50); + timer.start(50); } } string_list_free(&names); Index: gameobjs.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameobjs.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- gameobjs.cpp 11 Apr 2004 15:28:26 -0000 1.5 +++ gameobjs.cpp 11 Apr 2004 16:23:07 -0000 1.6 @@ -59,8 +59,8 @@ 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 @@ 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<std::vector<BrokenBrick>::iterator>(this)); } @@ -159,8 +159,8 @@ { 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 @@ { base.y = base.y - 2 * frame_ratio; - if(!timer_check(&timer)) + if(!timer.check()) World::current()->floating_scores.erase(static_cast<std::vector<FloatingScore>::iterator>(this)); } |
From: Ingo R. <gr...@us...> - 2004-04-11 15:47:58
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1575 Modified Files: gameloop.h player.cpp scene.cpp scene.h Log Message: - moved time_left timer into gamesession Index: scene.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/scene.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- scene.cpp 11 Apr 2004 15:28:26 -0000 1.19 +++ scene.cpp 11 Apr 2004 15:33:53 -0000 1.20 @@ -20,7 +20,5 @@ unsigned int global_frame_counter; -timer_type time_left; - // EOF // Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- player.cpp 11 Apr 2004 15:28:26 -0000 1.28 +++ player.cpp 11 Apr 2004 15:33:53 -0000 1.29 @@ -253,8 +253,6 @@ /* ---- DONE HANDLING TUX! --- */ /* Handle invincibility timer: */ - - if (get_current_music() == HERRING_MUSIC && !timer_check(&invincible_timer)) { /* @@ -263,8 +261,8 @@ but are we in hurry ? */ - - if (timer_get_left(&time_left) < TIME_WARNING) + // FIXME: Move this to gamesession + if (timer_get_left(&GameSession::current()->time_left) < TIME_WARNING) { /* yes, we are in hurry stop the herring_song, prepare to play the correct Index: gameloop.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.h,v retrieving revision 1.36 retrieving revision 1.37 diff -u -d -r1.36 -r1.37 --- gameloop.h 11 Apr 2004 15:28:26 -0000 1.36 +++ gameloop.h 11 Apr 2004 15:33:53 -0000 1.37 @@ -53,6 +53,8 @@ int levelnb; public: + timer_type time_left; + GameSession(); GameSession(const std::string& filename); GameSession(const std::string& subset, int levelnb, int mode); Index: scene.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/scene.h,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- scene.h 11 Apr 2004 15:28:26 -0000 1.22 +++ scene.h 11 Apr 2004 15:33:53 -0000 1.23 @@ -32,6 +32,4 @@ extern float scroll_x; extern unsigned int global_frame_counter; -extern timer_type time_left; - #endif /*SUPERTUX_SCENE_H*/ |
From: Ingo R. <gr...@us...> - 2004-04-11 15:42:23
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv726 Modified Files: badguy.cpp badguy.h gameloop.cpp gameloop.h gameobjs.cpp gameobjs.h physic.cpp physic.h player.cpp player.h scene.cpp scene.h special.cpp special.h title.cpp world.cpp world.h Log Message: - made frame ration local Index: scene.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/scene.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- scene.cpp 11 Apr 2004 15:07:29 -0000 1.18 +++ scene.cpp 11 Apr 2004 15:28:26 -0000 1.19 @@ -21,7 +21,6 @@ unsigned int global_frame_counter; timer_type time_left; -double frame_ratio; // EOF // Index: world.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.h,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- world.h 11 Apr 2004 14:55:59 -0000 1.20 +++ world.h 11 Apr 2004 15:28:26 -0000 1.21 @@ -67,7 +67,7 @@ void set_defaults(); void draw(); - void action(); + void action(double frame_ratio); /** Checks for all possible collisions. And calls the collision_handlers, which the collision_objects provide for this Index: special.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/special.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- special.cpp 11 Apr 2004 15:07:29 -0000 1.12 +++ special.cpp 11 Apr 2004 15:28:26 -0000 1.13 @@ -53,7 +53,7 @@ } void -Bullet::action() +Bullet::action(double frame_ratio) { base.x = base.x + base.xm * frame_ratio; base.y = base.y + base.ym * frame_ratio; @@ -128,7 +128,7 @@ } void -Upgrade::action() +Upgrade::action(double frame_ratio) { if (base.height < 32) { Index: badguy.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.cpp,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- badguy.cpp 11 Apr 2004 15:07:29 -0000 1.26 +++ badguy.cpp 11 Apr 2004 15:28:26 -0000 1.27 @@ -198,7 +198,7 @@ } void -BadGuy::action_bsod() +BadGuy::action_bsod(float frame_ratio) { static const float BSODJUMP = 2; @@ -223,13 +223,13 @@ } // move - physic.apply(base.x, base.y); + physic.apply(frame_ratio, base.x, base.y); if(dying != DYING_FALLING) collision_swept_object_map(&old_base, &base); } void -BadGuy::action_laptop() +BadGuy::action_laptop(float frame_ratio) { Player& tux = *World::current()->get_tux(); @@ -239,7 +239,7 @@ if (mode == NORMAL || mode == KICK) { // move - physic.apply(base.x, base.y); + physic.apply(frame_ratio, base.x, base.y); if (dying != DYING_FALLING) collision_swept_object_map(&old_base,&base); } @@ -386,7 +386,7 @@ } void -BadGuy::action_money() +BadGuy::action_money(float frame_ratio) { Player& tux = *World::current()->get_tux(); @@ -414,26 +414,26 @@ dir = LEFT; // move - physic.apply(base.x, base.y); + physic.apply(frame_ratio, base.x, base.y); if(dying == DYING_NOT) collision_swept_object_map(&old_base, &base); } void -BadGuy::action_mrbomb() +BadGuy::action_mrbomb(float frame_ratio) { if (dying == DYING_NOT) check_horizontal_bump(true); fall(); - physic.apply(base.x, base.y); + physic.apply(frame_ratio, base.x, base.y); if (dying != DYING_FALLING) collision_swept_object_map(&old_base,&base); } void -BadGuy::action_bomb() +BadGuy::action_bomb(float frame_ratio) { static const int TICKINGTIME = 1000; static const int EXPLODETIME = 1000; @@ -456,12 +456,12 @@ } // move - physic.apply(base.x, base.y); + physic.apply(frame_ratio, base.x, base.y); collision_swept_object_map(&old_base,&base); } void -BadGuy::action_stalactite() +BadGuy::action_stalactite(float frame_ratio) { Player& tux = *World::current()->get_tux(); @@ -496,14 +496,14 @@ } // move - physic.apply(base.x, base.y); + physic.apply(frame_ratio, base.x, base.y); if(dying == DYING_SQUISHED && !timer_check(&timer)) remove_me(); } void -BadGuy::action_flame() +BadGuy::action_flame(float frame_ratio) { static const float radius = 100; static const float speed = 0.02; @@ -514,7 +514,7 @@ } void -BadGuy::action_fish() +BadGuy::action_fish(float frame_ratio) { static const float JUMPV = 6; static const int WAITTIME = 1000; @@ -539,13 +539,13 @@ physic.enable_gravity(true); } - physic.apply(base.x, base.y); + physic.apply(frame_ratio, base.x, base.y); if(dying == DYING_NOT) collision_swept_object_map(&old_base, &base); } void -BadGuy::action_bouncingsnowball() +BadGuy::action_bouncingsnowball(float frame_ratio) { static const float JUMPV = 4.5; @@ -565,7 +565,7 @@ // check for right/left collisions check_horizontal_bump(); - physic.apply(base.x, base.y); + physic.apply(frame_ratio, base.x, base.y); if(dying == DYING_NOT) collision_swept_object_map(&old_base, &base); @@ -579,7 +579,7 @@ } void -BadGuy::action_flyingsnowball() +BadGuy::action_flyingsnowball(float frame_ratio) { static const float FLYINGSPEED = 1; static const int DIRCHANGETIME = 1000; @@ -605,7 +605,7 @@ if(dying != DYING_NOT) physic.enable_gravity(true); - physic.apply(base.x, base.y); + physic.apply(frame_ratio, base.x, base.y); if(dying == DYING_NOT || dying == DYING_SQUISHED) collision_swept_object_map(&old_base, &base); @@ -619,7 +619,7 @@ } void -BadGuy::action_spiky() +BadGuy::action_spiky(float frame_ratio) { if (dying == DYING_NOT) check_horizontal_bump(); @@ -634,26 +634,26 @@ } #endif - physic.apply(base.x, base.y); + physic.apply(frame_ratio, base.x, base.y); if (dying != DYING_FALLING) collision_swept_object_map(&old_base,&base); } void -BadGuy::action_snowball() +BadGuy::action_snowball(float frame_ratio) { if (dying == DYING_NOT) check_horizontal_bump(); fall(); - physic.apply(base.x, base.y); + physic.apply(frame_ratio, base.x, base.y); if (dying != DYING_FALLING) collision_swept_object_map(&old_base,&base); } void -BadGuy::action() +BadGuy::action(float frame_ratio) { // Remove if it's far off the screen: if (base.x < scroll_x - OFFSCREEN_DISTANCE) @@ -678,51 +678,51 @@ switch (kind) { case BAD_BSOD: - action_bsod(); + action_bsod(frame_ratio); break; case BAD_LAPTOP: - action_laptop(); + action_laptop(frame_ratio); break; case BAD_MONEY: - action_money(); + action_money(frame_ratio); break; case BAD_MRBOMB: - action_mrbomb(); + action_mrbomb(frame_ratio); break; case BAD_BOMB: - action_bomb(); + action_bomb(frame_ratio); break; case BAD_STALACTITE: - action_stalactite(); + action_stalactite(frame_ratio); break; case BAD_FLAME: - action_flame(); + action_flame(frame_ratio); break; case BAD_FISH: - action_fish(); + action_fish(frame_ratio); break; case BAD_BOUNCINGSNOWBALL: - action_bouncingsnowball(); + action_bouncingsnowball(frame_ratio); break; case BAD_FLYINGSNOWBALL: - action_flyingsnowball(); + action_flyingsnowball(frame_ratio); break; case BAD_SPIKY: - action_spiky(); + action_spiky(frame_ratio); break; case BAD_SNOWBALL: - action_snowball(); + action_snowball(frame_ratio); break; } } Index: gameobjs.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameobjs.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- gameobjs.h 11 Apr 2004 12:43:35 -0000 1.3 +++ gameobjs.h 11 Apr 2004 15:28:26 -0000 1.4 @@ -35,7 +35,7 @@ base_type base; void init(float x, float y); - void action(); + void action(double frame_ratio); void draw(); }; @@ -54,7 +54,7 @@ Tile* tile; void init(Tile* tile, float x, float y, float xm, float ym); - void action(); + void action(double frame_ratio); void draw(); }; @@ -67,7 +67,7 @@ base_type base; void init(float x, float y); - void action(); + void action(double frame_ratio); void draw(); }; @@ -79,7 +79,7 @@ base_type base; void init(float x, float y, int s); - void action(); + void action(double frame_ratio); void draw(); }; Index: scene.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/scene.h,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- scene.h 11 Apr 2004 15:07:29 -0000 1.21 +++ scene.h 11 Apr 2004 15:28:26 -0000 1.22 @@ -29,11 +29,9 @@ extern PlayerStatus player_status; -extern timer_type super_bkgd_timer; extern float scroll_x; extern unsigned int global_frame_counter; extern timer_type time_left; -extern double frame_ratio; #endif /*SUPERTUX_SCENE_H*/ Index: special.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/special.h,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- special.h 11 Apr 2004 13:20:43 -0000 1.11 +++ special.h 11 Apr 2004 15:28:26 -0000 1.12 @@ -39,7 +39,7 @@ base_type old_base; void init(float x, float y, int dir, int kind); - void action(); + void action(double frame_ratio); void draw(); void collision(void* p_c_object, int c_object); }; @@ -51,7 +51,7 @@ base_type old_base; void init(float x, float y, float xm, int dir); - void action(); + void action(double frame_ratio); void draw(); void collision(int c_object); }; Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.59 retrieving revision 1.60 diff -u -d -r1.59 -r1.60 --- gameloop.cpp 11 Apr 2004 15:07:29 -0000 1.59 +++ gameloop.cpp 11 Apr 2004 15:28:26 -0000 1.60 @@ -338,7 +338,7 @@ } int -GameSession::action() +GameSession::action(double frame_ratio) { Player& tux = *world->get_tux(); @@ -428,9 +428,9 @@ play_current_music(); } - tux.action(); + tux.action(frame_ratio); - world->action(); + world->action(frame_ratio); return -1; } @@ -496,7 +496,7 @@ while (!done && !quit) { /* Calculate the movement-factor */ - frame_ratio = ((double)(update_time-last_update_time))/((double)FRAME_RATE); + 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; @@ -555,7 +555,7 @@ frame_ratio = 1; while(z >= 1) {*/ - if (action() == 0) + if (action(frame_ratio) == 0) { /* == 0: no more lives */ /* == -1: continues */ Index: gameloop.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.h,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- gameloop.h 11 Apr 2004 14:55:59 -0000 1.35 +++ gameloop.h 11 Apr 2004 15:28:26 -0000 1.36 @@ -62,7 +62,7 @@ int run(); void draw(); - int action(); + int action(double frame_ratio); Level* get_level() { return world->get_level(); } World* get_world() { return world; } Index: physic.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/physic.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- physic.h 11 Apr 2004 14:44:19 -0000 1.8 +++ physic.h 11 Apr 2004 15:28:26 -0000 1.9 @@ -43,7 +43,7 @@ void enable_gravity(bool gravity_enabled); /** applies the physical simulation to given x and y coordinates */ - void apply(float &x, float &y); + void apply(float frame_ratio, float &x, float &y); private: /// horizontal and vertical acceleration Index: physic.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/physic.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- physic.cpp 11 Apr 2004 14:44:19 -0000 1.6 +++ physic.cpp 11 Apr 2004 15:28:26 -0000 1.7 @@ -79,7 +79,7 @@ } void -Physic::apply(float &x, float &y) +Physic::apply(float frame_ratio, float &x, float &y) { float gravity = World::current()->get_level()->gravity; float grav; Index: badguy.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.h,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- badguy.h 10 Apr 2004 11:42:43 -0000 1.21 +++ badguy.h 11 Apr 2004 15:28:26 -0000 1.22 @@ -108,7 +108,7 @@ public: void init(float x, float y, BadGuyKind kind); - void action(); + void action(float frame_ratio); void draw(); void collision(void* p_c_object, int c_object, @@ -120,18 +120,18 @@ void kill_me(); private: - void action_bsod(); - void action_laptop(); - void action_money(); - void action_bomb(); - void action_mrbomb(); - void action_stalactite(); - void action_flame(); - void action_fish(); - void action_bouncingsnowball(); - void action_flyingsnowball(); - void action_spiky(); - void action_snowball(); + void action_bsod(float frame_ratio); + void action_laptop(float frame_ratio); + void action_money(float frame_ratio); + void action_bomb(float frame_ratio); + void action_mrbomb(float frame_ratio); + void action_stalactite(float frame_ratio); + void action_flame(float frame_ratio); + void action_fish(float frame_ratio); + void action_bouncingsnowball(float frame_ratio); + void action_flyingsnowball(float frame_ratio); + void action_spiky(float frame_ratio); + void action_snowball(float frame_ratio); /** handles falling down. disables gravity calculation when we're back on * ground */ Index: gameobjs.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameobjs.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- gameobjs.cpp 11 Apr 2004 13:05:35 -0000 1.4 +++ gameobjs.cpp 11 Apr 2004 15:28:26 -0000 1.5 @@ -31,7 +31,7 @@ } void -BouncyDistro::action() +BouncyDistro::action(double frame_ratio) { base.y = base.y + base.ym * frame_ratio; @@ -64,7 +64,7 @@ } void -BrokenBrick::action() +BrokenBrick::action(double frame_ratio) { base.x = base.x + base.xm * frame_ratio; base.y = base.y + base.ym * frame_ratio; @@ -103,10 +103,9 @@ } void -BouncyBrick::action() +BouncyBrick::action(double frame_ratio) { - offset = (offset + - offset_m * frame_ratio); + offset = (offset + offset_m * frame_ratio); /* Go back down? */ if (offset < -BOUNCY_BRICK_MAX_OFFSET) @@ -166,7 +165,7 @@ } void -FloatingScore::action() +FloatingScore::action(double frame_ratio) { base.y = base.y - 2 * frame_ratio; Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- player.cpp 11 Apr 2004 15:07:29 -0000 1.27 +++ player.cpp 11 Apr 2004 15:28:26 -0000 1.28 @@ -157,7 +157,7 @@ } void -Player::action() +Player::action(double frame_ratio) { bool jumped_in_solid = false; @@ -169,7 +169,7 @@ /* Move tux: */ previous_base = base; - physic.apply(base.x, base.y); + physic.apply(frame_ratio, base.x, base.y); if (!dying) { Index: player.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.h,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- player.h 11 Apr 2004 14:44:19 -0000 1.22 +++ player.h 11 Apr 2004 15:28:26 -0000 1.23 @@ -121,7 +121,7 @@ void init(); int key_event(SDLKey key, int state); void level_begin(); - void action(); + void action(double frame_ratio); void handle_input(); void grabdistros(); void draw(); Index: title.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/title.cpp,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- title.cpp 11 Apr 2004 14:44:19 -0000 1.30 +++ title.cpp 11 Apr 2004 15:28:26 -0000 1.31 @@ -63,7 +63,7 @@ texture_draw_bg(&bkg_title); } -void draw_demo(GameSession* session) +void draw_demo(GameSession* session, double frame_ratio) { World::set_current(session->get_world()); //World* world = session->get_world(); @@ -118,8 +118,10 @@ scroll_x = tux->base.x - 320; } + + float last_tux_x_pos = tux->base.x; - tux->action(); + tux->action(frame_ratio); // Jump if tux stays in the same position for one loop, ie. if he is // stuck behind a wall @@ -176,7 +178,7 @@ while (!done) { /* Calculate the movement-factor */ - frame_ratio = ((double)(update_time-last_update_time))/((double)FRAME_RATE); + 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; /* Lower the frame_ratio that Tux doesn't jump to hectically throught the demo. */ @@ -209,7 +211,7 @@ /* Draw the background: */ draw_background(); - draw_demo(&session); + draw_demo(&session, frame_ratio); if (current_menu == main_menu) texture_draw(&logo, 160, 30); Index: world.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- world.cpp 11 Apr 2004 15:07:29 -0000 1.19 +++ world.cpp 11 Apr 2004 15:28:26 -0000 1.20 @@ -208,15 +208,15 @@ } void -World::action() +World::action(double frame_ratio) { /* Handle bouncy distros: */ for (unsigned int i = 0; i < bouncy_distros.size(); i++) - bouncy_distros[i].action(); + bouncy_distros[i].action(frame_ratio); /* Handle broken bricks: */ for (unsigned int i = 0; i < broken_bricks.size(); i++) - broken_bricks[i].action(); + broken_bricks[i].action(frame_ratio); /* Handle distro counting: */ if (counting_distros) @@ -229,19 +229,19 @@ // Handle all kinds of game objects for (unsigned int i = 0; i < bouncy_bricks.size(); i++) - bouncy_bricks[i].action(); + bouncy_bricks[i].action(frame_ratio); for (unsigned int i = 0; i < floating_scores.size(); i++) - floating_scores[i].action(); + floating_scores[i].action(frame_ratio); for (unsigned int i = 0; i < bullets.size(); ++i) - bullets[i].action(); + bullets[i].action(frame_ratio); for (unsigned int i = 0; i < upgrades.size(); i++) - upgrades[i].action(); + upgrades[i].action(frame_ratio); for (unsigned int i = 0; i < bad_guys.size(); i++) - bad_guys[i].action(); + bad_guys[i].action(frame_ratio); /* update particle systems */ std::vector<ParticleSystem*>::iterator p; |
From: Ingo R. <gr...@us...> - 2004-04-11 15:21:10
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29561 Modified Files: badguy.cpp gameloop.cpp player.cpp resources.cpp scene.cpp scene.h special.cpp world.cpp Log Message: - moved some global variables into a seperate class Index: scene.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/scene.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- scene.cpp 11 Apr 2004 14:55:59 -0000 1.17 +++ scene.cpp 11 Apr 2004 15:07:29 -0000 1.18 @@ -13,11 +13,7 @@ #include <stdlib.h> #include "scene.h" -int score; -int distros; -int next_level; -int score_multiplier; -timer_type super_bkgd_timer; +PlayerStatus player_status; // FIXME: Move this into a view class float scroll_x; Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.58 retrieving revision 1.59 diff -u -d -r1.58 -r1.59 --- gameloop.cpp 11 Apr 2004 14:55:59 -0000 1.58 +++ gameloop.cpp 11 Apr 2004 15:07:29 -0000 1.59 @@ -249,11 +249,11 @@ break; case SDLK_END: if(debug_mode) - distros += 50; + player_status.distros += 50; break; case SDLK_SPACE: if(debug_mode) - next_level = 1; + player_status.next_level = 1; break; case SDLK_DELETE: if(debug_mode) @@ -269,7 +269,7 @@ break; case SDLK_s: if(debug_mode) - score += 1000; + player_status.score += 1000; case SDLK_f: if(debug_fps) debug_fps = false; @@ -342,16 +342,16 @@ { Player& tux = *world->get_tux(); - if (tux.is_dead() || next_level) + if (tux.is_dead() || player_status.next_level) { /* Tux either died, or reached the end of a level! */ halt_music(); - if (next_level) + if (player_status.next_level) { /* End of a level! */ levelnb++; - next_level = 0; + player_status.next_level = 0; if(st_gl_mode != ST_GL_TEST) { drawresultscreen(); @@ -381,8 +381,8 @@ if(st_gl_mode != ST_GL_TEST) { - if (score > hs_score) - save_hs(score); + if (player_status.score > hs_score) + save_hs(player_status.score); } world->get_level()->free_gfx(); @@ -660,7 +660,7 @@ Player& tux = *world->get_tux(); char str[60]; - sprintf(str, "%d", score); + sprintf(str, "%d", player_status.score); text_draw(&white_text, "SCORE", 0, 0, 1); text_draw(&gold_text, str, 96, 0, 1); @@ -682,7 +682,7 @@ text_draw(&gold_text, str, 304, 0, 1); } - sprintf(str, "%d", distros); + sprintf(str, "%d", player_status.distros); text_draw(&white_text, "DISTROS", screen->h, 0, 1); text_draw(&gold_text, str, 608, 0, 1); @@ -710,10 +710,10 @@ text_drawf(&blue_text, "GAMEOVER", 0, 200, A_HMIDDLE, A_TOP, 1); - sprintf(str, "SCORE: %d", score); + sprintf(str, "SCORE: %d", player_status.score); text_drawf(&gold_text, str, 0, 224, A_HMIDDLE, A_TOP, 1); - sprintf(str, "DISTROS: %d", distros); + sprintf(str, "DISTROS: %d", player_status.distros); text_drawf(&gold_text, str, 0, 256, A_HMIDDLE, A_TOP, 1); flipscreen(); @@ -731,10 +731,10 @@ text_drawf(&blue_text, "Result:", 0, 200, A_HMIDDLE, A_TOP, 1); - sprintf(str, "SCORE: %d", score); + sprintf(str, "SCORE: %d", player_status.score); text_drawf(&gold_text, str, 0, 224, A_HMIDDLE, A_TOP, 1); - sprintf(str, "DISTROS: %d", distros); + sprintf(str, "DISTROS: %d", player_status.distros); text_drawf(&gold_text, str, 0, 256, A_HMIDDLE, A_TOP, 1); flipscreen(); Index: special.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/special.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- special.cpp 11 Apr 2004 14:55:59 -0000 1.11 +++ special.cpp 11 Apr 2004 15:07:29 -0000 1.12 @@ -261,19 +261,16 @@ pplayer->base.y += 32; pplayer->duck = true; } - timer_start(&super_bkgd_timer, 350); } else if (kind == UPGRADE_COFFEE) { play_sound(sounds[SND_COFFEE], SOUND_CENTER_SPEAKER); pplayer->got_coffee = true; - timer_start(&super_bkgd_timer, 250); } else if (kind == UPGRADE_HERRING) { play_sound(sounds[SND_HERRING], SOUND_CENTER_SPEAKER); timer_start(&pplayer->invincible_timer,TUX_INVINCIBLE_TIME); - timer_start(&super_bkgd_timer, 250); /* play the herring song ^^ */ if (get_current_music() != HURRYUP_MUSIC) { Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- player.cpp 11 Apr 2004 14:44:19 -0000 1.26 +++ player.cpp 11 Apr 2004 15:07:29 -0000 1.27 @@ -201,7 +201,7 @@ physic.enable_gravity(false); /* Reset score multiplier (for multi-hits): */ - score_multiplier = 1; + player_status.score_multiplier = 1; } if(jumped_in_solid) @@ -289,7 +289,7 @@ if (base.x >= World::current()->get_level()->endpos && World::current()->get_level()->endpos != 0) { - next_level = 1; + player_status.next_level = 1; } } @@ -830,7 +830,7 @@ play_sound(sounds[SND_FALL], SOUND_CENTER_SPEAKER); World::current()->add_score(pbad_c->base.x - scroll_x, pbad_c->base.y, - 25 * score_multiplier); + 25 * player_status.score_multiplier); } } } @@ -845,7 +845,7 @@ pbad_c->kill_me(); } } - score_multiplier++; + player_status.score_multiplier++; } break; default: Index: badguy.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- badguy.cpp 11 Apr 2004 14:44:19 -0000 1.25 +++ badguy.cpp 11 Apr 2004 15:07:29 -0000 1.26 @@ -791,9 +791,10 @@ { make_player_jump(player); - World::current()->add_score(base.x - scroll_x, base.y, 50 * score_multiplier); + World::current()->add_score(base.x - scroll_x, + base.y, 50 * player_status.score_multiplier); play_sound(sounds[SND_SQUISH], SOUND_CENTER_SPEAKER); - score_multiplier++; + player_status.score_multiplier++; dying = DYING_SQUISHED; timer_start(&timer, 2000); @@ -808,9 +809,9 @@ World::current()->add_bad_guy(base.x, base.y, BAD_BOMB); make_player_jump(player); - World::current()->add_score(base.x - scroll_x, base.y, 50 * score_multiplier); + World::current()->add_score(base.x - scroll_x, base.y, 50 * player_status.score_multiplier); play_sound(sounds[SND_SQUISH], SOUND_CENTER_SPEAKER); - score_multiplier++; + player_status.score_multiplier++; remove_me(); return; @@ -849,14 +850,14 @@ make_player_jump(player); - World::current()->add_score(base.x - scroll_x, base.y, 25 * score_multiplier); - score_multiplier++; + World::current()->add_score(base.x - scroll_x, base.y, 25 * player_status.score_multiplier); + player_status.score_multiplier++; return; } else if(kind == BAD_FISH) { make_player_jump(player); - World::current()->add_score(base.x - scroll_x, base.y, 25 * score_multiplier); - score_multiplier++; + World::current()->add_score(base.x - scroll_x, base.y, 25 * player_status.score_multiplier); + player_status.score_multiplier++; // simply remove the fish... remove_me(); @@ -894,10 +895,10 @@ /* Gain some points: */ if (kind == BAD_BSOD) World::current()->add_score(base.x - scroll_x, base.y, - 50 * score_multiplier); + 50 * player_status.score_multiplier); else World::current()->add_score(base.x - scroll_x, base.y, - 25 * score_multiplier); + 25 * player_status.score_multiplier); /* Play death sound: */ play_sound(sounds[SND_FALL], SOUND_CENTER_SPEAKER); Index: world.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- world.cpp 11 Apr 2004 14:55:59 -0000 1.18 +++ world.cpp 11 Apr 2004 15:07:29 -0000 1.19 @@ -56,8 +56,7 @@ // Set defaults: scroll_x = 0; - score_multiplier = 1; - timer_init(&super_bkgd_timer, true); + player_status.score_multiplier = 1; counting_distros = false; distro_counter = 0; @@ -128,24 +127,18 @@ { int y,x; - /* Draw screen: */ - if(timer_check(&super_bkgd_timer)) - texture_draw(&img_super_bkgd, 0, 0); + /* Draw the real background */ + if(get_level()->bkgd_image[0] != '\0') + { + int s = (int)scroll_x / 30; + texture_draw_part(&level->img_bkgd, s, 0,0,0,level->img_bkgd.w - s, level->img_bkgd.h); + texture_draw_part(&level->img_bkgd, 0, 0,screen->w - s ,0,s,level->img_bkgd.h); + } else { - /* Draw the real background */ - if(get_level()->bkgd_image[0] != '\0') - { - int s = (int)scroll_x / 30; - texture_draw_part(&level->img_bkgd, s, 0,0,0,level->img_bkgd.w - s, level->img_bkgd.h); - texture_draw_part(&level->img_bkgd, 0, 0,screen->w - s ,0,s,level->img_bkgd.h); - } - else - { - clearscreen(level->bkgd_red, level->bkgd_green, level->bkgd_blue); - } + clearscreen(level->bkgd_red, level->bkgd_green, level->bkgd_blue); } - + /* Draw particle systems (background) */ std::vector<ParticleSystem*>::iterator p; for(p = particle_systems.begin(); p != particle_systems.end(); ++p) @@ -346,7 +339,7 @@ void World::add_score(float x, float y, int s) { - score += s; + player_status.score += s; FloatingScore new_floating_score; new_floating_score.init(x,y,s); @@ -439,8 +432,8 @@ plevel->change(x, y, TM_IA, tile->next_tile); play_sound(sounds[SND_DISTRO], SOUND_CENTER_SPEAKER); - score = score + SCORE_DISTRO; - distros++; + player_status.score = player_status.score + SCORE_DISTRO; + player_status.distros++; } else if (!small) { @@ -454,7 +447,7 @@ /* Get some score: */ play_sound(sounds[SND_BRICK], SOUND_CENTER_SPEAKER); - score = score + SCORE_BRICK; + player_status.score = player_status.score + SCORE_BRICK; } } } @@ -478,8 +471,8 @@ case 1: // Box with a distro! add_bouncy_distro(((int)(x + 1) / 32) * 32, (int)(y / 32) * 32 - 32); play_sound(sounds[SND_DISTRO], SOUND_CENTER_SPEAKER); - score = score + SCORE_DISTRO; - distros++; + player_status.score = player_status.score + SCORE_DISTRO; + player_status.distros++; break; case 2: // Add an upgrade! @@ -517,8 +510,8 @@ (int)(y / 32) * 32); } - score = score + SCORE_DISTRO; - distros++; + player_status.score = player_status.score + SCORE_DISTRO; + player_status.distros++; } } Index: scene.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/scene.h,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- scene.h 11 Apr 2004 14:55:59 -0000 1.20 +++ scene.h 11 Apr 2004 15:07:29 -0000 1.21 @@ -19,10 +19,15 @@ #define FRAME_RATE 10 // 100 Frames per second (10ms) // Player stats -extern int score; -extern int distros; -extern int next_level; -extern int score_multiplier; +struct PlayerStatus +{ + int score; + int distros; + int next_level; + int score_multiplier; +}; + +extern PlayerStatus player_status; extern timer_type super_bkgd_timer; extern float scroll_x; Index: resources.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/resources.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- resources.cpp 11 Apr 2004 14:55:59 -0000 1.5 +++ resources.cpp 11 Apr 2004 15:07:29 -0000 1.6 @@ -17,7 +17,6 @@ texture_type img_box_empty; texture_type img_mints; texture_type img_coffee; -texture_type img_super_bkgd; texture_type img_red_glow; /* Load graphics/sounds shared between all levels: */ @@ -284,12 +283,6 @@ USE_ALPHA); - /* Super background: */ - - texture_load(&img_super_bkgd, datadir + "/images/shared/super-bkgd.png", - IGNORE_ALPHA); - - /* Sound effects: */ /* if (use_sound) // this will introduce SERIOUS bugs here ! because "load_sound" |
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27691 Modified Files: gameloop.cpp gameloop.h resources.cpp resources.h scene.cpp scene.h special.cpp world.cpp world.h Log Message: - localized some more variables Index: scene.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/scene.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- scene.cpp 11 Apr 2004 14:44:19 -0000 1.16 +++ scene.cpp 11 Apr 2004 14:55:59 -0000 1.17 @@ -15,11 +15,8 @@ int score; int distros; -int level; int next_level; int score_multiplier; -bool counting_distros; -int distro_counter; timer_type super_bkgd_timer; // FIXME: Move this into a view class @@ -27,12 +24,6 @@ unsigned int global_frame_counter; -texture_type img_box_full; -texture_type img_box_empty; -texture_type img_mints; -texture_type img_coffee; -texture_type img_super_bkgd; -texture_type img_red_glow; timer_type time_left; double frame_ratio; Index: world.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.h,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- world.h 11 Apr 2004 14:44:19 -0000 1.19 +++ world.h 11 Apr 2004 14:55:59 -0000 1.20 @@ -50,8 +50,10 @@ std::vector<Bullet> bullets; std::vector<ParticleSystem*> particle_systems; - static World* current_; + int distro_counter; + bool counting_distros; + static World* current_; public: static World* current() { return current_; } static void set_current(World* w) { current_ = w; } @@ -113,3 +115,7 @@ #endif /*SUPERTUX_WORLD_H*/ +/* Local Variables: */ +/* mode:c++ */ +/* End */ + Index: resources.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/resources.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- resources.h 11 Apr 2004 00:10:53 -0000 1.1 +++ resources.h 11 Apr 2004 14:55:59 -0000 1.2 @@ -8,6 +8,13 @@ extern texture_type img_flag[2]; extern texture_type img_cloud[2][4]; +extern texture_type img_box_full; +extern texture_type img_box_empty; +extern texture_type img_mints; +extern texture_type img_coffee; +extern texture_type img_super_bkgd; +extern texture_type img_red_glow; + void loadshared(); void unloadshared(); Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.57 retrieving revision 1.58 diff -u -d -r1.57 -r1.58 --- gameloop.cpp 11 Apr 2004 14:44:19 -0000 1.57 +++ gameloop.cpp 11 Apr 2004 14:55:59 -0000 1.58 @@ -73,8 +73,9 @@ world->load(filename); } -GameSession::GameSession(const std::string& subset_, int levelnb, int mode) - : subset(subset_) +GameSession::GameSession(const std::string& subset_, int levelnb_, int mode) + : subset(subset_), + levelnb(levelnb_) { init(); @@ -86,8 +87,7 @@ timer_init(&frame_timer, true); st_gl_mode = mode; - level = levelnb; - + /* Init the game: */ world->arrays_free(); world->set_defaults(); @@ -99,7 +99,7 @@ } else { - if(world->load(subset, level) != 0) + if(world->load(subset, levelnb) != 0) exit(1); } @@ -137,7 +137,7 @@ /* Level Intro: */ clearscreen(0, 0, 0); - sprintf(str, "LEVEL %d", level); + sprintf(str, "LEVEL %d", levelnb); text_drawf(&blue_text, str, 0, 200, A_HMIDDLE, A_TOP, 1); sprintf(str, "%s", world->get_level()->name.c_str()); @@ -350,7 +350,7 @@ if (next_level) { /* End of a level! */ - level++; + levelnb++; next_level = 0; if(st_gl_mode != ST_GL_TEST) { @@ -408,7 +408,7 @@ } else { - if(world->get_level()->load(subset, level) != 0) + if(world->get_level()->load(subset, levelnb) != 0) return 0; } Index: special.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/special.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- special.cpp 11 Apr 2004 13:20:43 -0000 1.10 +++ special.cpp 11 Apr 2004 14:55:59 -0000 1.11 @@ -19,6 +19,7 @@ #include "scene.h" #include "globals.h" #include "player.h" +#include "resources.h" texture_type img_bullet; texture_type img_golden_herring; Index: gameloop.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.h,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- gameloop.h 11 Apr 2004 14:44:19 -0000 1.34 +++ gameloop.h 11 Apr 2004 14:55:59 -0000 1.35 @@ -50,6 +50,7 @@ // FIXME: Hack for restarting the level std::string subset; + int levelnb; public: GameSession(); Index: world.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- world.cpp 11 Apr 2004 14:44:19 -0000 1.17 +++ world.cpp 11 Apr 2004 14:55:59 -0000 1.18 @@ -27,6 +27,7 @@ #include "world.h" #include "level.h" #include "tile.h" +#include "resources.h" texture_type img_distro[4]; Index: scene.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/scene.h,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- scene.h 11 Apr 2004 14:44:19 -0000 1.19 +++ scene.h 11 Apr 2004 14:55:59 -0000 1.20 @@ -18,19 +18,16 @@ #define FRAME_RATE 10 // 100 Frames per second (10ms) +// Player stats extern int score; extern int distros; -extern int level; extern int next_level; extern int score_multiplier; -extern bool counting_distros; -extern int distro_counter; extern timer_type super_bkgd_timer; extern float scroll_x; extern unsigned int global_frame_counter; -extern texture_type img_box_full, img_box_empty, img_mints, img_coffee, img_super_bkgd, img_red_glow; extern timer_type time_left; extern double frame_ratio; Index: resources.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/resources.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- resources.cpp 11 Apr 2004 14:44:19 -0000 1.4 +++ resources.cpp 11 Apr 2004 14:55:59 -0000 1.5 @@ -13,6 +13,13 @@ texture_type img_flag[2]; texture_type img_cloud[2][4]; +texture_type img_box_full; +texture_type img_box_empty; +texture_type img_mints; +texture_type img_coffee; +texture_type img_super_bkgd; +texture_type img_red_glow; + /* Load graphics/sounds shared between all levels: */ void loadshared() { |
From: Ingo R. <gr...@us...> - 2004-04-11 14:58:00
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25520 Modified Files: badguy.cpp collision.cpp gameloop.cpp gameloop.h level.cpp level.h leveleditor.cpp particlesystem.cpp physic.cpp physic.h player.cpp player.h resources.cpp scene.cpp scene.h setup.cpp title.cpp world.cpp world.h worldmap.cpp Log Message: - made some more global variables, local - replaced a few char* with string Index: scene.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/scene.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- scene.cpp 11 Apr 2004 11:52:29 -0000 1.15 +++ scene.cpp 11 Apr 2004 14:44:19 -0000 1.16 @@ -17,16 +17,16 @@ int distros; int level; int next_level; -int game_pause; int score_multiplier; -int endpos; bool counting_distros; int distro_counter; timer_type super_bkgd_timer; + +// FIXME: Move this into a view class float scroll_x; + unsigned int global_frame_counter; -Player tux; texture_type img_box_full; texture_type img_box_empty; texture_type img_mints; Index: world.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.h,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- world.h 11 Apr 2004 13:20:43 -0000 1.18 +++ world.h 11 Apr 2004 14:44:19 -0000 1.19 @@ -25,15 +25,20 @@ #include "type.h" #include "scene.h" #include "special.h" +#include "badguy.h" #include "particlesystem.h" #include "gameobjs.h" +class Level; + /** The World class holds a level and all the game objects (badguys, bouncy distros, etc) that are needed to run a game. */ class World { public: Level* level; + + Player tux; std::vector<BouncyDistro> bouncy_distros; std::vector<BrokenBrick> broken_bricks; @@ -46,13 +51,16 @@ std::vector<ParticleSystem*> particle_systems; static World* current_; + public: static World* current() { return current_; } + static void set_current(World* w) { current_ = w; } World(); ~World(); - Level* get_level() { return level; } + Level* get_level() { return level; } + Player* get_tux() { return &tux; } void set_defaults(); @@ -68,7 +76,7 @@ /** Load data for this level: Returns -1, if the loading of the level failed. */ - int load(const char* subset, int level); + int load(const std::string& subset, int level); /** Load data for this level: Returns -1, if the loading of the level failed. */ Index: physic.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/physic.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- physic.cpp 10 Apr 2004 20:16:15 -0000 1.5 +++ physic.cpp 11 Apr 2004 14:44:19 -0000 1.6 @@ -15,8 +15,8 @@ #include "defines.h" #include "physic.h" #include "timer.h" - -float gravity; +#include "world.h" +#include "level.h" Physic::Physic() : ax(0), ay(0), vx(0), vy(0), gravity_enabled(true) @@ -81,14 +81,15 @@ void Physic::apply(float &x, float &y) { - float grav; - if(gravity_enabled) - grav = gravity / 100.0; - else - grav = 0; + float gravity = World::current()->get_level()->gravity; + float grav; + if(gravity_enabled) + grav = gravity / 100.0; + else + grav = 0; - x += vx * frame_ratio + ax * frame_ratio * frame_ratio; - y += vy * frame_ratio + (ay + grav) * frame_ratio * frame_ratio; - vx += ax * frame_ratio; - vy += (ay + grav) * frame_ratio; + x += vx * frame_ratio + ax * frame_ratio * frame_ratio; + y += vy * frame_ratio + (ay + grav) * frame_ratio * frame_ratio; + vx += ax * frame_ratio; + vy += (ay + grav) * frame_ratio; } Index: particlesystem.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/particlesystem.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- particlesystem.cpp 28 Mar 2004 14:07:59 -0000 1.3 +++ particlesystem.cpp 11 Apr 2004 14:44:19 -0000 1.4 @@ -21,6 +21,8 @@ #include <iostream> #include <math.h> #include "globals.h" +#include "world.h" +#include "level.h" #include "scene.h" ParticleSystem::ParticleSystem() @@ -85,7 +87,7 @@ do { particle->speed = snowsize/60.0 + (float(rand()%10)/300.0); } while(particle->speed < 0.01); - particle->speed *= gravity; + particle->speed *= World::current()->get_level()->gravity; particles.push_back(particle); } Index: player.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.h,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- player.h 9 Apr 2004 02:19:09 -0000 1.21 +++ player.h 11 Apr 2004 14:44:19 -0000 1.22 @@ -93,10 +93,12 @@ class Player { public: - player_input_type input; player_keymap_type keymap; + int lives; int score; int distros; + + player_input_type input; bool got_coffee; int size; bool duck; @@ -105,10 +107,10 @@ bool jumping; int frame_; int frame_main; - int lives; - base_type base; - base_type old_base; - base_type previous_base; + + base_type base; + base_type old_base; + base_type previous_base; timer_type invincible_timer; timer_type skidding_timer; timer_type safe_timer; @@ -131,6 +133,7 @@ void keep_in_bounds(); bool on_ground(); bool under_solid(); + private: void handle_horizontal_input(int dir); void handle_vertical_input(); Index: worldmap.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- worldmap.cpp 11 Apr 2004 01:51:42 -0000 1.21 +++ worldmap.cpp 11 Apr 2004 14:44:19 -0000 1.22 @@ -419,7 +419,7 @@ { std::cout << "Enter the current level: " << i->name << std::endl;; halt_music(); - GameSession session(const_cast<char*>((datadir + "levels/default/" + i->name).c_str()), + GameSession session(datadir + "levels/default/" + i->name, 1, ST_GL_LOAD_LEVEL_FILE); session.run(); play_music(song, 1); Index: scene.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/scene.h,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- scene.h 11 Apr 2004 11:52:29 -0000 1.18 +++ scene.h 11 Apr 2004 14:44:19 -0000 1.19 @@ -13,30 +13,23 @@ #ifndef SUPERTUX_SCENE_H #define SUPERTUX_SCENE_H -#include "defines.h" -#include "player.h" -#include "badguy.h" -#include "special.h" -#include "level.h" -#include "particlesystem.h" +#include "texture.h" +#include "timer.h" #define FRAME_RATE 10 // 100 Frames per second (10ms) -extern int score; -extern int distros; -extern int level; -extern int next_level; -extern int game_pause; -extern int score_multiplier; -extern int endpos; +extern int score; +extern int distros; +extern int level; +extern int next_level; +extern int score_multiplier; extern bool counting_distros; -extern int distro_counter; +extern int distro_counter; extern timer_type super_bkgd_timer; extern float scroll_x; extern unsigned int global_frame_counter; -extern Player tux; extern texture_type img_box_full, img_box_empty, img_mints, img_coffee, img_super_bkgd, img_red_glow; extern timer_type time_left; extern double frame_ratio; Index: badguy.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- badguy.cpp 11 Apr 2004 12:37:40 -0000 1.24 +++ badguy.cpp 11 Apr 2004 14:44:19 -0000 1.25 @@ -231,6 +231,8 @@ void BadGuy::action_laptop() { + Player& tux = *World::current()->get_tux(); + fall(); /* Move left/right: */ @@ -244,7 +246,7 @@ else if (mode == HELD) { /* FIXME: The pbad object shouldn't know about pplayer objects. */ /* If we're holding the laptop */ - dir=tux.dir; + dir = tux.dir; if(dir==RIGHT) { base.x = tux.base.x + 16; @@ -386,6 +388,8 @@ void BadGuy::action_money() { + Player& tux = *World::current()->get_tux(); + static const float JUMPV = 6; fall(); @@ -459,6 +463,8 @@ void BadGuy::action_stalactite() { + Player& tux = *World::current()->get_tux(); + static const int SHAKETIME = 800; static const int RANGE = 40; Index: level.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level.h,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- level.h 11 Apr 2004 11:52:29 -0000 1.24 +++ level.h 11 Apr 2004 14:44:19 -0000 1.25 @@ -68,6 +68,7 @@ int bkgd_green; int bkgd_blue; int width; + int endpos; float gravity; std::vector<BadGuyData> badguy_data; @@ -80,7 +81,7 @@ /** Load data for this level: Returns -1, if the loading of the level failed. */ - int load(const char* subset, int level); + int load(const std::string& subset, int level); /** Load data for this level: Returns -1, if the loading of the level failed. */ Index: gameloop.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.h,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- gameloop.h 11 Apr 2004 13:05:35 -0000 1.33 +++ gameloop.h 11 Apr 2004 14:44:19 -0000 1.34 @@ -36,18 +36,32 @@ { private: bool quit; - timer_type fps_timer, frame_timer; + timer_type fps_timer; + timer_type frame_timer; World* world; + int st_gl_mode; + + float fps_fps; + unsigned int last_update_time; + unsigned int update_time; + int pause_menu_frame; + int debug_fps; + bool game_pause; + + // FIXME: Hack for restarting the level + std::string subset; public: GameSession(); GameSession(const std::string& filename); GameSession(const std::string& subset, int levelnb, int mode); - + ~GameSession(); + + /** Enter the busy loop */ int run(); + void draw(); int action(); - void process_events(); Level* get_level() { return world->get_level(); } World* get_world() { return world; } @@ -59,8 +73,15 @@ private: static GameSession* current_; - void levelintro(); + void init(); + void start_timers(); + void process_events(); + + void levelintro(); + void drawstatus(); + void drawendscreen(); + void drawresultscreen(void); }; std::string slotinfo(int slot); Index: physic.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/physic.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- physic.h 4 Apr 2004 00:32:10 -0000 1.7 +++ physic.h 11 Apr 2004 14:44:19 -0000 1.8 @@ -54,7 +54,4 @@ bool gravity_enabled; }; -/* global variables. */ -extern float gravity; - #endif /*SUPERTUX_PHYSIC_H*/ Index: setup.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/setup.cpp,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- setup.cpp 10 Apr 2004 22:01:26 -0000 1.28 +++ setup.cpp 11 Apr 2004 14:44:19 -0000 1.29 @@ -397,7 +397,7 @@ options_controls_menu->additem(MN_LABEL,"Controls",0,0); options_controls_menu->additem(MN_HL,"",0,0); - options_controls_menu->additem(MN_CONTROLFIELD,"Move Right",tux.keymap.right,0); + //FIXME:options_controls_menu->additem(MN_CONTROLFIELD,"Move Right", tux.keymap.right,0); options_controls_menu->additem(MN_HL,"",0,0); options_controls_menu->additem(MN_BACK,"Back",0,0); @@ -475,7 +475,10 @@ Menu::set_current(main_menu); } else - { // Slot contains a level, so load it + { + puts("Warning: Loading games isn't supported at the moment"); +#if 0 + // Slot contains a level, so load it if (game_started) { GameSession session("default",slot - 1,ST_GL_LOAD_GAME); @@ -487,8 +490,8 @@ else { //loadgame(slot - 1); - puts("Warning: Loading games isn't supported at the moment"); } +#endif } st_pause_ticks_stop(); return true; Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.56 retrieving revision 1.57 diff -u -d -r1.56 -r1.57 --- gameloop.cpp 11 Apr 2004 13:05:35 -0000 1.56 +++ gameloop.cpp 11 Apr 2004 14:44:19 -0000 1.57 @@ -42,31 +42,15 @@ #include "collision.h" #include "tile.h" #include "particlesystem.h" - -/* extern variables */ - -int game_started = false; - -/* Local variables: */ -static SDL_Event event; -static SDLKey key; -static char level_subset[100]; -static float fps_fps; -static int st_gl_mode; -static unsigned int last_update_time; -static unsigned int update_time; -static int pause_menu_frame; -static int debug_fps; +#include "resources.h" GameSession* GameSession::current_ = 0; -/* Local function prototypes: */ -void levelintro(void); -void loadshared(void); -void unloadshared(void); -void drawstatus(void); -void drawendscreen(void); -void drawresultscreen(void); +void +GameSession::init() +{ + game_pause = false; +} GameSession::GameSession() { @@ -76,9 +60,12 @@ GameSession::GameSession(const std::string& filename) { + init(); + + //assert(!"Don't call me"); current_ = this; - world = &::global_world; + world = new World; // &::global_world; timer_init(&fps_timer, true); timer_init(&frame_timer, true); @@ -86,34 +73,33 @@ world->load(filename); } -GameSession::GameSession(const std::string& subset, int levelnb, int mode) +GameSession::GameSession(const std::string& subset_, int levelnb, int mode) + : subset(subset_) { + init(); + current_ = this; - world = &::global_world; + world = new World; // &::global_world; timer_init(&fps_timer, true); timer_init(&frame_timer, true); - game_started = true; - st_gl_mode = mode; - level = levelnb; + level = levelnb; /* Init the game: */ world->arrays_free(); world->set_defaults(); - strcpy(level_subset, subset.c_str()); - if (st_gl_mode == ST_GL_LOAD_LEVEL_FILE) { - if (world->load(level_subset)) + if (world->load(subset)) exit(1); } else { - if(world->load(level_subset, level) != 0) + if(world->load(subset, level) != 0) exit(1); } @@ -124,8 +110,6 @@ world->activate_particle_systems(); world->get_level()->load_song(); - tux.init(); - if(st_gl_mode != ST_GL_TEST) load_hs(); @@ -139,9 +123,16 @@ loadgame(levelnb); } +GameSession::~GameSession() +{ + delete world; +} + void GameSession::levelintro(void) { + Player& tux = *world->get_tux(); + char str[60]; /* Level Intro: */ clearscreen(0, 0, 0); @@ -173,6 +164,9 @@ void GameSession::process_events() { + Player& tux = *world->get_tux(); + + SDL_Event event; while (SDL_PollEvent(&event)) { /* Check for menu-events, if the menu is shown */ @@ -185,103 +179,107 @@ quit = true; break; case SDL_KEYDOWN: /* A keypress! */ - key = event.key.keysym.sym; - - if(tux.key_event(key,DOWN)) - break; - - switch(key) - { - case SDLK_ESCAPE: /* Escape: Open/Close the menu: */ - if(!game_pause) - { - if(st_gl_mode == ST_GL_TEST) - quit = true; - else if(show_menu) - { - Menu::set_current(game_menu); - show_menu = 0; - st_pause_ticks_stop(); - } - else - { - Menu::set_current(game_menu); - show_menu = 1; - st_pause_ticks_start(); - } - } - break; - default: + { + SDLKey key = event.key.keysym.sym; + + if(tux.key_event(key,DOWN)) break; - } + + switch(key) + { + case SDLK_ESCAPE: /* Escape: Open/Close the menu: */ + if(!game_pause) + { + if(st_gl_mode == ST_GL_TEST) + quit = true; + else if(show_menu) + { + Menu::set_current(game_menu); + show_menu = 0; + st_pause_ticks_stop(); + } + else + { + Menu::set_current(game_menu); + show_menu = 1; + st_pause_ticks_start(); + } + } + break; + default: + break; + } + } break; case SDL_KEYUP: /* A keyrelease! */ - key = event.key.keysym.sym; - - if(tux.key_event(key, UP)) - break; + { + SDLKey key = event.key.keysym.sym; - switch(key) - { - case SDLK_p: - if(!show_menu) - { - if(game_pause) - { - game_pause = 0; - st_pause_ticks_stop(); - } - else - { - game_pause = 1; - st_pause_ticks_start(); - } - } - break; - case SDLK_TAB: - if(debug_mode) - { - tux.size = !tux.size; - if(tux.size == BIG) - { - tux.base.height = 64; - } - else - tux.base.height = 32; - } - break; - case SDLK_END: - if(debug_mode) - distros += 50; - break; - case SDLK_SPACE: - if(debug_mode) - next_level = 1; - break; - case SDLK_DELETE: - if(debug_mode) - tux.got_coffee = 1; - break; - case SDLK_INSERT: - if(debug_mode) - timer_start(&tux.invincible_timer,TUX_INVINCIBLE_TIME); - break; - case SDLK_l: - if(debug_mode) - --tux.lives; - break; - case SDLK_s: - if(debug_mode) - score += 1000; - case SDLK_f: - if(debug_fps) - debug_fps = false; - else - debug_fps = true; - break; - default: + if(tux.key_event(key, UP)) break; - } + + switch(key) + { + case SDLK_p: + if(!show_menu) + { + if(game_pause) + { + game_pause = false; + st_pause_ticks_stop(); + } + else + { + game_pause = true; + st_pause_ticks_start(); + } + } + break; + case SDLK_TAB: + if(debug_mode) + { + tux.size = !tux.size; + if(tux.size == BIG) + { + tux.base.height = 64; + } + else + tux.base.height = 32; + } + break; + case SDLK_END: + if(debug_mode) + distros += 50; + break; + case SDLK_SPACE: + if(debug_mode) + next_level = 1; + break; + case SDLK_DELETE: + if(debug_mode) + tux.got_coffee = 1; + break; + case SDLK_INSERT: + if(debug_mode) + timer_start(&tux.invincible_timer,TUX_INVINCIBLE_TIME); + break; + case SDLK_l: + if(debug_mode) + --tux.lives; + break; + case SDLK_s: + if(debug_mode) + score += 1000; + case SDLK_f: + if(debug_fps) + debug_fps = false; + else + debug_fps = true; + break; + default: + break; + } + } break; case SDL_JOYAXISMOTION: @@ -342,6 +340,8 @@ int GameSession::action() { + Player& tux = *world->get_tux(); + if (tux.is_dead() || next_level) { /* Tux either died, or reached the end of a level! */ @@ -403,12 +403,12 @@ if (st_gl_mode == ST_GL_LOAD_LEVEL_FILE) { - if(world->get_level()->load(level_subset) != 0) + if(world->get_level()->load(subset) != 0) return 0; } else { - if(world->get_level()->load(level_subset,level) != 0) + if(world->get_level()->load(subset, level) != 0) return 0; } @@ -465,13 +465,14 @@ int GameSession::run() { + Player& tux = *world->get_tux(); current_ = this; int fps_cnt; bool done; global_frame_counter = 0; - game_pause = 0; + game_pause = false; timer_init(&fps_timer,true); timer_init(&frame_timer,true); last_update_time = st_get_ticks(); @@ -484,8 +485,9 @@ /* Play music: */ play_current_music(); - while (SDL_PollEvent(&event)) - {} + // Eat unneeded events + SDL_Event event; + while (SDL_PollEvent(&event)) {} draw(); @@ -505,7 +507,6 @@ } /* Handle events: */ - tux.input.old_fire = tux.input.fire; process_events(); @@ -640,9 +641,7 @@ unloadshared(); world->arrays_free(); - game_started = false; - - return(quit); + return quit; } /* Bounce a brick: */ @@ -655,8 +654,10 @@ } /* (Status): */ -void drawstatus(void) +void +GameSession::drawstatus() { + Player& tux = *world->get_tux(); char str[60]; sprintf(str, "%d", score); @@ -694,14 +695,14 @@ text_draw(&gold_text, str, screen->h + 60, 40, 1); } - for(int i=0; i < tux.lives; ++i) + for(int i= 0; i < tux.lives; ++i) { texture_draw(&tux_life,565+(18*i),20); } } - -void drawendscreen(void) +void +GameSession::drawendscreen() { char str[80]; @@ -721,7 +722,8 @@ wait_for_event(event,2000,5000,true); } -void drawresultscreen(void) +void +GameSession::drawresultscreen(void) { char str[80]; @@ -742,8 +744,9 @@ } void -GameSession::savegame(int slot) +GameSession::savegame(int) { +#if 0 char savefile[1024]; FILE* fi; unsigned int ui; @@ -764,22 +767,23 @@ fwrite(&score,sizeof(int),1,fi); fwrite(&distros,sizeof(int),1,fi); fwrite(&scroll_x,sizeof(float),1,fi); - fwrite(&tux,sizeof(Player),1,fi); - timer_fwrite(&tux.invincible_timer,fi); - timer_fwrite(&tux.skidding_timer,fi); - timer_fwrite(&tux.safe_timer,fi); - timer_fwrite(&tux.frame_timer,fi); + //FIXME:fwrite(&tux,sizeof(Player),1,fi); + //FIXME:timer_fwrite(&tux.invincible_timer,fi); + //FIXME:timer_fwrite(&tux.skidding_timer,fi); + //FIXME:timer_fwrite(&tux.safe_timer,fi); + //FIXME:timer_fwrite(&tux.frame_timer,fi); timer_fwrite(&time_left,fi); ui = st_get_ticks(); fwrite(&ui,sizeof(int),1,fi); } fclose(fi); - +#endif } void -GameSession::loadgame(int slot) +GameSession::loadgame(int) { +#if 0 char savefile[1024]; char str[100]; FILE* fi; @@ -821,16 +825,16 @@ fread(&score, sizeof(int),1,fi); fread(&distros, sizeof(int),1,fi); fread(&scroll_x,sizeof(float),1,fi); - fread(&tux, sizeof(Player), 1, fi); - timer_fread(&tux.invincible_timer,fi); - timer_fread(&tux.skidding_timer,fi); - timer_fread(&tux.safe_timer,fi); - timer_fread(&tux.frame_timer,fi); + //FIXME:fread(&tux, sizeof(Player), 1, fi); + //FIXME:timer_fread(&tux.invincible_timer,fi); + //FIXME:timer_fread(&tux.skidding_timer,fi); + //FIXME:timer_fread(&tux.safe_timer,fi); + //FIXME:timer_fread(&tux.frame_timer,fi); timer_fread(&time_left,fi); fread(&ui,sizeof(int),1,fi); fclose(fi); } - +#endif } std::string slotinfo(int slot) Index: leveleditor.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/leveleditor.cpp,v retrieving revision 1.36 retrieving revision 1.37 diff -u -d -r1.36 -r1.37 --- leveleditor.cpp 11 Apr 2004 13:05:35 -0000 1.36 +++ leveleditor.cpp 11 Apr 2004 14:44:19 -0000 1.37 @@ -36,6 +36,7 @@ #include "scene.h" #include "button.h" #include "tile.h" +#include "resources.h" /* definitions to aid development */ #define DONE_LEVELEDITOR 1 @@ -59,11 +60,6 @@ #define SELECT_W 2 // size of the selections lines #define SELECT_CLR 0, 255, 0, 255 // lines color (R, G, B, A) -/* gameloop funcs declerations */ - -void loadshared(void); -void unloadshared(void); - /* own declerations */ /* crutial ones (main loop) */ int le_init(); Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- player.cpp 11 Apr 2004 12:37:40 -0000 1.25 +++ player.cpp 11 Apr 2004 14:44:19 -0000 1.26 @@ -99,6 +99,7 @@ timer_init(&skidding_timer,true); timer_init(&safe_timer,true); timer_init(&frame_timer,true); + physic.reset(); } @@ -285,8 +286,8 @@ // timer_check(&skidding_timer); // disabled /* End of level? */ - - if (base.x >= endpos && endpos != 0) + if (base.x >= World::current()->get_level()->endpos + && World::current()->get_level()->endpos != 0) { next_level = 1; } @@ -914,7 +915,7 @@ void Player::keep_in_bounds() { - Level* plevel = GameSession::current()->get_level(); + Level* plevel = World::current()->get_level(); /* Keep tux in bounds: */ if (base.x< 0) @@ -931,7 +932,7 @@ } else if (base.x > screen->w / 2 + scroll_x - && scroll_x < ((GameSession::current()->get_level()->width * 32) - screen->w)) + && scroll_x < ((World::current()->get_level()->width * 32) - screen->w)) { // FIXME: Scrolling needs to be handled by a seperate View // class, doing it as a player huck is ugly Index: collision.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/collision.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- collision.cpp 11 Apr 2004 12:59:59 -0000 1.14 +++ collision.cpp 11 Apr 2004 14:44:19 -0000 1.15 @@ -15,6 +15,7 @@ #include "bitmask.h" #include "scene.h" #include "world.h" +#include "level.h" #include "tile.h" bool rectcollision(base_type* one, base_type* two) Index: title.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/title.cpp,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- title.cpp 11 Apr 2004 11:52:29 -0000 1.29 +++ title.cpp 11 Apr 2004 14:44:19 -0000 1.30 @@ -39,15 +39,13 @@ #include "player.h" #include "math.h" #include "tile.h" - -void loadshared(void); +#include "resources.h" static texture_type bkg_title; static texture_type logo; static texture_type img_choose_subset; static bool walking; -static Player titletux; static timer_type random_timer; static SDL_Event event; @@ -65,8 +63,13 @@ texture_draw_bg(&bkg_title); } -void draw_demo(Level* plevel) +void draw_demo(GameSession* session) { + World::set_current(session->get_world()); + //World* world = session->get_world(); + Level* plevel = session->get_level(); + Player* tux = session->get_world()->get_tux(); + /* FIXME: // update particle systems std::vector<ParticleSystem*>::iterator p; @@ -93,14 +96,14 @@ } global_frame_counter++; - titletux.key_event(SDLK_RIGHT,DOWN); + tux->key_event(SDLK_RIGHT,DOWN); if(timer_check(&random_timer)) { if(walking) - titletux.key_event(SDLK_UP,UP); + tux->key_event(SDLK_UP,UP); else - titletux.key_event(SDLK_UP,DOWN); + tux->key_event(SDLK_UP,DOWN); } else { @@ -109,27 +112,26 @@ } // Wrap around at the end of the level back to the beginnig - if(plevel->width * 32 - 320 < titletux.base.x) + if(plevel->width * 32 - 320 < tux->base.x) { - titletux.base.x = titletux.base.x - (plevel->width * 32 - 640); - scroll_x = titletux.base.x - 320; + tux->base.x = tux->base.x - (plevel->width * 32 - 640); + scroll_x = tux->base.x - 320; } - float last_tux_x_pos = titletux.base.x; - titletux.action(); + float last_tux_x_pos = tux->base.x; + tux->action(); // Jump if tux stays in the same position for one loop, ie. if he is // stuck behind a wall - if (last_tux_x_pos == titletux.base.x) + if (last_tux_x_pos == tux->base.x) walking = false; - titletux.draw(); + tux->draw(); /* DEMO end */ } /* --- TITLE SCREEN --- */ - bool title(void) { string_list_type level_subsets; @@ -138,15 +140,13 @@ timer_init(&random_timer, true); walking = true; - titletux.init(); st_pause_ticks_init(); GameSession session(datadir + "/levels/misc/menu.stl"); loadshared(); + //FIXME:activate_particle_systems(); - /* Lower the gravity that tux doesn't jump to hectically through the demo */ - //gravity = 5; /* Reset menu variables */ menu_reset(); @@ -209,7 +209,7 @@ /* Draw the background: */ draw_background(); - draw_demo(session.get_level()); + draw_demo(&session); if (current_menu == main_menu) texture_draw(&logo, 160, 30); @@ -344,9 +344,10 @@ { if (process_load_game_menu()) { + // FIXME: shouldn't be needed if GameSession doesn't relay on global variables // reset tux scroll_x = 0; - titletux.level_begin(); + //titletux.level_begin(); update_time = st_get_ticks(); } } Index: world.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- world.cpp 11 Apr 2004 13:20:43 -0000 1.16 +++ world.cpp 11 Apr 2004 14:44:19 -0000 1.17 @@ -41,6 +41,7 @@ current_ = this; level = new Level; + tux.init(); } World::~World() @@ -60,14 +61,12 @@ counting_distros = false; distro_counter = 0; - endpos = 0; - /* set current song/music */ set_current_music(LEVEL_MUSIC); } int -World::load(const char* subset, int level_nr) +World::load(const std::string& subset, int level_nr) { return level->load(subset, level_nr); } Index: level.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level.cpp,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- level.cpp 11 Apr 2004 01:24:58 -0000 1.29 +++ level.cpp 11 Apr 2004 14:44:19 -0000 1.30 @@ -203,6 +203,7 @@ bkgd_red = 0; bkgd_green = 0; bkgd_blue = 0; + endpos = 0; for(int i = 0; i < 15; ++i) { @@ -227,14 +228,14 @@ } int -Level::load(const char *subset, int level) +Level::load(const std::string& subset, int level) { char filename[1024]; // Load data file: - snprintf(filename, 1024, "%s/levels/%s/level%d.stl", st_dir, subset, level); + snprintf(filename, 1024, "%s/levels/%s/level%d.stl", st_dir, subset.c_str(), level); if(!faccessible(filename)) - snprintf(filename, 1024, "%s/levels/%s/level%d.stl", datadir.c_str(), subset, level); + snprintf(filename, 1024, "%s/levels/%s/level%d.stl", datadir.c_str(), subset.c_str(), level); return load(filename); } @@ -423,9 +424,6 @@ } } - // FIXME: Set the global gravity to the latest loaded level's gravity - ::gravity = gravity; - // Mark the end position of this level! // FIXME: -10 is a rather random value, we still need some kind of // real levelend gola Index: resources.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/resources.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- resources.cpp 11 Apr 2004 12:37:40 -0000 1.3 +++ resources.cpp 11 Apr 2004 14:44:19 -0000 1.4 @@ -3,6 +3,7 @@ #include "player.h" #include "badguy.h" #include "gameobjs.h" +#include "special.h" #include "resources.h" texture_type img_waves[3]; |
From: Ingo R. <gr...@us...> - 2004-04-11 13:34:36
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12533 Modified Files: special.cpp special.h world.cpp world.h Log Message: - turned special into classes Index: world.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.h,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- world.h 11 Apr 2004 13:05:35 -0000 1.17 +++ world.h 11 Apr 2004 13:20:43 -0000 1.18 @@ -41,8 +41,8 @@ std::vector<FloatingScore> floating_scores; std::vector<BadGuy> bad_guys; - std::vector<upgrade_type> upgrades; - std::vector<bullet_type> bullets; + std::vector<Upgrade> upgrades; + std::vector<Bullet> bullets; std::vector<ParticleSystem*> particle_systems; static World* current_; Index: world.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- world.cpp 11 Apr 2004 13:05:35 -0000 1.15 +++ world.cpp 11 Apr 2004 13:20:43 -0000 1.16 @@ -183,13 +183,13 @@ tux.draw(); for (unsigned int i = 0; i < bullets.size(); ++i) - bullet_draw(&bullets[i]); + bullets[i].draw(); for (unsigned int i = 0; i < floating_scores.size(); ++i) floating_scores[i].draw(); for (unsigned int i = 0; i < upgrades.size(); ++i) - upgrade_draw(&upgrades[i]); + upgrades[i].draw(); for (unsigned int i = 0; i < bouncy_distros.size(); ++i) bouncy_distros[i].draw(); @@ -242,10 +242,10 @@ floating_scores[i].action(); for (unsigned int i = 0; i < bullets.size(); ++i) - bullet_action(&bullets[i]); + bullets[i].action(); for (unsigned int i = 0; i < upgrades.size(); i++) - upgrade_action(&upgrades[i]); + upgrades[i].action(); for (unsigned int i = 0; i < bad_guys.size(); i++) bad_guys[i].action(); @@ -279,7 +279,7 @@ // collide with bad_guy first, since bullet_collision will // delete the bullet bad_guys[j].collision(0, CO_BULLET); - bullet_collision(&bullets[i], CO_BADGUY); + bullets[i].collision(CO_BADGUY); break; // bullet is invalid now, so break } } @@ -338,7 +338,7 @@ { // We have detected a collision and now call the collision // functions of the collided objects. - upgrade_collision(&upgrades[i], &tux, CO_PLAYER); + upgrades[i].collision(&tux, CO_PLAYER); } } } @@ -399,16 +399,16 @@ void World::add_upgrade(float x, float y, int dir, int kind) { - upgrade_type new_upgrade; - upgrade_init(&new_upgrade,x,y,dir,kind); + Upgrade new_upgrade; + new_upgrade.init(x,y,dir,kind); upgrades.push_back(new_upgrade); } void World::add_bullet(float x, float y, float xm, int dir) { - bullet_type new_bullet; - bullet_init(&new_bullet,x,y,xm,dir); + Bullet new_bullet; + new_bullet.init(x,y,xm,dir); bullets.push_back(new_bullet); play_sound(sounds[SND_SHOOT], SOUND_CENTER_SPEAKER); Index: special.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/special.h,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- special.h 23 Mar 2004 17:25:15 -0000 1.10 +++ special.h 11 Apr 2004 13:20:43 -0000 1.11 @@ -31,17 +31,29 @@ UPGRADE_HERRING }; -struct upgrade_type +class Upgrade { + public: int kind; base_type base; base_type old_base; + + void init(float x, float y, int dir, int kind); + void action(); + void draw(); + void collision(void* p_c_object, int c_object); }; -struct bullet_type +class Bullet { + public: base_type base; base_type old_base; + + void init(float x, float y, float xm, int dir); + void action(); + void draw(); + void collision(int c_object); }; extern texture_type img_bullet; @@ -51,14 +63,4 @@ extern texture_type img_golden_herring; -void upgrade_init(upgrade_type *pupgrade, float x, float y, int dir, int kind); -void upgrade_action(upgrade_type *pupgrade); -void upgrade_draw(upgrade_type *pupgrade); -void upgrade_collision(upgrade_type *pupgrade, void* p_c_object, int c_object); - -void bullet_init(bullet_type* pbullet, float x, float y, float xm, int dir); -void bullet_action(bullet_type *pbullet); -void bullet_draw(bullet_type *pbullet); -void bullet_collision(bullet_type *pbullet, int c_object); - #endif /*SUPERTUX_SPECIAL_H*/ Index: special.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/special.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- special.cpp 11 Apr 2004 13:05:35 -0000 1.9 +++ special.cpp 11 Apr 2004 13:20:43 -0000 1.10 @@ -29,200 +29,210 @@ bm_bullet = bitmask_create_SDL(img_bullet.sdl_surface); } -void bullet_init(bullet_type* pbullet, float x, float y, float xm, int dir) +void +Bullet::init(float x, float y, float xm, int dir) { - pbullet->base.width = 4; - pbullet->base.height = 4; + base.width = 4; + base.height = 4; if (dir == RIGHT) { - pbullet->base.x = x + 32; - pbullet->base.xm = BULLET_XM + xm; + base.x = x + 32; + base.xm = BULLET_XM + xm; } else { - pbullet->base.x = x; - pbullet->base.xm = -BULLET_XM + xm; + base.x = x; + base.xm = -BULLET_XM + xm; } - pbullet->base.y = y; - pbullet->base.ym = BULLET_STARTING_YM; - pbullet->old_base = pbullet->base; + base.y = y; + base.ym = BULLET_STARTING_YM; + old_base = base; } -void bullet_action(bullet_type* pbullet) +void +Bullet::action() { - pbullet->base.x = pbullet->base.x + pbullet->base.xm * frame_ratio; - pbullet->base.y = pbullet->base.y + pbullet->base.ym * frame_ratio; + base.x = base.x + base.xm * frame_ratio; + base.y = base.y + base.ym * frame_ratio; - collision_swept_object_map(&pbullet->old_base,&pbullet->base); + collision_swept_object_map(&old_base,&base); - if (issolid(pbullet->base.x, pbullet->base.y + 4) || issolid(pbullet->base.x, pbullet->base.y)) + if (issolid(base.x, base.y + 4) || issolid(base.x, base.y)) { - pbullet->base.ym = -pbullet->base.ym; - pbullet->base.y = (int)(pbullet->base.y / 32) * 32; + base.ym = -base.ym; + base.y = (int)(base.y / 32) * 32; } - pbullet->base.ym = pbullet->base.ym + GRAVITY; + base.ym = base.ym + GRAVITY; - if (pbullet->base.x < scroll_x || - pbullet->base.x > scroll_x + screen->w || - pbullet->base.y < 0 || - pbullet->base.y > screen->h || - issolid(pbullet->base.x + 4, pbullet->base.y + 2) || - issolid(pbullet->base.x, pbullet->base.y + 2)) + if (base.x < scroll_x || + base.x > scroll_x + screen->w || + base.y < 0 || + base.y > screen->h || + issolid(base.x + 4, base.y + 2) || + issolid(base.x, base.y + 2)) { - World::current()->bullets.erase(static_cast<std::vector<bullet_type>::iterator>(pbullet)); + World::current()->bullets.erase(static_cast<std::vector<Bullet>::iterator>(this)); } } -void bullet_draw(bullet_type* pbullet) +void +Bullet::draw() { - if (pbullet->base.x >= scroll_x - pbullet->base.width && - pbullet->base.x <= scroll_x + screen->w) + if (base.x >= scroll_x - base.width && + base.x <= scroll_x + screen->w) { - texture_draw(&img_bullet, pbullet->base.x - scroll_x, pbullet->base.y, 255, + texture_draw(&img_bullet, base.x - scroll_x, base.y, 255, NO_UPDATE); } } -void bullet_collision(bullet_type* pbullet, int c_object) +void +Bullet::collision(int c_object) { if(c_object == CO_BADGUY) { - std::vector<bullet_type>::iterator i; + std::vector<Bullet>::iterator i; - for(i = World::current()->bullets.begin(); i != World::current()->bullets.end(); ++i) { - if(& (*i) == pbullet) { - World::current()->bullets.erase(i); - return; + for(i = World::current()->bullets.begin(); i != World::current()->bullets.end(); ++i) + { + if(&(*i) == this) + { + World::current()->bullets.erase(i); + return; + } } - } } } -void upgrade_init(upgrade_type *pupgrade, float x, float y, int dir, int kind) +void +Upgrade::init(float x_, float y_, int dir_, int kind_) { - pupgrade->base.width = 32; - pupgrade->base.height = 0; - pupgrade->kind = kind; - pupgrade->base.x = x; - pupgrade->base.y = y; - if(dir == LEFT) - pupgrade->base.xm = -2; + base.width = 32; + base.height = 0; + kind = kind_; + base.x = x_; + base.y = y_; + + if(dir_ == LEFT) + base.xm = -2; else - pupgrade->base.xm = 2; - pupgrade->base.ym = -2; - pupgrade->base.height = 0; - pupgrade->old_base = pupgrade->base; + base.xm = 2; + + base.ym = -2; + base.height = 0; + old_base = base; } -void upgrade_action(upgrade_type *pupgrade) +void +Upgrade::action() { - - - if (pupgrade->base.height < 32) + if (base.height < 32) { /* Rise up! */ - pupgrade->base.height = pupgrade->base.height + 0.7 * frame_ratio; - if(pupgrade->base.height > 32) - pupgrade->base.height = 32; + base.height = base.height + 0.7 * frame_ratio; + if(base.height > 32) + base.height = 32; } else { /* Move around? */ - if (pupgrade->kind == UPGRADE_MINTS || - pupgrade->kind == UPGRADE_HERRING) + if (kind == UPGRADE_MINTS || + kind == UPGRADE_HERRING) { - pupgrade->base.x = pupgrade->base.x + pupgrade->base.xm * frame_ratio; - pupgrade->base.y = pupgrade->base.y + pupgrade->base.ym * frame_ratio; + base.x = base.x + base.xm * frame_ratio; + base.y = base.y + base.ym * frame_ratio; - collision_swept_object_map(&pupgrade->old_base,&pupgrade->base); + collision_swept_object_map(&old_base,&base); /* Off the screen? Kill it! */ - if (pupgrade->base.x < scroll_x - pupgrade->base.width) - World::current()->upgrades.erase(static_cast<std::vector<upgrade_type>::iterator>(pupgrade)); - if (pupgrade->base.y > screen->h) - World::current()->upgrades.erase(static_cast<std::vector<upgrade_type>::iterator>(pupgrade)); + if (base.x < scroll_x - base.width) + World::current()->upgrades.erase(static_cast<std::vector<Upgrade>::iterator>(this)); + if (base.y > screen->h) + World::current()->upgrades.erase(static_cast<std::vector<Upgrade>::iterator>(this)); - if (issolid(pupgrade->base.x + 1, pupgrade->base.y + 32.) || - issolid(pupgrade->base.x + 31., pupgrade->base.y + 32.)) + if (issolid(base.x + 1, base.y + 32.) || + issolid(base.x + 31., base.y + 32.)) { - if (pupgrade->base.ym > 0) + if (base.ym > 0) { - if (pupgrade->kind == UPGRADE_MINTS) + if (kind == UPGRADE_MINTS) { - pupgrade->base.ym = 0; + base.ym = 0; } - else if (pupgrade->kind == UPGRADE_HERRING) + else if (kind == UPGRADE_HERRING) { - pupgrade->base.ym = -8; + base.ym = -8; } - pupgrade->base.y = (int)(pupgrade->base.y / 32) * 32; + base.y = (int)(base.y / 32) * 32; } } else - pupgrade->base.ym = pupgrade->base.ym + GRAVITY * frame_ratio; + base.ym = base.ym + GRAVITY * frame_ratio; - if (issolid(pupgrade->base.x - 1, (int) pupgrade->base.y)) + if (issolid(base.x - 1, (int) base.y)) { - if(pupgrade->base.xm < 0) - pupgrade->base.xm = -pupgrade->base.xm; + if(base.xm < 0) + base.xm = -base.xm; } - else if (issolid(pupgrade->base.x + pupgrade->base.width, (int) pupgrade->base.y)) + else if (issolid(base.x + base.width, (int) base.y)) { - if(pupgrade->base.xm > 0) - pupgrade->base.xm = -pupgrade->base.xm; + if(base.xm > 0) + base.xm = -base.xm; } } } } -void upgrade_draw(upgrade_type* pupgrade) +void +Upgrade::draw() { SDL_Rect dest; - if (pupgrade->base.height < 32) + if (base.height < 32) { /* Rising up... */ - dest.x = (int)(pupgrade->base.x - scroll_x); - dest.y = (int)(pupgrade->base.y + 32 - pupgrade->base.height); + dest.x = (int)(base.x - scroll_x); + dest.y = (int)(base.y + 32 - base.height); dest.w = 32; - dest.h = (int)pupgrade->base.height; + dest.h = (int)base.height; - if (pupgrade->kind == UPGRADE_MINTS) + if (kind == UPGRADE_MINTS) texture_draw_part(&img_mints,0,0,dest.x,dest.y,dest.w,dest.h); - else if (pupgrade->kind == UPGRADE_COFFEE) + else if (kind == UPGRADE_COFFEE) texture_draw_part(&img_coffee,0,0,dest.x,dest.y,dest.w,dest.h); - else if (pupgrade->kind == UPGRADE_HERRING) + else if (kind == UPGRADE_HERRING) texture_draw_part(&img_golden_herring,0,0,dest.x,dest.y,dest.w,dest.h); } else { - if (pupgrade->kind == UPGRADE_MINTS) + if (kind == UPGRADE_MINTS) { texture_draw(&img_mints, - pupgrade->base.x - scroll_x, pupgrade->base.y); + base.x - scroll_x, base.y); } - else if (pupgrade->kind == UPGRADE_COFFEE) + else if (kind == UPGRADE_COFFEE) { texture_draw(&img_coffee, - pupgrade->base.x - scroll_x, pupgrade->base.y); + base.x - scroll_x, base.y); } - else if (pupgrade->kind == UPGRADE_HERRING) + else if (kind == UPGRADE_HERRING) { texture_draw(&img_golden_herring, - pupgrade->base.x - scroll_x, pupgrade->base.y); + base.x - scroll_x, base.y); } } } -void upgrade_collision(upgrade_type* pupgrade, void* p_c_object, int c_object) +void +Upgrade::collision(void* p_c_object, int c_object) { Player* pplayer = NULL; @@ -234,11 +244,11 @@ /* p_c_object is CO_PLAYER, so assign it to pplayer */ pplayer = (Player*) p_c_object; - World::current()->upgrades.erase(static_cast<std::vector<upgrade_type>::iterator>(pupgrade)); + World::current()->upgrades.erase(static_cast<std::vector<Upgrade>::iterator>(this)); /* Affect the player: */ - if (pupgrade->kind == UPGRADE_MINTS) + if (kind == UPGRADE_MINTS) { play_sound(sounds[SND_EXCELLENT], SOUND_CENTER_SPEAKER); pplayer->size = BIG; @@ -252,13 +262,13 @@ } timer_start(&super_bkgd_timer, 350); } - else if (pupgrade->kind == UPGRADE_COFFEE) + else if (kind == UPGRADE_COFFEE) { play_sound(sounds[SND_COFFEE], SOUND_CENTER_SPEAKER); pplayer->got_coffee = true; timer_start(&super_bkgd_timer, 250); } - else if (pupgrade->kind == UPGRADE_HERRING) + else if (kind == UPGRADE_HERRING) { play_sound(sounds[SND_HERRING], SOUND_CENTER_SPEAKER); timer_start(&pplayer->invincible_timer,TUX_INVINCIBLE_TIME); |
From: Ingo R. <gr...@us...> - 2004-04-11 13:19:15
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9780 Modified Files: gameloop.cpp gameloop.h gameobjs.cpp leveleditor.cpp special.cpp world.cpp world.h Log Message: - renamed 'world' to 'global_world' to emphasis that it is mainly a temporary hack - moved some 'world' to 'World::current()' Index: world.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.h,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- world.h 11 Apr 2004 13:00:00 -0000 1.16 +++ world.h 11 Apr 2004 13:05:35 -0000 1.17 @@ -100,7 +100,8 @@ void trybumpbadguy(float x, float y); }; -extern World world; +/** FIMXE: Workaround for the leveleditor mainly */ +extern World global_world; #endif /*SUPERTUX_WORLD_H*/ Index: leveleditor.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/leveleditor.cpp,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- leveleditor.cpp 11 Apr 2004 11:52:29 -0000 1.35 +++ leveleditor.cpp 11 Apr 2004 13:05:35 -0000 1.36 @@ -244,7 +244,7 @@ le_level_subset.load(level_subsets.item[i-2]); leveleditor_menu->item[3].kind = MN_GOTO; le_level = 1; - world.arrays_free(); + global_world.arrays_free(); loadshared(); le_current_level = new Level; if(le_current_level->load(le_level_subset.name.c_str(), le_level) != 0) @@ -254,7 +254,7 @@ } le_set_defaults(); le_current_level->load_gfx(); - world.activate_bad_guys(); + global_world.activate_bad_guys(); show_menu = true; } break; @@ -275,7 +275,7 @@ le_level_subset.load(subset_new_menu->item[2].input); leveleditor_menu->item[3].kind = MN_GOTO; le_level = 1; - world.arrays_free(); + global_world.arrays_free(); loadshared(); le_current_level = new Level; if(le_current_level->load(le_level_subset.name.c_str(), le_level) != 0) @@ -285,7 +285,7 @@ } le_set_defaults(); le_current_level->load_gfx(); - world.activate_bad_guys(); + global_world.activate_bad_guys(); menu_item_change_input(&subset_new_menu->item[2],""); show_menu = true; break; @@ -544,7 +544,7 @@ void le_goto_level(int levelnb) { - world.arrays_free(); + global_world.arrays_free(); le_current_level->cleanup(); if(le_current_level->load(le_level_subset.name.c_str(), levelnb) != 0) @@ -561,7 +561,7 @@ le_current_level->free_gfx(); le_current_level->load_gfx(); - world.activate_bad_guys(); + global_world.activate_bad_guys(); } void le_quit(void) @@ -597,7 +597,7 @@ { le_current_level->free_gfx(); le_current_level->cleanup(); - world.arrays_free(); + global_world.arrays_free(); unloadshared(); } } @@ -729,12 +729,12 @@ } /* Draw the Bad guys: */ - for (i = 0; i < world.bad_guys.size(); ++i) + for (i = 0; i < global_world.bad_guys.size(); ++i) { /* to support frames: img_bsod_left[(frame / 5) % 4] */ scroll_x = pos_x; - world.bad_guys[i].draw(); + global_world.bad_guys[i].draw(); } @@ -1123,16 +1123,16 @@ xx = ((int)x / 32); /* if there is a bad guy over there, remove it */ - for(i = 0; i < world.bad_guys.size(); ++i) - if(xx == world.bad_guys[i].base.x/32 && yy == world.bad_guys[i].base.y/32) - world.bad_guys.erase(static_cast<std::vector<BadGuy>::iterator>(&world.bad_guys[i])); + for(i = 0; i < global_world.bad_guys.size(); ++i) + if(xx == global_world.bad_guys[i].base.x/32 && yy == global_world.bad_guys[i].base.y/32) + global_world.bad_guys.erase(static_cast<std::vector<BadGuy>::iterator>(&global_world.bad_guys[i])); if(c == '0') /* if it's a bad guy */ - world.add_bad_guy(xx*32, yy*32, BAD_BSOD); + global_world.add_bad_guy(xx*32, yy*32, BAD_BSOD); else if(c == '1') - world.add_bad_guy(xx*32, yy*32, BAD_LAPTOP); + global_world.add_bad_guy(xx*32, yy*32, BAD_LAPTOP); else if(c == '2') - world.add_bad_guy(xx*32, yy*32, BAD_MONEY); + global_world.add_bad_guy(xx*32, yy*32, BAD_MONEY); break; case SQUARE: @@ -1163,10 +1163,10 @@ y2 /= 32; /* if there is a bad guy over there, remove it */ - for(i = 0; i < world.bad_guys.size(); ++i) - if(world.bad_guys[i].base.x/32 >= x1 && world.bad_guys[i].base.x/32 <= x2 - && world.bad_guys[i].base.y/32 >= y1 && world.bad_guys[i].base.y/32 <= y2) - world.bad_guys.erase(static_cast<std::vector<BadGuy>::iterator>(&world.bad_guys[i])); + for(i = 0; i < global_world.bad_guys.size(); ++i) + if(global_world.bad_guys[i].base.x/32 >= x1 && global_world.bad_guys[i].base.x/32 <= x2 + && global_world.bad_guys[i].base.y/32 >= y1 && global_world.bad_guys[i].base.y/32 <= y2) + global_world.bad_guys.erase(static_cast<std::vector<BadGuy>::iterator>(&global_world.bad_guys[i])); for(xx = x1; xx <= x2; xx++) for(yy = y1; yy <= y2; yy++) @@ -1174,11 +1174,11 @@ le_current_level->change(xx*32, yy*32, tm, c); if(c == '0') // if it's a bad guy - world.add_bad_guy(xx*32, yy*32, BAD_BSOD); + global_world.add_bad_guy(xx*32, yy*32, BAD_BSOD); else if(c == '1') - world.add_bad_guy(xx*32, yy*32, BAD_LAPTOP); + global_world.add_bad_guy(xx*32, yy*32, BAD_LAPTOP); else if(c == '2') - world.add_bad_guy(xx*32, yy*32, BAD_MONEY); + global_world.add_bad_guy(xx*32, yy*32, BAD_MONEY); } break; default: @@ -1195,10 +1195,10 @@ session.run(); Menu::set_current(leveleditor_menu); - world.arrays_free(); + global_world.arrays_free(); le_current_level->load_gfx(); loadshared(); - world.activate_bad_guys(); + global_world.activate_bad_guys(); } void le_showhelp() Index: gameloop.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.h,v retrieving revision 1.32 retrieving revision 1.33 diff -u -d -r1.32 -r1.33 --- gameloop.h 11 Apr 2004 01:36:22 -0000 1.32 +++ gameloop.h 11 Apr 2004 13:05:35 -0000 1.33 @@ -65,8 +65,7 @@ std::string slotinfo(int slot); -bool rectcollision(base_type* one, base_type* two); -void drawshape(float x, float y, unsigned int c, Uint8 alpha = 255); +bool rectcollision(base_type* one, base_type* two); void bumpbrick(float x, float y); #endif /*SUPERTUX_GAMELOOP_H*/ Index: gameobjs.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameobjs.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- gameobjs.cpp 11 Apr 2004 12:43:35 -0000 1.3 +++ gameobjs.cpp 11 Apr 2004 13:05:35 -0000 1.4 @@ -38,7 +38,7 @@ base.ym += 0.1 * frame_ratio; if (base.ym >= 0) - world.bouncy_distros.erase(static_cast<std::vector<BouncyDistro>::iterator>(this)); + World::current()->bouncy_distros.erase(static_cast<std::vector<BouncyDistro>::iterator>(this)); } void @@ -70,7 +70,7 @@ base.y = base.y + base.ym * frame_ratio; if (!timer_check(&timer)) - world.broken_bricks.erase(static_cast<std::vector<BrokenBrick>::iterator>(this)); + World::current()->broken_bricks.erase(static_cast<std::vector<BrokenBrick>::iterator>(this)); } void @@ -115,7 +115,7 @@ /* Stop bouncing? */ if (offset >= 0) - world.bouncy_bricks.erase(static_cast<std::vector<BouncyBrick>::iterator>(this)); + World::current()->bouncy_bricks.erase(static_cast<std::vector<BouncyBrick>::iterator>(this)); } void @@ -171,7 +171,7 @@ base.y = base.y - 2 * frame_ratio; if(!timer_check(&timer)) - world.floating_scores.erase(static_cast<std::vector<FloatingScore>::iterator>(this)); + World::current()->floating_scores.erase(static_cast<std::vector<FloatingScore>::iterator>(this)); } void Index: special.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/special.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- special.cpp 10 Apr 2004 22:37:13 -0000 1.8 +++ special.cpp 11 Apr 2004 13:05:35 -0000 1.9 @@ -72,7 +72,7 @@ issolid(pbullet->base.x + 4, pbullet->base.y + 2) || issolid(pbullet->base.x, pbullet->base.y + 2)) { - world.bullets.erase(static_cast<std::vector<bullet_type>::iterator>(pbullet)); + World::current()->bullets.erase(static_cast<std::vector<bullet_type>::iterator>(pbullet)); } } @@ -92,9 +92,9 @@ if(c_object == CO_BADGUY) { std::vector<bullet_type>::iterator i; - for(i = world.bullets.begin(); i != world.bullets.end(); ++i) { + for(i = World::current()->bullets.begin(); i != World::current()->bullets.end(); ++i) { if(& (*i) == pbullet) { - world.bullets.erase(i); + World::current()->bullets.erase(i); return; } } @@ -144,9 +144,9 @@ /* Off the screen? Kill it! */ if (pupgrade->base.x < scroll_x - pupgrade->base.width) - world.upgrades.erase(static_cast<std::vector<upgrade_type>::iterator>(pupgrade)); + World::current()->upgrades.erase(static_cast<std::vector<upgrade_type>::iterator>(pupgrade)); if (pupgrade->base.y > screen->h) - world.upgrades.erase(static_cast<std::vector<upgrade_type>::iterator>(pupgrade)); + World::current()->upgrades.erase(static_cast<std::vector<upgrade_type>::iterator>(pupgrade)); if (issolid(pupgrade->base.x + 1, pupgrade->base.y + 32.) || issolid(pupgrade->base.x + 31., pupgrade->base.y + 32.)) @@ -234,7 +234,7 @@ /* p_c_object is CO_PLAYER, so assign it to pplayer */ pplayer = (Player*) p_c_object; - world.upgrades.erase(static_cast<std::vector<upgrade_type>::iterator>(pupgrade)); + World::current()->upgrades.erase(static_cast<std::vector<upgrade_type>::iterator>(pupgrade)); /* Affect the player: */ Index: world.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- world.cpp 11 Apr 2004 13:00:00 -0000 1.14 +++ world.cpp 11 Apr 2004 13:05:35 -0000 1.15 @@ -32,7 +32,7 @@ World* World::current_ = 0; -World world; +World global_world; World::World() { Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.55 retrieving revision 1.56 diff -u -d -r1.55 -r1.56 --- gameloop.cpp 11 Apr 2004 13:00:00 -0000 1.55 +++ gameloop.cpp 11 Apr 2004 13:05:35 -0000 1.56 @@ -78,7 +78,7 @@ { current_ = this; - world = &::world; + world = &::global_world; timer_init(&fps_timer, true); timer_init(&frame_timer, true); @@ -90,7 +90,7 @@ { current_ = this; - world = &::world; + world = &::global_world; timer_init(&fps_timer, true); timer_init(&frame_timer, true); @@ -648,7 +648,7 @@ /* Bounce a brick: */ void bumpbrick(float x, float y) { - world.add_bouncy_brick(((int)(x + 1) / 32) * 32, + World::current()->add_bouncy_brick(((int)(x + 1) / 32) * 32, (int)(y / 32) * 32); play_sound(sounds[SND_BRICK], SOUND_CENTER_SPEAKER); |
From: Ingo R. <gr...@us...> - 2004-04-11 13:13:39
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8841 Modified Files: collision.cpp collision.h gameloop.cpp world.cpp world.h Log Message: - moved some collision code into the world class, since it only acts on world data Index: world.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.h,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- world.h 11 Apr 2004 12:43:35 -0000 1.15 +++ world.h 11 Apr 2004 13:00:00 -0000 1.16 @@ -58,6 +58,12 @@ void draw(); void action(); + + /** Checks for all possible collisions. And calls the + collision_handlers, which the collision_objects provide for this + case (or not). */ + void collision_handler(); + void arrays_free(); /** Load data for this level: Index: world.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- world.cpp 11 Apr 2004 12:43:35 -0000 1.13 +++ world.cpp 11 Apr 2004 13:00:00 -0000 1.14 @@ -249,6 +249,98 @@ for (unsigned int i = 0; i < bad_guys.size(); i++) bad_guys[i].action(); + + /* update particle systems */ + std::vector<ParticleSystem*>::iterator p; + for(p = particle_systems.begin(); p != particle_systems.end(); ++p) + { + (*p)->simulate(frame_ratio); + } + + /* Handle all possible collisions. */ + collision_handler(); +} + + +void +World::collision_handler() +{ + // CO_BULLET & CO_BADGUY check + for(unsigned int i = 0; i < bullets.size(); ++i) + { + for(unsigned int j = 0; j < bad_guys.size(); ++j) + { + if(bad_guys[j].dying != DYING_NOT) + continue; + if(rectcollision(&bullets[i].base, &bad_guys[j].base)) + { + // We have detected a collision and now call the + // collision functions of the collided objects. + // collide with bad_guy first, since bullet_collision will + // delete the bullet + bad_guys[j].collision(0, CO_BULLET); + bullet_collision(&bullets[i], CO_BADGUY); + break; // bullet is invalid now, so break + } + } + } + + /* CO_BADGUY & CO_BADGUY check */ + for(unsigned int i = 0; i < bad_guys.size(); ++i) + { + if(bad_guys[i].dying != DYING_NOT) + continue; + + for(unsigned int j = i+1; j < bad_guys.size(); ++j) + { + if(j == i || bad_guys[j].dying != DYING_NOT) + continue; + + if(rectcollision(&bad_guys[i].base, &bad_guys[j].base)) + { + // We have detected a collision and now call the + // collision functions of the collided objects. + bad_guys[j].collision(&bad_guys[i], CO_BADGUY); + bad_guys[i].collision(&bad_guys[j], CO_BADGUY); + } + } + } + + if(tux.dying != DYING_NOT) return; + + // CO_BADGUY & CO_PLAYER check + for(unsigned int i = 0; i < bad_guys.size(); ++i) + { + if(bad_guys[i].dying != DYING_NOT) + continue; + + if(rectcollision_offset(&bad_guys[i].base,&tux.base,0,0)) + { + // We have detected a collision and now call the collision + // functions of the collided objects. + if (tux.previous_base.y < tux.base.y && + tux.previous_base.y + tux.previous_base.height + < bad_guys[i].base.y + bad_guys[i].base.height/2) + { + bad_guys[i].collision(&tux, CO_PLAYER, COLLISION_SQUISH); + } + else + { + tux.collision(&bad_guys[i], CO_BADGUY); + } + } + } + + // CO_UPGRADE & CO_PLAYER check + for(unsigned int i = 0; i < upgrades.size(); ++i) + { + if(rectcollision(&upgrades[i].base, &tux.base)) + { + // We have detected a collision and now call the collision + // functions of the collided objects. + upgrade_collision(&upgrades[i], &tux, CO_PLAYER); + } + } } void Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.54 retrieving revision 1.55 diff -u -d -r1.54 -r1.55 --- gameloop.cpp 11 Apr 2004 11:52:29 -0000 1.54 +++ gameloop.cpp 11 Apr 2004 13:00:00 -0000 1.55 @@ -432,16 +432,6 @@ world->action(); - /* update particle systems */ - std::vector<ParticleSystem*>::iterator p; - for(p = world->particle_systems.begin(); p != world->particle_systems.end(); ++p) - { - (*p)->simulate(frame_ratio); - } - - /* Handle all possible collisions. */ - collision_handler(); - return -1; } Index: collision.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/collision.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- collision.cpp 11 Apr 2004 11:52:29 -0000 1.13 +++ collision.cpp 11 Apr 2004 12:59:59 -0000 1.14 @@ -39,9 +39,9 @@ int h = (int)pbase->width / 16; if(issolid(pbase->x + 1, pbase->y + 1) || - issolid(pbase->x + pbase->width -1, pbase->y + 1) || - issolid(pbase->x +1, pbase->y + pbase->height -1) || - issolid(pbase->x + pbase->width -1, pbase->y + pbase->height - 1)) + issolid(pbase->x + pbase->width -1, pbase->y + 1) || + issolid(pbase->x +1, pbase->y + pbase->height -1) || + issolid(pbase->x + pbase->width -1, pbase->y + pbase->height - 1)) return true; for(int i = 1; i < h; ++i) @@ -203,86 +203,6 @@ *old = *current; } -void collision_handler() -{ - // CO_BULLET & CO_BADGUY check - for(unsigned int i = 0; i < world.bullets.size(); ++i) - { - for(unsigned int j = 0; j < world.bad_guys.size(); ++j) - { - if(world.bad_guys[j].dying != DYING_NOT) - continue; - if(rectcollision(&world.bullets[i].base, &world.bad_guys[j].base)) - { - // We have detected a collision and now call the - // collision functions of the collided objects. - // collide with bad_guy first, since bullet_collision will - // delete the bullet - world.bad_guys[j].collision(0, CO_BULLET); - bullet_collision(&world.bullets[i], CO_BADGUY); - break; // bullet is invalid now, so break - } - } - } - - /* CO_BADGUY & CO_BADGUY check */ - for(unsigned int i = 0; i < world.bad_guys.size(); ++i) - { - if(world.bad_guys[i].dying != DYING_NOT) - continue; - - for(unsigned int j = i+1; j < world.bad_guys.size(); ++j) - { - if(j == i || world.bad_guys[j].dying != DYING_NOT) - continue; - - if(rectcollision(&world.bad_guys[i].base, &world.bad_guys[j].base)) - { - // We have detected a collision and now call the - // collision functions of the collided objects. - world.bad_guys[j].collision(&world.bad_guys[i], CO_BADGUY); - world.bad_guys[i].collision(&world.bad_guys[j], CO_BADGUY); - } - } - } - - if(tux.dying != DYING_NOT) return; - - // CO_BADGUY & CO_PLAYER check - for(unsigned int i = 0; i < world.bad_guys.size(); ++i) - { - if(world.bad_guys[i].dying != DYING_NOT) - continue; - - if(rectcollision_offset(&world.bad_guys[i].base,&tux.base,0,0)) - { - // We have detected a collision and now call the collision - // functions of the collided objects. - if (tux.previous_base.y < tux.base.y && - tux.previous_base.y + tux.previous_base.height - < world.bad_guys[i].base.y + world.bad_guys[i].base.height/2) - { - world.bad_guys[i].collision(&tux, CO_PLAYER, COLLISION_SQUISH); - } - else - { - tux.collision(&world.bad_guys[i], CO_BADGUY); - } - } - } - - // CO_UPGRADE & CO_PLAYER check - for(unsigned int i = 0; i < world.upgrades.size(); ++i) - { - if(rectcollision(&world.upgrades[i].base, &tux.base)) - { - // We have detected a collision and now call the collision - // functions of the collided objects. - upgrade_collision(&world.upgrades[i], &tux, CO_PLAYER); - } - } -} - Tile* gettile(float x, float y) { Index: collision.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/collision.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- collision.h 11 Apr 2004 00:05:35 -0000 1.7 +++ collision.h 11 Apr 2004 13:00:00 -0000 1.8 @@ -15,6 +15,7 @@ #include "type.h" class Tile; +class World; /* Collision objects */ enum @@ -32,13 +33,10 @@ bool rectcollision(base_type* one, base_type* two); bool rectcollision_offset(base_type* one, base_type* two, float off_x, float off_y); + void collision_swept_object_map(base_type* old, base_type* current); bool collision_object_map(base_type* object); -/* Checks for all possible collisions. - And calls the collision_handlers, which the collision_objects provide for this case (or not). */ -void collision_handler(); - /** Return a pointer to the tile at the given x/y coordinates */ Tile* gettile(float x, float y); |
From: Ingo R. <gr...@us...> - 2004-04-11 12:57:14
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6233 Modified Files: gameobjs.cpp gameobjs.h world.cpp world.h Log Message: - change gameobjs names from lower case to upper case Index: gameobjs.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameobjs.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- gameobjs.cpp 11 Apr 2004 12:37:40 -0000 1.2 +++ gameobjs.cpp 11 Apr 2004 12:43:35 -0000 1.3 @@ -23,7 +23,7 @@ #include "gameobjs.h" void -bouncy_distro_type::init(float x, float y) +BouncyDistro::init(float x, float y) { base.x = x; base.y = y; @@ -31,18 +31,18 @@ } void -bouncy_distro_type::action() +BouncyDistro::action() { base.y = base.y + base.ym * frame_ratio; base.ym += 0.1 * frame_ratio; if (base.ym >= 0) - world.bouncy_distros.erase(static_cast<std::vector<bouncy_distro_type>::iterator>(this)); + world.bouncy_distros.erase(static_cast<std::vector<BouncyDistro>::iterator>(this)); } void -bouncy_distro_type::draw() +BouncyDistro::draw() { texture_draw(&img_distro[0], base.x - scroll_x, @@ -51,7 +51,7 @@ void -broken_brick_type::init(Tile* tile_, float x, float y, float xm, float ym) +BrokenBrick::init(Tile* tile_, float x, float y, float xm, float ym) { tile = tile_; base.x = x; @@ -64,17 +64,17 @@ } void -broken_brick_type::action() +BrokenBrick::action() { base.x = base.x + base.xm * frame_ratio; base.y = base.y + base.ym * frame_ratio; if (!timer_check(&timer)) - world.broken_bricks.erase(static_cast<std::vector<broken_brick_type>::iterator>(this)); + world.broken_bricks.erase(static_cast<std::vector<BrokenBrick>::iterator>(this)); } void -broken_brick_type::draw() +BrokenBrick::draw() { SDL_Rect src, dest; src.x = rand() % 16; @@ -93,7 +93,7 @@ } void -bouncy_brick_type::init(float x, float y) +BouncyBrick::init(float x, float y) { base.x = x; base.y = y; @@ -103,7 +103,7 @@ } void -bouncy_brick_type::action() +BouncyBrick::action() { offset = (offset + offset_m * frame_ratio); @@ -115,11 +115,11 @@ /* Stop bouncing? */ if (offset >= 0) - world.bouncy_bricks.erase(static_cast<std::vector<bouncy_brick_type>::iterator>(this)); + world.bouncy_bricks.erase(static_cast<std::vector<BouncyBrick>::iterator>(this)); } void -bouncy_brick_type::draw() +BouncyBrick::draw() { int s; SDL_Rect dest; @@ -156,7 +156,7 @@ } void -floating_score_type::init(float x, float y, int s) +FloatingScore::init(float x, float y, int s) { base.x = x; base.y = y - 16; @@ -166,16 +166,16 @@ } void -floating_score_type::action() +FloatingScore::action() { base.y = base.y - 2 * frame_ratio; if(!timer_check(&timer)) - world.floating_scores.erase(static_cast<std::vector<floating_score_type>::iterator>(this)); + world.floating_scores.erase(static_cast<std::vector<FloatingScore>::iterator>(this)); } void -floating_score_type::draw() +FloatingScore::draw() { char str[10]; sprintf(str, "%d", value); Index: world.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.h,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- world.h 11 Apr 2004 12:37:40 -0000 1.14 +++ world.h 11 Apr 2004 12:43:35 -0000 1.15 @@ -35,10 +35,10 @@ public: Level* level; - std::vector<bouncy_distro_type> bouncy_distros; - std::vector<broken_brick_type> broken_bricks; - std::vector<bouncy_brick_type> bouncy_bricks; - std::vector<floating_score_type> floating_scores; + std::vector<BouncyDistro> bouncy_distros; + std::vector<BrokenBrick> broken_bricks; + std::vector<BouncyBrick> bouncy_bricks; + std::vector<FloatingScore> floating_scores; std::vector<BadGuy> bad_guys; std::vector<upgrade_type> upgrades; Index: world.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- world.cpp 11 Apr 2004 12:37:40 -0000 1.12 +++ world.cpp 11 Apr 2004 12:43:35 -0000 1.13 @@ -256,15 +256,15 @@ { score += s; - floating_score_type new_floating_score; -new_floating_score.init(x,y,s); + FloatingScore new_floating_score; + new_floating_score.init(x,y,s); floating_scores.push_back(new_floating_score); } void World::add_bouncy_distro(float x, float y) { - bouncy_distro_type new_bouncy_distro; + BouncyDistro new_bouncy_distro; new_bouncy_distro.init(x,y); bouncy_distros.push_back(new_bouncy_distro); } @@ -282,7 +282,7 @@ void World::add_broken_brick_piece(Tile* tile, float x, float y, float xm, float ym) { - broken_brick_type new_broken_brick; + BrokenBrick new_broken_brick; new_broken_brick.init(tile, x, y, xm, ym); broken_bricks.push_back(new_broken_brick); } @@ -290,7 +290,7 @@ void World::add_bouncy_brick(float x, float y) { - bouncy_brick_type new_bouncy_brick; + BouncyBrick new_bouncy_brick; new_bouncy_brick.init(x,y); bouncy_bricks.push_back(new_bouncy_brick); } Index: gameobjs.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameobjs.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- gameobjs.h 11 Apr 2004 12:37:40 -0000 1.2 +++ gameobjs.h 11 Apr 2004 12:43:35 -0000 1.3 @@ -29,7 +29,7 @@ #define NO_BOUNCE 0 #define BOUNCE 1 -class bouncy_distro_type +class BouncyDistro { public: base_type base; @@ -46,7 +46,7 @@ class Tile; -class broken_brick_type +class BrokenBrick { public: base_type base; @@ -58,7 +58,7 @@ void draw(); }; -class bouncy_brick_type +class BouncyBrick { public: float offset; @@ -71,7 +71,7 @@ void draw(); }; -class floating_score_type +class FloatingScore { public: int value; |
From: Ingo R. <gr...@us...> - 2004-04-11 12:51:19
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5261 Modified Files: badguy.cpp gameobjs.cpp gameobjs.h player.cpp resources.cpp world.cpp world.h Log Message: - moved some more stuff into the world class - turned gameobjs into classes Index: world.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.h,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- world.h 11 Apr 2004 11:52:29 -0000 1.13 +++ world.h 11 Apr 2004 12:37:40 -0000 1.14 @@ -1,14 +1,21 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2004 SuperTux Development Team, see AUTHORS for details // -// Interface: world -// -// Description: -// -// -// Author: Tobias Glaesser <tob...@gm...>, (C) 2003 -// -// Copyright: See COPYING file that comes with this distribution -// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. // +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef SUPERTUX_WORLD_H #define SUPERTUX_WORLD_H @@ -21,20 +28,6 @@ #include "particlesystem.h" #include "gameobjs.h" -/** Try to grab the coin at the given coordinates */ -void trygrabdistro(float x, float y, int bounciness); - -/** Try to break the brick at the given coordinates */ -void trybreakbrick(float x, float y, bool small); - -/** Try to get the content out of a bonus box, thus emptying it */ -void tryemptybox(float x, float y, int col_side); - -/** Try to bumb a badguy that might we walking above Tux, thus shaking - the tile which the badguy is walking on an killing him this way */ -void trybumpbadguy(float x, float y); - - /** The World class holds a level and all the game objects (badguys, bouncy distros, etc) that are needed to run a game. */ class World @@ -86,6 +79,19 @@ void add_bad_guy(float x, float y, BadGuyKind kind); void add_upgrade(float x, float y, int dir, int kind); void add_bullet(float x, float y, float xm, int dir); + + /** Try to grab the coin at the given coordinates */ + void trygrabdistro(float x, float y, int bounciness); + + /** Try to break the brick at the given coordinates */ + void trybreakbrick(float x, float y, bool small); + + /** Try to get the content out of a bonus box, thus emptying it */ + void tryemptybox(float x, float y, int col_side); + + /** Try to bumb a badguy that might we walking above Tux, thus shaking + the tile which the badguy is walking on an killing him this way */ + void trybumpbadguy(float x, float y); }; extern World world; Index: gameobjs.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameobjs.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- gameobjs.cpp 11 Apr 2004 11:52:29 -0000 1.1 +++ gameobjs.cpp 11 Apr 2004 12:37:40 -0000 1.2 @@ -1,55 +1,80 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2004 SuperTux Development Team, see AUTHORS for details +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + #include "world.h" #include "tile.h" #include "gameloop.h" #include "gameobjs.h" -void bouncy_distro_init(bouncy_distro_type* pbouncy_distro, float x, float y) +void +bouncy_distro_type::init(float x, float y) { - pbouncy_distro->base.x = x; - pbouncy_distro->base.y = y; - pbouncy_distro->base.ym = -2; + base.x = x; + base.y = y; + base.ym = -2; } -void bouncy_distro_action(bouncy_distro_type* pbouncy_distro) +void +bouncy_distro_type::action() { - pbouncy_distro->base.y = pbouncy_distro->base.y + pbouncy_distro->base.ym * frame_ratio; + base.y = base.y + base.ym * frame_ratio; - pbouncy_distro->base.ym += 0.1 * frame_ratio; + base.ym += 0.1 * frame_ratio; - if (pbouncy_distro->base.ym >= 0) - world.bouncy_distros.erase(static_cast<std::vector<bouncy_distro_type>::iterator>(pbouncy_distro)); + if (base.ym >= 0) + world.bouncy_distros.erase(static_cast<std::vector<bouncy_distro_type>::iterator>(this)); } -void bouncy_distro_draw(bouncy_distro_type* pbouncy_distro) +void +bouncy_distro_type::draw() { texture_draw(&img_distro[0], - pbouncy_distro->base.x - scroll_x, - pbouncy_distro->base.y); + base.x - scroll_x, + base.y); } -void broken_brick_init(broken_brick_type* pbroken_brick, Tile* tile, - float x, float y, float xm, float ym) + +void +broken_brick_type::init(Tile* tile_, float x, float y, float xm, float ym) { - pbroken_brick->tile = tile; - pbroken_brick->base.x = x; - pbroken_brick->base.y = y; - pbroken_brick->base.xm = xm; - pbroken_brick->base.ym = ym; + tile = tile_; + base.x = x; + base.y = y; + base.xm = xm; + base.ym = ym; - timer_init(&pbroken_brick->timer, true); - timer_start(&pbroken_brick->timer,200); + timer_init(&timer, true); + timer_start(&timer,200); } -void broken_brick_action(broken_brick_type* pbroken_brick) +void +broken_brick_type::action() { - pbroken_brick->base.x = pbroken_brick->base.x + pbroken_brick->base.xm * frame_ratio; - pbroken_brick->base.y = pbroken_brick->base.y + pbroken_brick->base.ym * frame_ratio; + base.x = base.x + base.xm * frame_ratio; + base.y = base.y + base.ym * frame_ratio; - if (!timer_check(&pbroken_brick->timer)) - world.broken_bricks.erase(static_cast<std::vector<broken_brick_type>::iterator>(pbroken_brick)); + if (!timer_check(&timer)) + world.broken_bricks.erase(static_cast<std::vector<broken_brick_type>::iterator>(this)); } -void broken_brick_draw(broken_brick_type* pbroken_brick) +void +broken_brick_type::draw() { SDL_Rect src, dest; src.x = rand() % 16; @@ -57,63 +82,63 @@ src.w = 16; src.h = 16; - dest.x = (int)(pbroken_brick->base.x - scroll_x); - dest.y = (int)pbroken_brick->base.y; + dest.x = (int)(base.x - scroll_x); + dest.y = (int)base.y; dest.w = 16; dest.h = 16; - if (pbroken_brick->tile->images.size() > 0) - texture_draw_part(&pbroken_brick->tile->images[0], + if (tile->images.size() > 0) + texture_draw_part(&tile->images[0], src.x,src.y,dest.x,dest.y,dest.w,dest.h); } -void bouncy_brick_init(bouncy_brick_type* pbouncy_brick, float x, float y) +void +bouncy_brick_type::init(float x, float y) { - pbouncy_brick->base.x = x; - pbouncy_brick->base.y = y; - pbouncy_brick->offset = 0; - pbouncy_brick->offset_m = -BOUNCY_BRICK_SPEED; - pbouncy_brick->shape = GameSession::current()->get_level()->gettileid(x, y); + base.x = x; + base.y = y; + offset = 0; + offset_m = -BOUNCY_BRICK_SPEED; + shape = World::current()->get_level()->gettileid(x, y); } -void bouncy_brick_action(bouncy_brick_type* pbouncy_brick) +void +bouncy_brick_type::action() { - - pbouncy_brick->offset = (pbouncy_brick->offset + - pbouncy_brick->offset_m * frame_ratio); + offset = (offset + + offset_m * frame_ratio); /* Go back down? */ - - if (pbouncy_brick->offset < -BOUNCY_BRICK_MAX_OFFSET) - pbouncy_brick->offset_m = BOUNCY_BRICK_SPEED; + if (offset < -BOUNCY_BRICK_MAX_OFFSET) + offset_m = BOUNCY_BRICK_SPEED; /* Stop bouncing? */ - - if (pbouncy_brick->offset >= 0) - world.bouncy_bricks.erase(static_cast<std::vector<bouncy_brick_type>::iterator>(pbouncy_brick)); + if (offset >= 0) + world.bouncy_bricks.erase(static_cast<std::vector<bouncy_brick_type>::iterator>(this)); } -void bouncy_brick_draw(bouncy_brick_type* pbouncy_brick) +void +bouncy_brick_type::draw() { int s; SDL_Rect dest; - if (pbouncy_brick->base.x >= scroll_x - 32 && - pbouncy_brick->base.x <= scroll_x + screen->w) + if (base.x >= scroll_x - 32 && + base.x <= scroll_x + screen->w) { - dest.x = (int)(pbouncy_brick->base.x - scroll_x); - dest.y = (int)pbouncy_brick->base.y; + dest.x = (int)(base.x - scroll_x); + dest.y = (int)base.y; dest.w = 32; dest.h = 32; - Level* plevel = GameSession::current()->get_level(); + Level* plevel = World::current()->get_level(); // FIXME: overdrawing hack to clean the tile from the screen to // paint it later at on offseted position if(plevel->bkgd_image[0] == '\0') { - fillrect(pbouncy_brick->base.x - scroll_x, pbouncy_brick->base.y, + fillrect(base.x - scroll_x, base.y, 32,32, plevel->bkgd_red, plevel->bkgd_green, plevel->bkgd_blue, 0); } @@ -124,34 +149,37 @@ dest.x, dest.y,dest.w,dest.h); } - Tile::draw(pbouncy_brick->base.x - scroll_x, - pbouncy_brick->base.y + pbouncy_brick->offset, - pbouncy_brick->shape); + Tile::draw(base.x - scroll_x, + base.y + offset, + shape); } } -void floating_score_init(floating_score_type* pfloating_score, float x, float y, int s) +void +floating_score_type::init(float x, float y, int s) { - pfloating_score->base.x = x; - pfloating_score->base.y = y - 16; - timer_init(&pfloating_score->timer,true); - timer_start(&pfloating_score->timer,1000); - pfloating_score->value = s; + base.x = x; + base.y = y - 16; + timer_init(&timer,true); + timer_start(&timer,1000); + value = s; } -void floating_score_action(floating_score_type* pfloating_score) +void +floating_score_type::action() { - pfloating_score->base.y = pfloating_score->base.y - 2 * frame_ratio; + base.y = base.y - 2 * frame_ratio; - if(!timer_check(&pfloating_score->timer)) - world.floating_scores.erase(static_cast<std::vector<floating_score_type>::iterator>(pfloating_score)); + if(!timer_check(&timer)) + world.floating_scores.erase(static_cast<std::vector<floating_score_type>::iterator>(this)); } -void floating_score_draw(floating_score_type* pfloating_score) +void +floating_score_type::draw() { char str[10]; - sprintf(str, "%d", pfloating_score->value); - text_draw(&gold_text, str, (int)pfloating_score->base.x + 16 - strlen(str) * 8, (int)pfloating_score->base.y, 1); + sprintf(str, "%d", value); + text_draw(&gold_text, str, (int)base.x + 16 - strlen(str) * 8, (int)base.y, 1); } /* EOF */ Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- player.cpp 10 Apr 2004 22:37:13 -0000 1.24 +++ player.cpp 11 Apr 2004 12:37:40 -0000 1.25 @@ -208,26 +208,26 @@ if (isbrick(base.x, base.y) || isfullbox(base.x, base.y)) { - trygrabdistro(base.x, base.y - 32,BOUNCE); - trybumpbadguy(base.x, base.y - 64); + World::current()->trygrabdistro(base.x, base.y - 32,BOUNCE); + World::current()->trybumpbadguy(base.x, base.y - 64); - trybreakbrick(base.x, base.y, size == SMALL); + World::current()->trybreakbrick(base.x, base.y, size == SMALL); bumpbrick(base.x, base.y); - tryemptybox(base.x, base.y, RIGHT); + World::current()->tryemptybox(base.x, base.y, RIGHT); } if (isbrick(base.x+ 31, base.y) || isfullbox(base.x+ 31, base.y)) { - trygrabdistro(base.x+ 31, base.y - 32,BOUNCE); - trybumpbadguy(base.x+ 31, base.y - 64); + World::current()->trygrabdistro(base.x+ 31, base.y - 32,BOUNCE); + World::current()->trybumpbadguy(base.x+ 31, base.y - 64); if(size == BIG) - trybreakbrick(base.x+ 31, base.y, size == SMALL); + World::current()->trybreakbrick(base.x+ 31, base.y, size == SMALL); bumpbrick(base.x+ 31, base.y); - tryemptybox(base.x+ 31, base.y, LEFT); + World::current()->tryemptybox(base.x+ 31, base.y, LEFT); } } @@ -478,7 +478,7 @@ if (input.fire == DOWN && input.old_fire == UP && got_coffee) { - world.add_bullet(base.x, base.y, physic.get_velocity_x(), dir); + World::current()->add_bullet(base.x, base.y, physic.get_velocity_x(), dir); } @@ -551,16 +551,16 @@ /* Grab distros: */ if (!dying) { - trygrabdistro(base.x, base.y, NO_BOUNCE); - trygrabdistro(base.x+ 31, base.y, NO_BOUNCE); + World::current()->trygrabdistro(base.x, base.y, NO_BOUNCE); + World::current()->trygrabdistro(base.x+ 31, base.y, NO_BOUNCE); - trygrabdistro(base.x, base.y + base.height, NO_BOUNCE); - trygrabdistro(base.x+ 31, base.y + base.height, NO_BOUNCE); + World::current()->trygrabdistro(base.x, base.y + base.height, NO_BOUNCE); + World::current()->trygrabdistro(base.x+ 31, base.y + base.height, NO_BOUNCE); if(size == BIG) { - trygrabdistro(base.x, base.y + base.height / 2, NO_BOUNCE); - trygrabdistro(base.x+ 31, base.y + base.height / 2, NO_BOUNCE); + World::current()->trygrabdistro(base.x, base.y + base.height / 2, NO_BOUNCE); + World::current()->trygrabdistro(base.x+ 31, base.y + base.height / 2, NO_BOUNCE); } } @@ -827,9 +827,9 @@ { pbad_c->dying = DYING_FALLING; play_sound(sounds[SND_FALL], SOUND_CENTER_SPEAKER); - world.add_score(pbad_c->base.x - scroll_x, - pbad_c->base.y, - 25 * score_multiplier); + World::current()->add_score(pbad_c->base.x - scroll_x, + pbad_c->base.y, + 25 * score_multiplier); } } } Index: gameobjs.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameobjs.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- gameobjs.h 11 Apr 2004 11:52:29 -0000 1.1 +++ gameobjs.h 11 Apr 2004 12:37:40 -0000 1.2 @@ -1,3 +1,21 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2004 SuperTux Development Team, see AUTHORS for details +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef SUPERTUX_GAMEOBJS_H #define SUPERTUX_GAMEOBJS_H @@ -15,15 +33,14 @@ { public: base_type base; + + void init(float x, float y); + void action(); + void draw(); }; extern texture_type img_distro[4]; -void bouncy_distro_init(bouncy_distro_type* pbouncy_distro, float x, float y); -void bouncy_distro_action(bouncy_distro_type* pbouncy_distro); -void bouncy_distro_draw(bouncy_distro_type* pbouncy_distro); -void bouncy_distro_collision(bouncy_distro_type* pbouncy_distro, int c_object); - #define BOUNCY_BRICK_MAX_OFFSET 8 #define BOUNCY_BRICK_SPEED 0.9 @@ -35,12 +52,11 @@ base_type base; timer_type timer; Tile* tile; -}; -void broken_brick_init(broken_brick_type* pbroken_brick, Tile* tile, - float x, float y, float xm, float ym); -void broken_brick_action(broken_brick_type* pbroken_brick); -void broken_brick_draw(broken_brick_type* pbroken_brick); + void init(Tile* tile, float x, float y, float xm, float ym); + void action(); + void draw(); +}; class bouncy_brick_type { @@ -49,11 +65,11 @@ float offset_m; int shape; base_type base; -}; -void bouncy_brick_init(bouncy_brick_type* pbouncy_brick, float x, float y); -void bouncy_brick_action(bouncy_brick_type* pbouncy_brick); -void bouncy_brick_draw(bouncy_brick_type* pbouncy_brick); + void init(float x, float y); + void action(); + void draw(); +}; class floating_score_type { @@ -61,12 +77,12 @@ int value; timer_type timer; base_type base; + + void init(float x, float y, int s); + void action(); + void draw(); }; -void floating_score_init(floating_score_type* pfloating_score, float x, float y, int s); -void floating_score_action(floating_score_type* pfloating_score); -void floating_score_draw(floating_score_type* pfloating_score); - #endif /* Local Variables: */ Index: world.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- world.cpp 11 Apr 2004 11:52:29 -0000 1.11 +++ world.cpp 11 Apr 2004 12:37:40 -0000 1.12 @@ -1,14 +1,21 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2004 SuperTux Development Team, see AUTHORS for details // -// C Implementation: world -// -// Description: -// -// -// Author: Tobias Glaesser <tob...@gm...>, (C) 2004 -// -// Copyright: See COPYING file that comes with this distribution -// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. // +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <math.h> #include <stdlib.h> @@ -168,7 +175,7 @@ /* (Bouncy bricks): */ for (unsigned int i = 0; i < bouncy_bricks.size(); ++i) - bouncy_brick_draw(&bouncy_bricks[i]); + bouncy_bricks[i].draw(); for (unsigned int i = 0; i < bad_guys.size(); ++i) bad_guys[i].draw(); @@ -179,16 +186,16 @@ bullet_draw(&bullets[i]); for (unsigned int i = 0; i < floating_scores.size(); ++i) - floating_score_draw(&floating_scores[i]); + floating_scores[i].draw(); for (unsigned int i = 0; i < upgrades.size(); ++i) upgrade_draw(&upgrades[i]); for (unsigned int i = 0; i < bouncy_distros.size(); ++i) - bouncy_distro_draw(&bouncy_distros[i]); + bouncy_distros[i].draw(); for (unsigned int i = 0; i < broken_bricks.size(); ++i) - broken_brick_draw(&broken_bricks[i]); + broken_bricks[i].draw(); /* Draw foreground: */ for (y = 0; y < 15; ++y) @@ -212,11 +219,11 @@ { /* Handle bouncy distros: */ for (unsigned int i = 0; i < bouncy_distros.size(); i++) - bouncy_distro_action(&bouncy_distros[i]); + bouncy_distros[i].action(); /* Handle broken bricks: */ for (unsigned int i = 0; i < broken_bricks.size(); i++) - broken_brick_action(&broken_bricks[i]); + broken_bricks[i].action(); /* Handle distro counting: */ if (counting_distros) @@ -229,10 +236,10 @@ // Handle all kinds of game objects for (unsigned int i = 0; i < bouncy_bricks.size(); i++) - bouncy_brick_action(&bouncy_bricks[i]); + bouncy_bricks[i].action(); for (unsigned int i = 0; i < floating_scores.size(); i++) - floating_score_action(&floating_scores[i]); + floating_scores[i].action(); for (unsigned int i = 0; i < bullets.size(); ++i) bullet_action(&bullets[i]); @@ -250,7 +257,7 @@ score += s; floating_score_type new_floating_score; - floating_score_init(&new_floating_score,x,y,s); +new_floating_score.init(x,y,s); floating_scores.push_back(new_floating_score); } @@ -258,7 +265,7 @@ World::add_bouncy_distro(float x, float y) { bouncy_distro_type new_bouncy_distro; - bouncy_distro_init(&new_bouncy_distro,x,y); + new_bouncy_distro.init(x,y); bouncy_distros.push_back(new_bouncy_distro); } @@ -276,7 +283,7 @@ World::add_broken_brick_piece(Tile* tile, float x, float y, float xm, float ym) { broken_brick_type new_broken_brick; - broken_brick_init(&new_broken_brick, tile, x, y, xm, ym); + new_broken_brick.init(tile, x, y, xm, ym); broken_bricks.push_back(new_broken_brick); } @@ -284,7 +291,7 @@ World::add_bouncy_brick(float x, float y) { bouncy_brick_type new_bouncy_brick; - bouncy_brick_init(&new_bouncy_brick,x,y); + new_bouncy_brick.init(x,y); bouncy_bricks.push_back(new_bouncy_brick); } @@ -316,9 +323,10 @@ } /* Break a brick: */ -void trybreakbrick(float x, float y, bool small) +void +World::trybreakbrick(float x, float y, bool small) { - Level* plevel = World::current()->get_level(); + Level* plevel = get_level(); Tile* tile = gettile(x, y); if (tile->brick) @@ -326,7 +334,7 @@ if (tile->data > 0) { /* Get a distro from it: */ - world.add_bouncy_distro(((int)(x + 1) / 32) * 32, + add_bouncy_distro(((int)(x + 1) / 32) * 32, (int)(y / 32) * 32); if (!counting_distros) @@ -348,7 +356,7 @@ plevel->change(x, y, TM_IA, tile->next_tile); /* Replace it with broken bits: */ - world.add_broken_brick(tile, + add_broken_brick(tile, ((int)(x + 1) / 32) * 32, (int)(y / 32) * 32); @@ -360,10 +368,9 @@ } /* Empty a box: */ -void tryemptybox(float x, float y, int col_side) +void +World::tryemptybox(float x, float y, int col_side) { - Level* plevel = World::current()->get_level(); - Tile* tile = gettile(x,y); if (!tile->fullbox) return; @@ -376,45 +383,45 @@ switch(tile->data) { - case 1: //'A': /* Box with a distro! */ - world.add_bouncy_distro(((int)(x + 1) / 32) * 32, (int)(y / 32) * 32 - 32); + case 1: // Box with a distro! + add_bouncy_distro(((int)(x + 1) / 32) * 32, (int)(y / 32) * 32 - 32); play_sound(sounds[SND_DISTRO], SOUND_CENTER_SPEAKER); score = score + SCORE_DISTRO; distros++; break; - case 2: // 'B': /* Add an upgrade! */ + case 2: // Add an upgrade! if (tux.size == SMALL) /* Tux is small, add mints! */ - world.add_upgrade((int)((x + 1) / 32) * 32, (int)(y / 32) * 32 - 32, col_side, UPGRADE_MINTS); + add_upgrade((int)((x + 1) / 32) * 32, (int)(y / 32) * 32 - 32, col_side, UPGRADE_MINTS); else /* Tux is big, add coffee: */ - world.add_upgrade((int)((x + 1) / 32) * 32, (int)(y / 32) * 32 - 32, col_side, UPGRADE_COFFEE); + add_upgrade((int)((x + 1) / 32) * 32, (int)(y / 32) * 32 - 32, col_side, UPGRADE_COFFEE); play_sound(sounds[SND_UPGRADE], SOUND_CENTER_SPEAKER); break; - case 3:// '!': /* Add a golden herring */ - world.add_upgrade((int)((x + 1) / 32) * 32, (int)(y / 32) * 32 - 32, col_side, UPGRADE_HERRING); + case 3: // Add a golden herring + add_upgrade((int)((x + 1) / 32) * 32, (int)(y / 32) * 32 - 32, col_side, UPGRADE_HERRING); break; default: break; } /* Empty the box: */ - plevel->change(x, y, TM_IA, tile->next_tile); + level->change(x, y, TM_IA, tile->next_tile); } /* Try to grab a distro: */ -void trygrabdistro(float x, float y, int bounciness) +void +World::trygrabdistro(float x, float y, int bounciness) { - Level* plevel = World::current()->get_level(); Tile* tile = gettile(x, y); if (tile && tile->distro) { - plevel->change(x, y, TM_IA, tile->next_tile); + level->change(x, y, TM_IA, tile->next_tile); play_sound(sounds[SND_DISTRO], SOUND_CENTER_SPEAKER); if (bounciness == BOUNCE) { - world.add_bouncy_distro(((int)(x + 1) / 32) * 32, + add_bouncy_distro(((int)(x + 1) / 32) * 32, (int)(y / 32) * 32); } @@ -424,28 +431,29 @@ } /* Try to bump a bad guy from below: */ -void trybumpbadguy(float x, float y) +void +World::trybumpbadguy(float x, float y) { /* Bad guys: */ - for (unsigned int i = 0; i < world.bad_guys.size(); i++) + for (unsigned int i = 0; i < bad_guys.size(); i++) { - if (world.bad_guys[i].base.x >= x - 32 && world.bad_guys[i].base.x <= x + 32 && - world.bad_guys[i].base.y >= y - 16 && world.bad_guys[i].base.y <= y + 16) + if (bad_guys[i].base.x >= x - 32 && bad_guys[i].base.x <= x + 32 && + bad_guys[i].base.y >= y - 16 && bad_guys[i].base.y <= y + 16) { - world.bad_guys[i].collision(&tux, CO_PLAYER, COLLISION_BUMP); + bad_guys[i].collision(&tux, CO_PLAYER, COLLISION_BUMP); } } /* Upgrades: */ - for (unsigned int i = 0; i < world.upgrades.size(); i++) + for (unsigned int i = 0; i < upgrades.size(); i++) { - if (world.upgrades[i].base.height == 32 && - world.upgrades[i].base.x >= x - 32 && world.upgrades[i].base.x <= x + 32 && - world.upgrades[i].base.y >= y - 16 && world.upgrades[i].base.y <= y + 16) + if (upgrades[i].base.height == 32 && + upgrades[i].base.x >= x - 32 && upgrades[i].base.x <= x + 32 && + upgrades[i].base.y >= y - 16 && upgrades[i].base.y <= y + 16) { - world.upgrades[i].base.xm = -world.upgrades[i].base.xm; - world.upgrades[i].base.ym = -8; + upgrades[i].base.xm = -upgrades[i].base.xm; + upgrades[i].base.ym = -8; play_sound(sounds[SND_BUMP_UPGRADE], SOUND_CENTER_SPEAKER); } } Index: badguy.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- badguy.cpp 11 Apr 2004 11:52:29 -0000 1.23 +++ badguy.cpp 11 Apr 2004 12:37:40 -0000 1.24 @@ -373,11 +373,11 @@ void BadGuy::remove_me() { - for(std::vector<BadGuy>::iterator i = world.bad_guys.begin(); - i != world.bad_guys.end(); ++i) + for(std::vector<BadGuy>::iterator i = World::current()->bad_guys.begin(); + i != World::current()->bad_guys.end(); ++i) { if( & (*i) == this) { - world.bad_guys.erase(i); + World::current()->bad_guys.erase(i); return; } } @@ -785,7 +785,7 @@ { make_player_jump(player); - world.add_score(base.x - scroll_x, base.y, 50 * score_multiplier); + World::current()->add_score(base.x - scroll_x, base.y, 50 * score_multiplier); play_sound(sounds[SND_SQUISH], SOUND_CENTER_SPEAKER); score_multiplier++; @@ -799,10 +799,10 @@ { if(kind == BAD_MRBOMB) { // mrbomb transforms into a bomb now - world.add_bad_guy(base.x, base.y, BAD_BOMB); + World::current()->add_bad_guy(base.x, base.y, BAD_BOMB); make_player_jump(player); - world.add_score(base.x - scroll_x, base.y, 50 * score_multiplier); + World::current()->add_score(base.x - scroll_x, base.y, 50 * score_multiplier); play_sound(sounds[SND_SQUISH], SOUND_CENTER_SPEAKER); score_multiplier++; @@ -843,13 +843,13 @@ make_player_jump(player); - world.add_score(base.x - scroll_x, base.y, 25 * score_multiplier); + World::current()->add_score(base.x - scroll_x, base.y, 25 * score_multiplier); score_multiplier++; return; } else if(kind == BAD_FISH) { make_player_jump(player); - world.add_score(base.x - scroll_x, base.y, 25 * score_multiplier); + World::current()->add_score(base.x - scroll_x, base.y, 25 * score_multiplier); score_multiplier++; // simply remove the fish... @@ -887,10 +887,10 @@ /* Gain some points: */ if (kind == BAD_BSOD) - world.add_score(base.x - scroll_x, base.y, + World::current()->add_score(base.x - scroll_x, base.y, 50 * score_multiplier); else - world.add_score(base.x - scroll_x, base.y, + World::current()->add_score(base.x - scroll_x, base.y, 25 * score_multiplier); /* Play death sound: */ Index: resources.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/resources.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- resources.cpp 11 Apr 2004 11:52:29 -0000 1.2 +++ resources.cpp 11 Apr 2004 12:37:40 -0000 1.3 @@ -364,4 +364,3 @@ } /* EOF */ - |
From: Ingo R. <gr...@us...> - 2004-04-11 12:06:10
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30182 Modified Files: Makefile.am badguy.cpp collision.cpp gameloop.cpp level.h leveleditor.cpp resources.cpp scene.cpp scene.h tile.cpp tile.h title.cpp world.cpp world.h Added Files: gameobjs.cpp gameobjs.h Log Message: - moved gameobjects into there own file - moved drawshape to tile.h Index: tile.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/tile.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- tile.h 4 Apr 2004 00:32:10 -0000 1.9 +++ tile.h 11 Apr 2004 11:52:29 -0000 1.10 @@ -57,6 +57,9 @@ int next_tile; int anim_speed; + + /** Draw a tile on the screen: */ + static void draw(float x, float y, unsigned int c, Uint8 alpha = 255); }; struct TileGroup @@ -92,6 +95,4 @@ } }; - - #endif Index: world.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.h,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- world.h 11 Apr 2004 01:36:22 -0000 1.12 +++ world.h 11 Apr 2004 11:52:29 -0000 1.13 @@ -19,61 +19,7 @@ #include "scene.h" #include "special.h" #include "particlesystem.h" - -/* Bounciness of distros: */ - -#define NO_BOUNCE 0 -#define BOUNCE 1 - -struct bouncy_distro_type -{ - base_type base; -}; - -extern texture_type img_distro[4]; - -void bouncy_distro_init(bouncy_distro_type* pbouncy_distro, float x, float y); -void bouncy_distro_action(bouncy_distro_type* pbouncy_distro); -void bouncy_distro_draw(bouncy_distro_type* pbouncy_distro); -void bouncy_distro_collision(bouncy_distro_type* pbouncy_distro, int c_object); - -#define BOUNCY_BRICK_MAX_OFFSET 8 -#define BOUNCY_BRICK_SPEED 0.9 - -struct broken_brick_type -{ - base_type base; - timer_type timer; - Tile* tile; -}; - -void broken_brick_init(broken_brick_type* pbroken_brick, Tile* tile, - float x, float y, float xm, float ym); -void broken_brick_action(broken_brick_type* pbroken_brick); -void broken_brick_draw(broken_brick_type* pbroken_brick); - -struct bouncy_brick_type -{ - float offset; - float offset_m; - int shape; - base_type base; -}; - -void bouncy_brick_init(bouncy_brick_type* pbouncy_brick, float x, float y); -void bouncy_brick_action(bouncy_brick_type* pbouncy_brick); -void bouncy_brick_draw(bouncy_brick_type* pbouncy_brick); - -struct floating_score_type -{ - int value; - timer_type timer; - base_type base; -}; - -void floating_score_init(floating_score_type* pfloating_score, float x, float y, int s); -void floating_score_action(floating_score_type* pfloating_score); -void floating_score_draw(floating_score_type* pfloating_score); +#include "gameobjs.h" /** Try to grab the coin at the given coordinates */ void trygrabdistro(float x, float y, int bounciness); @@ -97,20 +43,26 @@ Level* level; std::vector<bouncy_distro_type> bouncy_distros; - std::vector<broken_brick_type> broken_bricks; - std::vector<bouncy_brick_type> bouncy_bricks; - std::vector<BadGuy> bad_guys; + std::vector<broken_brick_type> broken_bricks; + std::vector<bouncy_brick_type> bouncy_bricks; std::vector<floating_score_type> floating_scores; + + std::vector<BadGuy> bad_guys; std::vector<upgrade_type> upgrades; std::vector<bullet_type> bullets; std::vector<ParticleSystem*> particle_systems; + static World* current_; public: + static World* current() { return current_; } + World(); ~World(); Level* get_level() { return level; } + void set_defaults(); + void draw(); void action(); void arrays_free(); Index: scene.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/scene.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- scene.cpp 11 Apr 2004 01:24:58 -0000 1.14 +++ scene.cpp 11 Apr 2004 11:52:29 -0000 1.15 @@ -36,22 +36,5 @@ timer_type time_left; double frame_ratio; -void set_defaults(void) -{ - // Set defaults: - scroll_x = 0; - - score_multiplier = 1; - timer_init(&super_bkgd_timer, true); - - counting_distros = false; - distro_counter = 0; - - endpos = 0; - - /* set current song/music */ - set_current_music(LEVEL_MUSIC); -} - // EOF // Index: level.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level.h,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- level.h 11 Apr 2004 01:24:58 -0000 1.23 +++ level.h 11 Apr 2004 11:52:29 -0000 1.24 @@ -107,5 +107,4 @@ void load_image(texture_type* ptexture, std::string theme, const char * file, int use_alpha); }; - #endif /*SUPERTUX_LEVEL_H*/ --- NEW FILE: gameobjs.h --- #ifndef SUPERTUX_GAMEOBJS_H #define SUPERTUX_GAMEOBJS_H #include "type.h" #include "texture.h" #include "timer.h" #include "scene.h" /* Bounciness of distros: */ #define NO_BOUNCE 0 #define BOUNCE 1 class bouncy_distro_type { public: base_type base; }; extern texture_type img_distro[4]; void bouncy_distro_init(bouncy_distro_type* pbouncy_distro, float x, float y); void bouncy_distro_action(bouncy_distro_type* pbouncy_distro); void bouncy_distro_draw(bouncy_distro_type* pbouncy_distro); void bouncy_distro_collision(bouncy_distro_type* pbouncy_distro, int c_object); #define BOUNCY_BRICK_MAX_OFFSET 8 #define BOUNCY_BRICK_SPEED 0.9 class Tile; class broken_brick_type { public: base_type base; timer_type timer; Tile* tile; }; void broken_brick_init(broken_brick_type* pbroken_brick, Tile* tile, float x, float y, float xm, float ym); void broken_brick_action(broken_brick_type* pbroken_brick); void broken_brick_draw(broken_brick_type* pbroken_brick); class bouncy_brick_type { public: float offset; float offset_m; int shape; base_type base; }; void bouncy_brick_init(bouncy_brick_type* pbouncy_brick, float x, float y); void bouncy_brick_action(bouncy_brick_type* pbouncy_brick); void bouncy_brick_draw(bouncy_brick_type* pbouncy_brick); class floating_score_type { public: int value; timer_type timer; base_type base; }; void floating_score_init(floating_score_type* pfloating_score, float x, float y, int s); void floating_score_action(floating_score_type* pfloating_score); void floating_score_draw(floating_score_type* pfloating_score); #endif /* Local Variables: */ /* mode:c++ */ /* End */ Index: scene.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/scene.h,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- scene.h 11 Apr 2004 01:24:58 -0000 1.17 +++ scene.h 11 Apr 2004 11:52:29 -0000 1.18 @@ -14,10 +14,8 @@ #define SUPERTUX_SCENE_H #include "defines.h" -#include "gameloop.h" #include "player.h" #include "badguy.h" -#include "world.h" #include "special.h" #include "level.h" #include "particlesystem.h" @@ -43,6 +41,4 @@ extern timer_type time_left; extern double frame_ratio; -void set_defaults(void); - #endif /*SUPERTUX_SCENE_H*/ Index: badguy.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.cpp,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- badguy.cpp 10 Apr 2004 22:37:13 -0000 1.22 +++ badguy.cpp 11 Apr 2004 11:52:29 -0000 1.23 @@ -16,6 +16,7 @@ #include "badguy.h" #include "scene.h" #include "screen.h" +#include "world.h" #include "tile.h" texture_type img_bsod_squished_left[1]; Index: tile.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/tile.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- tile.cpp 4 Apr 2004 00:32:10 -0000 1.10 +++ tile.cpp 11 Apr 2004 11:52:29 -0000 1.11 @@ -10,6 +10,7 @@ // // #include "tile.h" +#include "scene.h" #include "assert.h" TileManager* TileManager::instance_ = 0; @@ -134,5 +135,29 @@ } } +void +Tile::draw(float x, float y, unsigned int c, Uint8 alpha) +{ + if (c != 0) + { + Tile* ptile = TileManager::instance()->get(c); + if(ptile) + { + if(ptile->images.size() > 1) + { + texture_draw(&ptile->images[( ((global_frame_counter*25) / ptile->anim_speed) % (ptile->images.size()))],x,y, alpha); + } + else if (ptile->images.size() == 1) + { + texture_draw(&ptile->images[0],x,y, alpha); + } + else + { + //printf("Tile not dravable %u\n", c); + } + } + } +} + // EOF // Index: Makefile.am =================================================================== RCS file: /cvsroot/super-tux/supertux/src/Makefile.am,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- Makefile.am 11 Apr 2004 00:05:35 -0000 1.14 +++ Makefile.am 11 Apr 2004 11:52:29 -0000 1.15 @@ -1,7 +1,7 @@ bin_PROGRAMS = supertux supertux_SOURCES = \ -badguy.cpp badguy.h bitmask.cpp bitmask.h button.cpp button.h collision.cpp collision.h configfile.cpp configfile.h defines.h gameloop.cpp gameloop.h globals.cpp globals.h high_scores.cpp high_scores.h intro.cpp intro.h level.cpp level.h leveleditor.cpp leveleditor.h lispreader.cpp lispreader.h menu.cpp menu.h particlesystem.cpp particlesystem.h physic.cpp physic.h player.cpp player.h scene.cpp scene.h screen.cpp screen.h setup.cpp setup.h sound.cpp sound.h special.cpp special.h supertux.cpp supertux.h text.cpp text.h texture.cpp texture.h timer.cpp timer.h title.cpp title.h type.cpp type.h world.cpp world.h worldmap.cpp worldmap.h tile.h tile.cpp mousecursor.cpp mousecursor.h resources.h resources.cpp +badguy.cpp badguy.h bitmask.cpp bitmask.h button.cpp button.h collision.cpp collision.h configfile.cpp configfile.h defines.h gameloop.cpp gameloop.h globals.cpp globals.h high_scores.cpp high_scores.h intro.cpp intro.h level.cpp level.h leveleditor.cpp leveleditor.h lispreader.cpp lispreader.h menu.cpp menu.h particlesystem.cpp particlesystem.h physic.cpp physic.h player.cpp player.h scene.cpp scene.h screen.cpp screen.h setup.cpp setup.h sound.cpp sound.h special.cpp special.h supertux.cpp supertux.h text.cpp text.h texture.cpp texture.h timer.cpp timer.h title.cpp title.h type.cpp type.h world.cpp world.h worldmap.cpp worldmap.h tile.h tile.cpp mousecursor.cpp mousecursor.h resources.h resources.cpp gameobjs.h gameobjs.cpp # EOF # noinst_HEADERS = Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.53 retrieving revision 1.54 diff -u -d -r1.53 -r1.54 --- gameloop.cpp 11 Apr 2004 01:36:22 -0000 1.53 +++ gameloop.cpp 11 Apr 2004 11:52:29 -0000 1.54 @@ -102,7 +102,7 @@ /* Init the game: */ world->arrays_free(); - set_defaults(); + world->set_defaults(); strcpy(level_subset, subset.c_str()); @@ -397,7 +397,7 @@ /* Either way, (re-)load the (next) level... */ tux.level_begin(); - set_defaults(); + world->set_defaults(); world->get_level()->cleanup(); @@ -655,31 +655,6 @@ return(quit); } -/* Draw a tile on the screen: */ - -void drawshape(float x, float y, unsigned int c, Uint8 alpha) -{ - if (c != 0) - { - Tile* ptile = TileManager::instance()->get(c); - if(ptile) - { - if(ptile->images.size() > 1) - { - texture_draw(&ptile->images[( ((global_frame_counter*25) / ptile->anim_speed) % (ptile->images.size()))],x,y, alpha); - } - else if (ptile->images.size() == 1) - { - texture_draw(&ptile->images[0],x,y, alpha); - } - else - { - //printf("Tile not dravable %u\n", c); - } - } - } -} - /* Bounce a brick: */ void bumpbrick(float x, float y) { @@ -836,18 +811,18 @@ level_subset[strlen(level_subset)-1] = '\0'; fread(&level,sizeof(int),1,fi); - set_defaults(); + world->set_defaults(); world->get_level()->cleanup(); world->arrays_free(); + world->get_level()->free_gfx(); + world->get_level()->free_song(); if(world->get_level()->load(level_subset,level) != 0) exit(1); + world->activate_bad_guys(); world->activate_particle_systems(); - - world->get_level()->free_gfx(); world->get_level()->load_gfx(); - world->get_level()->free_song(); world->get_level()->load_song(); levelintro(); Index: collision.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/collision.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- collision.cpp 11 Apr 2004 00:05:35 -0000 1.12 +++ collision.cpp 11 Apr 2004 11:52:29 -0000 1.13 @@ -14,6 +14,7 @@ #include "collision.h" #include "bitmask.h" #include "scene.h" +#include "world.h" #include "tile.h" bool rectcollision(base_type* one, base_type* two) @@ -285,7 +286,7 @@ Tile* gettile(float x, float y) { - return TileManager::instance()->get(GameSession::current()->get_level()->gettileid(x, y)); + return TileManager::instance()->get(World::current()->get_level()->gettileid(x, y)); } bool issolid(float x, float y) Index: leveleditor.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/leveleditor.cpp,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- leveleditor.cpp 11 Apr 2004 01:36:22 -0000 1.34 +++ leveleditor.cpp 11 Apr 2004 11:52:29 -0000 1.35 @@ -24,12 +24,14 @@ #include <SDL_image.h> #include "leveleditor.h" +#include "world.h" #include "screen.h" #include "defines.h" #include "globals.h" #include "setup.h" #include "menu.h" #include "level.h" +#include "gameloop.h" #include "badguy.h" #include "scene.h" #include "button.h" @@ -635,7 +637,7 @@ /* draw button bar */ fillrect(screen->w - 64, 0, 64, screen->h, 50, 50, 50,255); - drawshape(19 * 32, 14 * 32, le_current_tile); + Tile::draw(19 * 32, 14 * 32, le_current_tile); if(TileManager::instance()->get(le_current_tile)->editor_images.size() > 0) texture_draw(&TileManager::instance()->get(le_current_tile)->editor_images[0], 19 * 32, 14 * 32); @@ -703,21 +705,21 @@ else a = 128; - drawshape(32*x - fmodf(pos_x, 32), y * 32, le_current_level->bg_tiles[y][x + (int)(pos_x / 32)],a); + Tile::draw(32*x - fmodf(pos_x, 32), y * 32, le_current_level->bg_tiles[y][x + (int)(pos_x / 32)],a); if(active_tm == TM_IA) a = 255; else a = 128; - drawshape(32*x - fmodf(pos_x, 32), y * 32, le_current_level->ia_tiles[y][x + (int)(pos_x / 32)],a); + Tile::draw(32*x - fmodf(pos_x, 32), y * 32, le_current_level->ia_tiles[y][x + (int)(pos_x / 32)],a); if(active_tm == TM_FG) a = 255; else a = 128; - drawshape(32*x - fmodf(pos_x, 32), y * 32, le_current_level->fg_tiles[y][x + (int)(pos_x / 32)],a); + Tile::draw(32*x - fmodf(pos_x, 32), y * 32, le_current_level->fg_tiles[y][x + (int)(pos_x / 32)],a); /* draw whats inside stuff when cursor is selecting those */ /* (draw them all the time - is this the right behaviour?) */ --- NEW FILE: gameobjs.cpp --- #include "world.h" #include "tile.h" #include "gameloop.h" #include "gameobjs.h" void bouncy_distro_init(bouncy_distro_type* pbouncy_distro, float x, float y) { pbouncy_distro->base.x = x; pbouncy_distro->base.y = y; pbouncy_distro->base.ym = -2; } void bouncy_distro_action(bouncy_distro_type* pbouncy_distro) { pbouncy_distro->base.y = pbouncy_distro->base.y + pbouncy_distro->base.ym * frame_ratio; pbouncy_distro->base.ym += 0.1 * frame_ratio; if (pbouncy_distro->base.ym >= 0) world.bouncy_distros.erase(static_cast<std::vector<bouncy_distro_type>::iterator>(pbouncy_distro)); } void bouncy_distro_draw(bouncy_distro_type* pbouncy_distro) { texture_draw(&img_distro[0], pbouncy_distro->base.x - scroll_x, pbouncy_distro->base.y); } void broken_brick_init(broken_brick_type* pbroken_brick, Tile* tile, float x, float y, float xm, float ym) { pbroken_brick->tile = tile; pbroken_brick->base.x = x; pbroken_brick->base.y = y; pbroken_brick->base.xm = xm; pbroken_brick->base.ym = ym; timer_init(&pbroken_brick->timer, true); timer_start(&pbroken_brick->timer,200); } void broken_brick_action(broken_brick_type* pbroken_brick) { pbroken_brick->base.x = pbroken_brick->base.x + pbroken_brick->base.xm * frame_ratio; pbroken_brick->base.y = pbroken_brick->base.y + pbroken_brick->base.ym * frame_ratio; if (!timer_check(&pbroken_brick->timer)) world.broken_bricks.erase(static_cast<std::vector<broken_brick_type>::iterator>(pbroken_brick)); } void broken_brick_draw(broken_brick_type* pbroken_brick) { SDL_Rect src, dest; src.x = rand() % 16; src.y = rand() % 16; src.w = 16; src.h = 16; dest.x = (int)(pbroken_brick->base.x - scroll_x); dest.y = (int)pbroken_brick->base.y; dest.w = 16; dest.h = 16; if (pbroken_brick->tile->images.size() > 0) texture_draw_part(&pbroken_brick->tile->images[0], src.x,src.y,dest.x,dest.y,dest.w,dest.h); } void bouncy_brick_init(bouncy_brick_type* pbouncy_brick, float x, float y) { pbouncy_brick->base.x = x; pbouncy_brick->base.y = y; pbouncy_brick->offset = 0; pbouncy_brick->offset_m = -BOUNCY_BRICK_SPEED; pbouncy_brick->shape = GameSession::current()->get_level()->gettileid(x, y); } void bouncy_brick_action(bouncy_brick_type* pbouncy_brick) { pbouncy_brick->offset = (pbouncy_brick->offset + pbouncy_brick->offset_m * frame_ratio); /* Go back down? */ if (pbouncy_brick->offset < -BOUNCY_BRICK_MAX_OFFSET) pbouncy_brick->offset_m = BOUNCY_BRICK_SPEED; /* Stop bouncing? */ if (pbouncy_brick->offset >= 0) world.bouncy_bricks.erase(static_cast<std::vector<bouncy_brick_type>::iterator>(pbouncy_brick)); } void bouncy_brick_draw(bouncy_brick_type* pbouncy_brick) { int s; SDL_Rect dest; if (pbouncy_brick->base.x >= scroll_x - 32 && pbouncy_brick->base.x <= scroll_x + screen->w) { dest.x = (int)(pbouncy_brick->base.x - scroll_x); dest.y = (int)pbouncy_brick->base.y; dest.w = 32; dest.h = 32; Level* plevel = GameSession::current()->get_level(); // FIXME: overdrawing hack to clean the tile from the screen to // paint it later at on offseted position if(plevel->bkgd_image[0] == '\0') { fillrect(pbouncy_brick->base.x - scroll_x, pbouncy_brick->base.y, 32,32, plevel->bkgd_red, plevel->bkgd_green, plevel->bkgd_blue, 0); } else { s = (int)scroll_x / 30; texture_draw_part(&plevel->img_bkgd, dest.x + s, dest.y, dest.x, dest.y,dest.w,dest.h); } Tile::draw(pbouncy_brick->base.x - scroll_x, pbouncy_brick->base.y + pbouncy_brick->offset, pbouncy_brick->shape); } } void floating_score_init(floating_score_type* pfloating_score, float x, float y, int s) { pfloating_score->base.x = x; pfloating_score->base.y = y - 16; timer_init(&pfloating_score->timer,true); timer_start(&pfloating_score->timer,1000); pfloating_score->value = s; } void floating_score_action(floating_score_type* pfloating_score) { pfloating_score->base.y = pfloating_score->base.y - 2 * frame_ratio; if(!timer_check(&pfloating_score->timer)) world.floating_scores.erase(static_cast<std::vector<floating_score_type>::iterator>(pfloating_score)); } void floating_score_draw(floating_score_type* pfloating_score) { char str[10]; sprintf(str, "%d", pfloating_score->value); text_draw(&gold_text, str, (int)pfloating_score->base.x + 16 - strlen(str) * 8, (int)pfloating_score->base.y, 1); } /* EOF */ Index: world.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- world.cpp 11 Apr 2004 01:36:22 -0000 1.10 +++ world.cpp 11 Apr 2004 11:52:29 -0000 1.11 @@ -23,10 +23,16 @@ texture_type img_distro[4]; +World* World::current_ = 0; + World world; World::World() { + // FIXME: Move this to action and draw and everywhere else where the + // world calls child functions + current_ = this; + level = new Level; } @@ -35,6 +41,24 @@ delete level; } +void +World::set_defaults() +{ + // Set defaults: + scroll_x = 0; + + score_multiplier = 1; + timer_init(&super_bkgd_timer, true); + + counting_distros = false; + distro_counter = 0; + + endpos = 0; + + /* set current song/music */ + set_current_music(LEVEL_MUSIC); +} + int World::load(const char* subset, int level_nr) { @@ -127,8 +151,8 @@ { for (x = 0; x < 21; ++x) { - drawshape(32*x - fmodf(scroll_x, 32), y * 32, - level->bg_tiles[(int)y][(int)x + (int)(scroll_x / 32)]); + Tile::draw(32*x - fmodf(scroll_x, 32), y * 32, + level->bg_tiles[(int)y][(int)x + (int)(scroll_x / 32)]); } } @@ -137,8 +161,8 @@ { for (x = 0; x < 21; ++x) { - drawshape(32*x - fmodf(scroll_x, 32), y * 32, - level->ia_tiles[(int)y][(int)x + (int)(scroll_x / 32)]); + Tile::draw(32*x - fmodf(scroll_x, 32), y * 32, + level->ia_tiles[(int)y][(int)x + (int)(scroll_x / 32)]); } } @@ -171,8 +195,8 @@ { for (x = 0; x < 21; ++x) { - drawshape(32*x - fmodf(scroll_x, 32), y * 32, - level->fg_tiles[(int)y][(int)x + (int)(scroll_x / 32)]); + Tile::draw(32*x - fmodf(scroll_x, 32), y * 32, + level->fg_tiles[(int)y][(int)x + (int)(scroll_x / 32)]); } } @@ -291,163 +315,10 @@ play_sound(sounds[SND_SHOOT], SOUND_CENTER_SPEAKER); } - - -void bouncy_distro_init(bouncy_distro_type* pbouncy_distro, float x, float y) -{ - pbouncy_distro->base.x = x; - pbouncy_distro->base.y = y; - pbouncy_distro->base.ym = -2; -} - -void bouncy_distro_action(bouncy_distro_type* pbouncy_distro) -{ - pbouncy_distro->base.y = pbouncy_distro->base.y + pbouncy_distro->base.ym * frame_ratio; - - pbouncy_distro->base.ym += 0.1 * frame_ratio; - - if (pbouncy_distro->base.ym >= 0) - world.bouncy_distros.erase(static_cast<std::vector<bouncy_distro_type>::iterator>(pbouncy_distro)); -} - -void bouncy_distro_draw(bouncy_distro_type* pbouncy_distro) -{ - texture_draw(&img_distro[0], - pbouncy_distro->base.x - scroll_x, - pbouncy_distro->base.y); -} - -void broken_brick_init(broken_brick_type* pbroken_brick, Tile* tile, - float x, float y, float xm, float ym) -{ - pbroken_brick->tile = tile; - pbroken_brick->base.x = x; - pbroken_brick->base.y = y; - pbroken_brick->base.xm = xm; - pbroken_brick->base.ym = ym; - - timer_init(&pbroken_brick->timer, true); - timer_start(&pbroken_brick->timer,200); -} - -void broken_brick_action(broken_brick_type* pbroken_brick) -{ - pbroken_brick->base.x = pbroken_brick->base.x + pbroken_brick->base.xm * frame_ratio; - pbroken_brick->base.y = pbroken_brick->base.y + pbroken_brick->base.ym * frame_ratio; - - if (!timer_check(&pbroken_brick->timer)) - world.broken_bricks.erase(static_cast<std::vector<broken_brick_type>::iterator>(pbroken_brick)); -} - -void broken_brick_draw(broken_brick_type* pbroken_brick) -{ - SDL_Rect src, dest; - src.x = rand() % 16; - src.y = rand() % 16; - src.w = 16; - src.h = 16; - - dest.x = (int)(pbroken_brick->base.x - scroll_x); - dest.y = (int)pbroken_brick->base.y; - dest.w = 16; - dest.h = 16; - - if (pbroken_brick->tile->images.size() > 0) - texture_draw_part(&pbroken_brick->tile->images[0], - src.x,src.y,dest.x,dest.y,dest.w,dest.h); -} - -void bouncy_brick_init(bouncy_brick_type* pbouncy_brick, float x, float y) -{ - pbouncy_brick->base.x = x; - pbouncy_brick->base.y = y; - pbouncy_brick->offset = 0; - pbouncy_brick->offset_m = -BOUNCY_BRICK_SPEED; - pbouncy_brick->shape = GameSession::current()->get_level()->gettileid(x, y); -} - -void bouncy_brick_action(bouncy_brick_type* pbouncy_brick) -{ - - pbouncy_brick->offset = (pbouncy_brick->offset + - pbouncy_brick->offset_m * frame_ratio); - - /* Go back down? */ - - if (pbouncy_brick->offset < -BOUNCY_BRICK_MAX_OFFSET) - pbouncy_brick->offset_m = BOUNCY_BRICK_SPEED; - - - /* Stop bouncing? */ - - if (pbouncy_brick->offset >= 0) - world.bouncy_bricks.erase(static_cast<std::vector<bouncy_brick_type>::iterator>(pbouncy_brick)); -} - -void bouncy_brick_draw(bouncy_brick_type* pbouncy_brick) -{ - int s; - SDL_Rect dest; - - if (pbouncy_brick->base.x >= scroll_x - 32 && - pbouncy_brick->base.x <= scroll_x + screen->w) - { - dest.x = (int)(pbouncy_brick->base.x - scroll_x); - dest.y = (int)pbouncy_brick->base.y; - dest.w = 32; - dest.h = 32; - - Level* plevel = GameSession::current()->get_level(); - - // FIXME: overdrawing hack to clean the tile from the screen to - // paint it later at on offseted position - if(plevel->bkgd_image[0] == '\0') - { - fillrect(pbouncy_brick->base.x - scroll_x, pbouncy_brick->base.y, - 32,32, - plevel->bkgd_red, plevel->bkgd_green, plevel->bkgd_blue, 0); - } - else - { - s = (int)scroll_x / 30; - texture_draw_part(&plevel->img_bkgd, dest.x + s, dest.y, - dest.x, dest.y,dest.w,dest.h); - } - - drawshape(pbouncy_brick->base.x - scroll_x, - pbouncy_brick->base.y + pbouncy_brick->offset, - pbouncy_brick->shape); - } -} - -void floating_score_init(floating_score_type* pfloating_score, float x, float y, int s) -{ - pfloating_score->base.x = x; - pfloating_score->base.y = y - 16; - timer_init(&pfloating_score->timer,true); - timer_start(&pfloating_score->timer,1000); - pfloating_score->value = s; -} - -void floating_score_action(floating_score_type* pfloating_score) -{ - pfloating_score->base.y = pfloating_score->base.y - 2 * frame_ratio; - - if(!timer_check(&pfloating_score->timer)) - world.floating_scores.erase(static_cast<std::vector<floating_score_type>::iterator>(pfloating_score)); -} - -void floating_score_draw(floating_score_type* pfloating_score) -{ - char str[10]; - sprintf(str, "%d", pfloating_score->value); - text_draw(&gold_text, str, (int)pfloating_score->base.x + 16 - strlen(str) * 8, (int)pfloating_score->base.y, 1); -} - /* Break a brick: */ void trybreakbrick(float x, float y, bool small) { - Level* plevel = GameSession::current()->get_level(); + Level* plevel = World::current()->get_level(); Tile* tile = gettile(x, y); if (tile->brick) @@ -491,7 +362,7 @@ /* Empty a box: */ void tryemptybox(float x, float y, int col_side) { - Level* plevel = GameSession::current()->get_level(); + Level* plevel = World::current()->get_level(); Tile* tile = gettile(x,y); if (!tile->fullbox) @@ -534,7 +405,7 @@ /* Try to grab a distro: */ void trygrabdistro(float x, float y, int bounciness) { - Level* plevel = GameSession::current()->get_level(); + Level* plevel = World::current()->get_level(); Tile* tile = gettile(x, y); if (tile && tile->distro) { Index: title.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/title.cpp,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- title.cpp 11 Apr 2004 01:24:58 -0000 1.28 +++ title.cpp 11 Apr 2004 11:52:29 -0000 1.29 @@ -38,6 +38,7 @@ #include "scene.h" #include "player.h" #include "math.h" +#include "tile.h" void loadshared(void); @@ -86,8 +87,8 @@ { for (int x = 0; x < 21; ++x) { - drawshape(32*x - fmodf(scroll_x, 32), y * 32, - plevel->ia_tiles[(int)y][(int)x + (int)(scroll_x / 32)]); + Tile::draw(32*x - fmodf(scroll_x, 32), y * 32, + plevel->ia_tiles[(int)y][(int)x + (int)(scroll_x / 32)]); } } Index: resources.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/resources.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- resources.cpp 11 Apr 2004 00:10:53 -0000 1.1 +++ resources.cpp 11 Apr 2004 11:52:29 -0000 1.2 @@ -2,6 +2,7 @@ #include "scene.h" #include "player.h" #include "badguy.h" +#include "gameobjs.h" #include "resources.h" texture_type img_waves[3]; @@ -251,7 +252,6 @@ /* Distros: */ - texture_load(&img_distro[0], datadir + "/images/shared/distro-0.png", USE_ALPHA); |
From: Ingo R. <gr...@us...> - 2004-04-11 02:06:24
|
Update of /cvsroot/super-tux/supertux/data/levels/default In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1984/default Modified Files: snow1-grumbel.stl worldmap.stwm Log Message: - fixed worldmap a bit Index: snow1-grumbel.stl =================================================================== RCS file: /cvsroot/super-tux/supertux/data/levels/default/snow1-grumbel.stl,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- snow1-grumbel.stl 26 Mar 2004 12:52:30 -0000 1.2 +++ snow1-grumbel.stl 11 Apr 2004 01:52:49 -0000 1.3 @@ -1,4 +1,4 @@ -;; Generated by Windstille Editor +;; Generated by Flexlay Editor (supertux-level (version 1) (name "Hello World") @@ -68,63 +68,64 @@ ) (objects - (mriceblock (x 1138) (y 405)) - (mrbomb (x 1024) (y 400)) - (mriceblock (x 1714) (y 352)) - (mriceblock (x 2021) (y 416)) - (mriceblock (x 2770) (y 252)) - (mriceblock (x 2720) (y 251)) - (mriceblock (x 2665) (y 252)) - (mriceblock (x 3450) (y 313)) - (mriceblock (x 3525) (y 311)) - (mriceblock (x 3934) (y 250)) - (mriceblock (x 4007) (y 249)) - (mriceblock (x 4556) (y 406)) - (mriceblock (x 4627) (y 406)) - (mriceblock (x 4489) (y 408)) - (money (x 2089) (y 294)) + (laptop (x 1148) (y 351)) + (mrbomb (x 1008) (y 346)) + (laptop (x 1678) (y 293)) + (laptop (x 1976) (y 335)) + (laptop (x 2770) (y 252)) + (laptop (x 2720) (y 251)) + (laptop (x 2665) (y 252)) + (laptop (x 3450) (y 313)) + (laptop (x 3525) (y 311)) + (laptop (x 3934) (y 250)) + (laptop (x 4007) (y 249)) + (laptop (x 4556) (y 406)) + (laptop (x 4627) (y 406)) + (laptop (x 4489) (y 408)) + (money (x 2112) (y 296)) (money (x 4320) (y 264)) (money (x 4739) (y 264)) - (mriceblock (x 5327) (y 207)) - (mriceblock (x 5380) (y 207)) - (mriceblock (x 5277) (y 207)) - (mriceblock (x 5908) (y 159)) - (mriceblock (x 5978) (y 158)) + (laptop (x 5327) (y 207)) + (laptop (x 5380) (y 207)) + (laptop (x 5277) (y 207)) + (laptop (x 5908) (y 159)) + (laptop (x 5978) (y 158)) (mrbomb (x 5759) (y 407)) - (mriceblock (x 5878) (y 408)) - (mriceblock (x 5963) (y 405)) + (laptop (x 5878) (y 408)) + (laptop (x 5963) (y 405)) (money (x 7356) (y 303)) (money (x 7228) (y 371)) (money (x 7098) (y 351)) - (mriceblock (x 7943) (y 403)) - (mriceblock (x 8014) (y 402)) - (mriceblock (x 8089) (y 397)) + (laptop (x 7943) (y 403)) + (laptop (x 8014) (y 402)) + (laptop (x 8089) (y 397)) (money (x 8800) (y 317)) - (mriceblock (x 9422) (y 339)) - (mriceblock (x 9595) (y 217)) - (mriceblock (x 9665) (y 216)) + (laptop (x 9422) (y 339)) + (laptop (x 9595) (y 217)) + (laptop (x 9665) (y 216)) (money (x 9979) (y 434)) (money (x 10225) (y 432)) - (mriceblock (x 10113) (y 159)) - (mriceblock (x 11129) (y 372)) - (mriceblock (x 11181) (y 370)) - (mriceblock (x 11236) (y 372)) + (laptop (x 10113) (y 159)) + (laptop (x 11129) (y 372)) + (laptop (x 11181) (y 370)) + (laptop (x 11236) (y 372)) (money (x 10798) (y 403)) - (mriceblock (x 11783) (y 215)) - (mriceblock (x 11833) (y 215)) - (mriceblock (x 11883) (y 216)) - (mriceblock (x 12734) (y 246)) - (mriceblock (x 12796) (y 246)) - (mriceblock (x 12676) (y 247)) + (laptop (x 11783) (y 215)) + (laptop (x 11833) (y 215)) + (laptop (x 11883) (y 216)) + (laptop (x 12734) (y 246)) + (laptop (x 12796) (y 246)) + (laptop (x 12676) (y 247)) (money (x 13231) (y 312)) - (mriceblock (x 13726) (y 216)) - (mriceblock (x 13792) (y 216)) + (laptop (x 13726) (y 216)) + (laptop (x 13792) (y 216)) (money (x 14221) (y 229)) (money (x 14033) (y 228)) - (mriceblock (x 14664) (y 213)) - (mriceblock (x 14732) (y 212)) + (laptop (x 14664) (y 213)) + (laptop (x 14732) (y 212)) (money (x 14990) (y 253)) (money (x 15090) (y 253)) + (money (x 816) (y 270)) ) ) Index: worldmap.stwm =================================================================== RCS file: /cvsroot/super-tux/supertux/data/levels/default/worldmap.stwm,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- worldmap.stwm 10 Apr 2004 15:40:31 -0000 1.4 +++ worldmap.stwm 11 Apr 2004 01:52:49 -0000 1.5 @@ -1,39 +1,42 @@ +;; Generated with Windstille Editor (supertux-worldmap - (tilemap (width 20) - (height 15) - (data 5 1 1 6 1 4 1 1 6 1 1 4 1 1 3 8 8 8 8 8 - 8 8 8 8 8 2 8 8 8 8 8 2 8 8 2 8 8 8 8 8 - 8 8 8 8 8 2 8 8 8 8 8 7 8 8 2 8 8 8 8 8 - 8 8 8 8 8 7 8 8 8 8 8 7 8 8 2 8 8 8 8 8 - 8 8 8 8 8 2 8 8 8 8 8 2 8 8 2 8 8 8 8 8 - 8 8 8 8 8 2 8 4 1 6 1 4 1 1 4 1 1 1 4 8 - 8 8 8 8 8 7 8 2 8 8 8 8 8 8 2 8 8 8 8 8 - 8 8 8 8 8 2 8 2 8 8 8 8 8 8 2 8 8 8 8 8 - 8 8 8 8 8 4 1 4 6 1 1 6 1 1 4 8 8 8 8 8 - 8 8 8 8 8 7 8 8 8 8 8 8 8 8 7 8 8 8 8 8 - 8 8 8 8 8 2 8 8 8 8 8 8 8 8 2 8 8 8 8 8 - 8 8 8 8 8 2 8 8 8 8 8 8 8 8 2 8 8 8 8 8 - 8 8 8 8 8 4 1 1 6 1 1 6 1 1 4 8 8 8 8 8 - 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 - 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 - )) - (levels + (tilemap + (width 20) + (height 15) + (data + 9 9 9 9 9 11 16 12 11 16 16 16 16 12 9 9 9 9 9 9 + 9 9 11 16 16 22 19 17 15 48 40 40 39 23 16 12 9 9 9 9 + 9 9 15 20 18 18 18 13 15 47 19 19 37 40 39 23 16 12 9 9 + 9 11 22 17 11 16 16 16 22 47 48 40 40 40 44 39 19 23 16 12 + 9 15 19 23 22 48 40 40 40 44 46 48 39 19 19 47 19 19 19 17 + 9 15 48 39 19 41 40 40 40 40 42 47 47 19 19 47 19 20 18 13 + 9 15 37 45 40 45 40 40 40 40 43 42 37 40 40 42 19 17 9 9 + 9 15 19 47 19 47 19 19 48 40 42 19 24 25 25 25 26 17 9 9 + 9 14 21 37 40 46 19 48 42 19 24 25 33 32 35 29 28 17 9 9 + 9 9 15 19 19 37 40 42 24 25 33 35 29 29 28 20 18 13 9 9 + 9 9 15 19 19 24 25 25 33 32 35 28 20 18 18 13 9 9 9 9 + 9 9 14 21 19 31 32 32 32 35 28 20 13 9 9 11 16 12 9 9 + 9 9 9 14 21 30 29 29 29 28 20 13 9 11 16 22 20 13 9 9 + 9 9 9 9 14 18 18 18 18 18 13 9 9 14 18 18 13 9 9 9 + 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 + )) + (levels (level (name "level1.stl") (x 3) (y 0)) (level (name "level2.stl") (x 5) (y 3)) (level (name "level3.stl") (x 8) (y 0)) (level (name "level4.stl") (x 7) (y 5)) - (level (name "snow1.stl") (x 0) (y 0)) - (level (name "snow2.stl") (x 5) (y 0)) - (level (name "cave1.stl") (x 5) (y 6)) - (level (name "cave2.stl") (x 5) (y 8)) - (level (name "snow3.stl") (x 5) (y 12)) - (level (name "cave3.stl") (x 8) (y 12)) - (level (name "cave4.stl") (x 11) (y 12)) - (level (name "snow4.stl") (x 14) (y 12)) - (level (name "cave5.stl") (x 14) (y 9)) - (level (name "snow5.stl") (x 14) (y 5)) - (level (name "cave6.stl") (x 11) (y 0)) - (level (name "snow6.stl") (x 14) (y 9)) - )) + (level (name "snow1-grumbel.stl") (x 0) (y 0)) + (level (name "snow2-grumbel.stl") (x 5) (y 0)) + (level (name "cave1-grumbel.stl") (x 5) (y 6)) + (level (name "cave2-grumbel.stl") (x 5) (y 8)) + (level (name "snow3-grumbel.stl") (x 5) (y 12)) + (level (name "cave3-grumbel.stl") (x 8) (y 12)) + (level (name "cave4-grumbel.stl") (x 11) (y 12)) + (level (name "snow4-grumbel.stl") (x 14) (y 12)) + (level (name "cave5-grumbel.stl") (x 14) (y 9)) + (level (name "snow5-grumbel.stl") (x 14) (y 5)) + (level (name "cave6-grumbel.stl") (x 11) (y 0)) + (level (name "snow6-grumbel.stl") (x 14) (y 9))) + + ) -;; EOF ;; \ No newline at end of file |
From: Ingo R. <gr...@us...> - 2004-04-11 02:06:23
|
Update of /cvsroot/super-tux/supertux/data/levels/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1984/test Modified Files: enemytest.stl Log Message: - fixed worldmap a bit Index: enemytest.stl =================================================================== RCS file: /cvsroot/super-tux/supertux/data/levels/test/enemytest.stl,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- enemytest.stl 10 Apr 2004 12:44:16 -0000 1.1 +++ enemytest.stl 11 Apr 2004 01:52:49 -0000 1.2 @@ -68,7 +68,7 @@ ) (objects - (fish (x 509) (y 281)) + (fish (x 509) (y 181)) (flyingsnowball (x 941) (y 222)) (spiky (x 656) (y 306)) (snowball (x 259) (y 303)) |
From: Ingo R. <gr...@us...> - 2004-04-11 02:05:16
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1831 Modified Files: worldmap.cpp worldmap.h Log Message: - fixed worldmap a bit Index: worldmap.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- worldmap.cpp 10 Apr 2004 20:26:13 -0000 1.20 +++ worldmap.cpp 11 Apr 2004 01:51:42 -0000 1.21 @@ -201,6 +201,8 @@ height = 15; texture_load(&level_sprite, datadir + "/images/worldmap/levelmarker.png", USE_ALPHA); + texture_load(&leveldot_green, datadir + "/images/worldmap/leveldot_green.png", USE_ALPHA); + texture_load(&leveldot_red, datadir + "/images/worldmap/leveldot_red.png", USE_ALPHA); input_direction = NONE; enter_level = false; @@ -456,7 +458,7 @@ for(Levels::iterator i = levels.begin(); i != levels.end(); ++i) { - texture_draw(&level_sprite, i->x*32, i->y*32); + texture_draw(&leveldot_green, i->x*32, i->y*32); } tux->draw(); Index: worldmap.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.h,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- worldmap.h 22 Mar 2004 14:34:05 -0000 1.10 +++ worldmap.h 11 Apr 2004 01:51:42 -0000 1.11 @@ -114,6 +114,9 @@ Tux* tux; texture_type level_sprite; + texture_type leveldot_green; + texture_type leveldot_red; + bool quit; std::string name; |
From: Ingo R. <gr...@us...> - 2004-04-11 01:49:56
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31878 Modified Files: gameloop.cpp gameloop.h leveleditor.cpp world.cpp world.h Log Message: - moved some activate_bad_guy stuff into the world, where it belongs Index: gameloop.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.h,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- gameloop.h 11 Apr 2004 01:24:58 -0000 1.31 +++ gameloop.h 11 Apr 2004 01:36:22 -0000 1.32 @@ -63,8 +63,6 @@ void start_timers(); }; -void activate_bad_guys(Level* plevel); - std::string slotinfo(int slot); bool rectcollision(base_type* one, base_type* two); Index: world.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.h,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- world.h 11 Apr 2004 00:05:35 -0000 1.11 +++ world.h 11 Apr 2004 01:36:22 -0000 1.12 @@ -124,6 +124,7 @@ int load(const std::string& filename); void activate_particle_systems(); + void activate_bad_guys(); void add_score(float x, float y, int s); void add_bouncy_distro(float x, float y); Index: world.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- world.cpp 11 Apr 2004 01:24:58 -0000 1.9 +++ world.cpp 11 Apr 2004 01:36:22 -0000 1.10 @@ -64,6 +64,16 @@ particle_systems.clear(); } +void +World::activate_bad_guys() +{ + for (std::vector<BadGuyData>::iterator i = level->badguy_data.begin(); + i != level->badguy_data.end(); + ++i) + { + add_bad_guy(i->x, i->y, i->kind); + } +} void World::activate_particle_systems() Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.52 retrieving revision 1.53 diff -u -d -r1.52 -r1.53 --- gameloop.cpp 11 Apr 2004 01:24:58 -0000 1.52 +++ gameloop.cpp 11 Apr 2004 01:36:22 -0000 1.53 @@ -119,7 +119,8 @@ world->get_level()->load_gfx(); loadshared(); - activate_bad_guys(world->get_level()); + + world->activate_bad_guys(); world->activate_particle_systems(); world->get_level()->load_song(); @@ -169,16 +170,6 @@ update_time = st_get_ticks(); } -void activate_bad_guys(Level* plevel) -{ - for (std::vector<BadGuyData>::iterator i = plevel->badguy_data.begin(); - i != plevel->badguy_data.end(); - ++i) - { - world.add_bad_guy(i->x, i->y, i->kind); - } -} - void GameSession::process_events() { @@ -370,8 +361,9 @@ world->get_level()->free_gfx(); world->get_level()->cleanup(); world->get_level()->free_song(); - unloadshared(); world->arrays_free(); + + unloadshared(); return(0); } tux.level_begin(); @@ -392,19 +384,21 @@ if (score > hs_score) save_hs(score); } + world->get_level()->free_gfx(); world->get_level()->cleanup(); world->get_level()->free_song(); - unloadshared(); world->arrays_free(); + + unloadshared(); return(0); } /* if (lives < 0) */ } /* Either way, (re-)load the (next) level... */ - tux.level_begin(); set_defaults(); + world->get_level()->cleanup(); if (st_gl_mode == ST_GL_LOAD_LEVEL_FILE) @@ -419,7 +413,7 @@ } world->arrays_free(); - activate_bad_guys(world->get_level()); + world->activate_bad_guys(); world->activate_particle_systems(); world->get_level()->free_gfx(); @@ -844,10 +838,11 @@ set_defaults(); world->get_level()->cleanup(); + world->arrays_free(); + if(world->get_level()->load(level_subset,level) != 0) exit(1); - world->arrays_free(); - activate_bad_guys(world->get_level()); + world->activate_bad_guys(); world->activate_particle_systems(); world->get_level()->free_gfx(); Index: leveleditor.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/leveleditor.cpp,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- leveleditor.cpp 11 Apr 2004 01:24:58 -0000 1.33 +++ leveleditor.cpp 11 Apr 2004 01:36:22 -0000 1.34 @@ -252,7 +252,7 @@ } le_set_defaults(); le_current_level->load_gfx(); - activate_bad_guys(le_current_level); + world.activate_bad_guys(); show_menu = true; } break; @@ -283,7 +283,7 @@ } le_set_defaults(); le_current_level->load_gfx(); - activate_bad_guys(le_current_level); + world.activate_bad_guys(); menu_item_change_input(&subset_new_menu->item[2],""); show_menu = true; break; @@ -559,7 +559,7 @@ le_current_level->free_gfx(); le_current_level->load_gfx(); - activate_bad_guys(le_current_level); + world.activate_bad_guys(); } void le_quit(void) @@ -595,8 +595,8 @@ { le_current_level->free_gfx(); le_current_level->cleanup(); - unloadshared(); world.arrays_free(); + unloadshared(); } } @@ -1196,7 +1196,7 @@ world.arrays_free(); le_current_level->load_gfx(); loadshared(); - activate_bad_guys(le_current_level); + world.activate_bad_guys(); } void le_showhelp() |
From: Ingo R. <gr...@us...> - 2004-04-11 01:38:34
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30134 Modified Files: gameloop.cpp gameloop.h level.cpp level.h leveleditor.cpp scene.cpp scene.h supertux.cpp title.cpp title.h world.cpp Log Message: - moved some more level_ stuff into the levelclass - removed a quit, since it did the same as a done Index: scene.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/scene.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- scene.cpp 10 Apr 2004 22:37:13 -0000 1.13 +++ scene.cpp 11 Apr 2004 01:24:58 -0000 1.14 @@ -18,7 +18,6 @@ int level; int next_level; int game_pause; -bool quit; int score_multiplier; int endpos; bool counting_distros; Index: scene.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/scene.h,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- scene.h 10 Apr 2004 22:37:13 -0000 1.16 +++ scene.h 11 Apr 2004 01:24:58 -0000 1.17 @@ -29,7 +29,6 @@ extern int level; extern int next_level; extern int game_pause; -extern bool quit; extern int score_multiplier; extern int endpos; extern bool counting_distros; Index: level.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level.h,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- level.h 11 Apr 2004 00:24:22 -0000 1.22 +++ level.h 11 Apr 2004 01:24:58 -0000 1.23 @@ -50,11 +50,11 @@ TM_FG }; -extern texture_type img_bkgd; - class Level { public: + texture_type img_bkgd; + std::string name; std::string theme; std::string song_title; @@ -87,7 +87,9 @@ int load(const std::string& filename); void load_gfx(); + void load_song(); + void free_song(); void save(const char* subset, int level); @@ -99,10 +101,11 @@ /** Return the id of the tile at position x/y */ unsigned int gettileid(float x, float y); + + void free_gfx(); + + void load_image(texture_type* ptexture, std::string theme, const char * file, int use_alpha); }; -void level_load_image(texture_type* ptexture, std::string theme, const char * file, int use_alpha); -void level_free_song(); -void level_free_gfx(); #endif /*SUPERTUX_LEVEL_H*/ Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.51 retrieving revision 1.52 diff -u -d -r1.51 -r1.52 --- gameloop.cpp 11 Apr 2004 00:05:35 -0000 1.51 +++ gameloop.cpp 11 Apr 2004 01:24:58 -0000 1.52 @@ -191,7 +191,7 @@ switch(event.type) { case SDL_QUIT: /* Quit event - quit: */ - quit = 1; + quit = true; break; case SDL_KEYDOWN: /* A keypress! */ key = event.key.keysym.sym; @@ -205,7 +205,7 @@ if(!game_pause) { if(st_gl_mode == ST_GL_TEST) - quit = 1; + quit = true; else if(show_menu) { Menu::set_current(game_menu); @@ -367,9 +367,9 @@ } else { - level_free_gfx(); + world->get_level()->free_gfx(); world->get_level()->cleanup(); - level_free_song(); + world->get_level()->free_song(); unloadshared(); world->arrays_free(); return(0); @@ -392,9 +392,9 @@ if (score > hs_score) save_hs(score); } - level_free_gfx(); + world->get_level()->free_gfx(); world->get_level()->cleanup(); - level_free_song(); + world->get_level()->free_song(); unloadshared(); world->arrays_free(); return(0); @@ -421,10 +421,12 @@ world->arrays_free(); activate_bad_guys(world->get_level()); world->activate_particle_systems(); - level_free_gfx(); + + world->get_level()->free_gfx(); world->get_level()->load_gfx(); - level_free_song(); + world->get_level()->free_song(); world->get_level()->load_song(); + if(st_gl_mode != ST_GL_TEST) levelintro(); start_timers(); @@ -452,10 +454,7 @@ void GameSession::draw() { - - world->draw(); - drawstatus(); if(game_pause) @@ -470,12 +469,11 @@ } if(show_menu) - { - menu_process_current(); - mouse_cursor->draw(); - } + { + menu_process_current(); + mouse_cursor->draw(); + } - /* (Update it all!) */ updatescreen(); } @@ -486,13 +484,8 @@ current_ = this; int fps_cnt; - bool jump; bool done; - /* --- MAIN GAME LOOP!!! --- */ - jump = false; - done = false; - quit = 0; global_frame_counter = 0; game_pause = 0; timer_init(&fps_timer,true); @@ -511,10 +504,11 @@ {} draw(); - do - { - jump = false; + done = false; + quit = false; + while (!done && !quit) + { /* Calculate the movement-factor */ 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. */ @@ -617,17 +611,14 @@ /* Pause till next frame, if the machine running the game is too fast: */ /* FIXME: Works great for in OpenGl mode, where the CPU doesn't have to do that much. But the results in SDL mode aren't perfect (thought the 100 FPS are reached), even on an AMD2500+. */ - if(last_update_time >= update_time - 12 && !jump) { + if(last_update_time >= update_time - 12) { SDL_Delay(10); update_time = st_get_ticks(); } /*if((update_time - last_update_time) < 10) SDL_Delay((11 - (update_time - last_update_time))/2);*/ - - /* Handle time: */ - if (timer_check(&time_left)) { /* are we low on time ? */ @@ -642,7 +633,6 @@ else tux.kill(KILL); - /* Calculate frames per second */ if(show_fps) { @@ -655,15 +645,14 @@ fps_cnt = 0; } } - } - while (!done && !quit); halt_music(); - level_free_gfx(); + world->get_level()->free_gfx(); world->get_level()->cleanup(); - level_free_song(); + world->get_level()->free_song(); + unloadshared(); world->arrays_free(); @@ -860,10 +849,12 @@ world->arrays_free(); activate_bad_guys(world->get_level()); world->activate_particle_systems(); - level_free_gfx(); + + world->get_level()->free_gfx(); world->get_level()->load_gfx(); - level_free_song(); + world->get_level()->free_song(); world->get_level()->load_song(); + levelintro(); update_time = st_get_ticks(); Index: supertux.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/supertux.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- supertux.cpp 10 Apr 2004 20:26:13 -0000 1.6 +++ supertux.cpp 11 Apr 2004 01:24:58 -0000 1.7 @@ -17,7 +17,7 @@ int main(int argc, char * argv[]) { - int done; + bool done; st_directory_setup(); parseargs(argc, argv); @@ -39,8 +39,7 @@ } else { - done = 0; - + done = false; while (!done) { done = title(); @@ -52,5 +51,5 @@ st_shutdown(); - return(0); + return 0; } Index: title.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/title.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- title.h 15 Mar 2004 17:45:29 -0000 1.2 +++ title.h 11 Apr 2004 01:24:58 -0000 1.3 @@ -10,4 +10,4 @@ April 11, 2000 - March 15, 2004 */ -int title(void); +bool title(void); Index: gameloop.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.h,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- gameloop.h 11 Apr 2004 00:05:35 -0000 1.30 +++ gameloop.h 11 Apr 2004 01:24:58 -0000 1.31 @@ -35,6 +35,7 @@ class GameSession { private: + bool quit; timer_type fps_timer, frame_timer; World* world; Index: level.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level.cpp,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- level.cpp 11 Apr 2004 00:24:22 -0000 1.28 +++ level.cpp 11 Apr 2004 01:24:58 -0000 1.29 @@ -26,8 +26,6 @@ using namespace std; -texture_type img_bkgd; - st_subset::st_subset() { levels = 0; @@ -539,30 +537,9 @@ badguy_data.clear(); } -/* Load graphics: */ - void Level::load_gfx() { - /* - level_load_image(&img_brick[0],theme,"brick0.png", IGNORE_ALPHA); - level_load_image(&img_brick[1],theme,"brick1.png", IGNORE_ALPHA); - - level_load_image(&img_solid[0],theme,"solid0.png", USE_ALPHA); - level_load_image(&img_solid[1],theme,"solid1.png", USE_ALPHA); - level_load_image(&img_solid[2],theme,"solid2.png", USE_ALPHA); - level_load_image(&img_solid[3],theme,"solid3.png", USE_ALPHA); - - level_load_image(&img_bkgd_tile[0][0],theme,"bkgd-00.png", USE_ALPHA); - level_load_image(&img_bkgd_tile[0][1],theme,"bkgd-01.png", USE_ALPHA); - level_load_image(&img_bkgd_tile[0][2],theme,"bkgd-02.png", USE_ALPHA); - level_load_image(&img_bkgd_tile[0][3],theme,"bkgd-03.png", USE_ALPHA); - - level_load_image(&img_bkgd_tile[1][0],theme,"bkgd-10.png", USE_ALPHA); - level_load_image(&img_bkgd_tile[1][1],theme,"bkgd-11.png", USE_ALPHA); - level_load_image(&img_bkgd_tile[1][2],theme,"bkgd-12.png", USE_ALPHA); - level_load_image(&img_bkgd_tile[1][3],theme,"bkgd-13.png", USE_ALPHA); - */ if(!bkgd_image.empty()) { char fname[1024]; @@ -573,20 +550,20 @@ } else { - /* Quick hack to make sure an image is loaded, when we are freeing it afterwards. */# - level_load_image(&img_bkgd, theme,"solid0.png", IGNORE_ALPHA); + /* Quick hack to make sure an image is loaded, when we are freeing it afterwards. */ + load_image(&img_bkgd, theme,"solid0.png", IGNORE_ALPHA); } } -/* Free graphics data for this level: */ -void level_free_gfx(void) +void +Level::free_gfx() { texture_free(&img_bkgd); } /* Load a level-specific graphic... */ - -void level_load_image(texture_type* ptexture, string theme,const char * file, int use_alpha) +void +Level::load_image(texture_type* ptexture, string theme,const char * file, int use_alpha) { char fname[1024]; @@ -647,16 +624,13 @@ } } -/* Free music data for this level: */ - -void level_free_song(void) +void +Level::free_song(void) { free_music(level_song); free_music(level_song_fast); } -/* Load music: */ - void Level::load_song() { @@ -669,7 +643,8 @@ strlen(song_title.c_str()) + 8 + 5); song_subtitle = strdup(song_title.c_str()); strcpy(strstr(song_subtitle, "."), "\0"); - sprintf(song_path, "%s/music/%s-fast%s", datadir.c_str(), song_subtitle, strstr(song_title.c_str(), ".")); + sprintf(song_path, "%s/music/%s-fast%s", datadir.c_str(), + song_subtitle, strstr(song_title.c_str(), ".")); level_song_fast = ::load_song(song_path); free(song_subtitle); free(song_path); Index: world.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- world.cpp 11 Apr 2004 00:05:35 -0000 1.8 +++ world.cpp 11 Apr 2004 01:24:58 -0000 1.9 @@ -18,6 +18,7 @@ #include "screen.h" #include "defines.h" #include "world.h" +#include "level.h" #include "tile.h" texture_type img_distro[4]; @@ -95,8 +96,8 @@ if(get_level()->bkgd_image[0] != '\0') { int s = (int)scroll_x / 30; - texture_draw_part(&img_bkgd,s,0,0,0,img_bkgd.w - s, img_bkgd.h); - texture_draw_part(&img_bkgd,0,0,screen->w - s ,0,s,img_bkgd.h); + texture_draw_part(&level->img_bkgd, s, 0,0,0,level->img_bkgd.w - s, level->img_bkgd.h); + texture_draw_part(&level->img_bkgd, 0, 0,screen->w - s ,0,s,level->img_bkgd.h); } else { @@ -399,7 +400,8 @@ else { s = (int)scroll_x / 30; - texture_draw_part(&img_bkgd,dest.x + s,dest.y,dest.x,dest.y,dest.w,dest.h); + texture_draw_part(&plevel->img_bkgd, dest.x + s, dest.y, + dest.x, dest.y,dest.w,dest.h); } drawshape(pbouncy_brick->base.x - scroll_x, Index: title.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/title.cpp,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- title.cpp 10 Apr 2004 22:01:27 -0000 1.27 +++ title.cpp 11 Apr 2004 01:24:58 -0000 1.28 @@ -129,9 +129,8 @@ /* --- TITLE SCREEN --- */ -int title(void) +bool title(void) { - int done; string_list_type level_subsets; st_subset subset; level_subsets = dsubdirs("/levels", "info"); @@ -162,9 +161,7 @@ texture_load(&img_choose_subset,datadir + "/images/status/choose-level-subset.png", USE_ALPHA); /* --- Main title loop: --- */ - - done = 0; - quit = 0; + bool done = 0; show_menu = 1; frame = 0; @@ -175,9 +172,8 @@ update_time = st_get_ticks(); timer_start(&random_timer, rand() % 2000 + 2000); - while (!done && !quit) + while (!done) { - /* Calculate the movement-factor */ 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. */ @@ -192,13 +188,11 @@ menu_event(event); if (event.type == SDL_QUIT) { - /* Quit event - quit: */ - quit = 1; + done = true; } else if (event.type == SDL_KEYDOWN) { /* Keypress... */ - key = event.key.keysym.sym; /* Check for menu events */ @@ -207,8 +201,7 @@ if (key == SDLK_ESCAPE) { /* Escape: Quit: */ - - quit = 1; + done = true; } } } @@ -237,7 +230,7 @@ */ /* Don't draw menu, if quit is true */ - if(show_menu && !quit) + if(show_menu && !done) menu_process_current(); if(current_menu == main_menu) @@ -276,8 +269,7 @@ switch(event.type) { case SDL_QUIT: - done = 1; - quit = 1; + done = true; break; case SDL_KEYDOWN: // key pressed // Keypress... @@ -333,13 +325,13 @@ break; case 3: done = 1; - quit = leveleditor(1); + done = leveleditor(1); break; case 4: display_credits(); break; case 5: - quit = 1; + done = true; break; } } @@ -382,8 +374,7 @@ string_list_free(&level_subsets); /* Return to main! */ - - return(quit); + return done; } #define MAX_VEL 10 Index: leveleditor.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/leveleditor.cpp,v retrieving revision 1.32 retrieving revision 1.33 diff -u -d -r1.32 -r1.33 --- leveleditor.cpp 10 Apr 2004 22:37:13 -0000 1.32 +++ leveleditor.cpp 11 Apr 2004 01:24:58 -0000 1.33 @@ -519,7 +519,7 @@ if(i) { - level_free_gfx(); + le_current_level->free_gfx(); le_current_level->load_gfx(); } @@ -556,9 +556,9 @@ le_set_defaults(); - - level_free_gfx(); + le_current_level->free_gfx(); le_current_level->load_gfx(); + activate_bad_guys(le_current_level); } @@ -593,7 +593,7 @@ if(le_current_level != NULL) { - level_free_gfx(); + le_current_level->free_gfx(); le_current_level->cleanup(); unloadshared(); world.arrays_free(); @@ -682,8 +682,10 @@ if(le_current_level->bkgd_image[0] != '\0') { s = pos_x / 30; - texture_draw_part(&img_bkgd,s,0,0,0,img_bkgd.w - s - 32, img_bkgd.h); - texture_draw_part(&img_bkgd,0,0,screen->w - s - 32 ,0,s,img_bkgd.h); + texture_draw_part(&le_current_level->img_bkgd,s,0,0,0, + le_current_level->img_bkgd.w - s - 32, le_current_level->img_bkgd.h); + texture_draw_part(&le_current_level->img_bkgd,0,0,screen->w - s - 32 ,0,s, + le_current_level->img_bkgd.h); } else { |
From: Ingo R. <gr...@us...> - 2004-04-11 00:37:56
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20248 Modified Files: level.cpp level.h Log Message: - removed obsolete hardcoded tiles Index: level.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level.cpp,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- level.cpp 11 Apr 2004 00:05:35 -0000 1.27 +++ level.cpp 11 Apr 2004 00:24:22 -0000 1.28 @@ -26,7 +26,7 @@ using namespace std; -texture_type img_bkgd, img_bkgd_tile[2][4], img_solid[4], img_brick[2]; +texture_type img_bkgd; st_subset::st_subset() { @@ -544,6 +544,7 @@ void Level::load_gfx() { + /* level_load_image(&img_brick[0],theme,"brick0.png", IGNORE_ALPHA); level_load_image(&img_brick[1],theme,"brick1.png", IGNORE_ALPHA); @@ -561,7 +562,7 @@ level_load_image(&img_bkgd_tile[1][1],theme,"bkgd-11.png", USE_ALPHA); level_load_image(&img_bkgd_tile[1][2],theme,"bkgd-12.png", USE_ALPHA); level_load_image(&img_bkgd_tile[1][3],theme,"bkgd-13.png", USE_ALPHA); - + */ if(!bkgd_image.empty()) { char fname[1024]; @@ -580,19 +581,6 @@ /* Free graphics data for this level: */ void level_free_gfx(void) { - int i; - - for (i = 0; i < 2; i++) - { - texture_free(&img_brick[i]); - } - for (i = 0; i < 4; i++) - { - texture_free(&img_solid[i]); - texture_free(&img_bkgd_tile[0][i]); - texture_free(&img_bkgd_tile[1][i]); - } - texture_free(&img_bkgd); } Index: level.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level.h,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- level.h 11 Apr 2004 00:05:35 -0000 1.21 +++ level.h 11 Apr 2004 00:24:22 -0000 1.22 @@ -52,11 +52,6 @@ extern texture_type img_bkgd; -/* -extern texture_type img_bkgd_tile[2][4]; -extern texture_type img_solid[4]; -extern texture_type img_brick[2]; -*/ class Level { public: |
From: Ingo R. <gr...@us...> - 2004-04-11 00:24:27
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18300 Added Files: resources.cpp resources.h Log Message: - moved stuff from gamesession to world --- NEW FILE: resources.h --- #ifndef SUPERTUX_RESOURCES_H #define SUPERTUX_RESOURCES_H extern texture_type img_waves[3]; extern texture_type img_water; extern texture_type img_pole; extern texture_type img_poletop; extern texture_type img_flag[2]; extern texture_type img_cloud[2][4]; void loadshared(); void unloadshared(); #endif /* EOF */ --- NEW FILE: resources.cpp --- #include "globals.h" #include "scene.h" #include "player.h" #include "badguy.h" #include "resources.h" texture_type img_waves[3]; texture_type img_water; texture_type img_pole; texture_type img_poletop; texture_type img_flag[2]; texture_type img_cloud[2][4]; /* Load graphics/sounds shared between all levels: */ void loadshared() { int i; /* Tuxes: */ texture_load(&smalltux_stand_left, datadir + "/images/shared/smalltux-left-6.png", USE_ALPHA); texture_load(&smalltux_stand_right, datadir + "/images/shared/smalltux-right-6.png", USE_ALPHA); texture_load(&smalltux_jump_left, datadir + "/images/shared/smalltux-jump-left.png", USE_ALPHA); texture_load(&smalltux_jump_right, datadir + "/images/shared/smalltux-jump-right.png", USE_ALPHA); tux_right.resize(8); texture_load(&tux_right[0], datadir + "/images/shared/smalltux-right-1.png", USE_ALPHA); texture_load(&tux_right[1], datadir + "/images/shared/smalltux-right-2.png", USE_ALPHA); texture_load(&tux_right[2], datadir + "/images/shared/smalltux-right-3.png", USE_ALPHA); texture_load(&tux_right[3], datadir + "/images/shared/smalltux-right-4.png", USE_ALPHA); texture_load(&tux_right[4], datadir + "/images/shared/smalltux-right-5.png", USE_ALPHA); texture_load(&tux_right[5], datadir + "/images/shared/smalltux-right-6.png", USE_ALPHA); texture_load(&tux_right[6], datadir + "/images/shared/smalltux-right-7.png", USE_ALPHA); texture_load(&tux_right[7], datadir + "/images/shared/smalltux-right-8.png", USE_ALPHA); tux_left.resize(8); texture_load(&tux_left[0], datadir + "/images/shared/smalltux-left-1.png", USE_ALPHA); texture_load(&tux_left[1], datadir + "/images/shared/smalltux-left-2.png", USE_ALPHA); texture_load(&tux_left[2], datadir + "/images/shared/smalltux-left-3.png", USE_ALPHA); texture_load(&tux_left[3], datadir + "/images/shared/smalltux-left-4.png", USE_ALPHA); texture_load(&tux_left[4], datadir + "/images/shared/smalltux-left-5.png", USE_ALPHA); texture_load(&tux_left[5], datadir + "/images/shared/smalltux-left-6.png", USE_ALPHA); texture_load(&tux_left[6], datadir + "/images/shared/smalltux-left-7.png", USE_ALPHA); texture_load(&tux_left[7], datadir + "/images/shared/smalltux-left-8.png", USE_ALPHA); texture_load(&firetux_right[0], datadir + "/images/shared/firetux-right-0.png", USE_ALPHA); texture_load(&firetux_right[1], datadir + "/images/shared/firetux-right-1.png", USE_ALPHA); texture_load(&firetux_right[2], datadir + "/images/shared/firetux-right-2.png", USE_ALPHA); texture_load(&firetux_left[0], datadir + "/images/shared/firetux-left-0.png", USE_ALPHA); texture_load(&firetux_left[1], datadir + "/images/shared/firetux-left-1.png", USE_ALPHA); texture_load(&firetux_left[2], datadir + "/images/shared/firetux-left-2.png", USE_ALPHA); texture_load(&cape_right[0], datadir + "/images/shared/cape-right-0.png", USE_ALPHA); texture_load(&cape_right[1], datadir + "/images/shared/cape-right-1.png", USE_ALPHA); texture_load(&cape_left[0], datadir + "/images/shared/cape-left-0.png", USE_ALPHA); texture_load(&cape_left[1], datadir + "/images/shared/cape-left-1.png", USE_ALPHA); texture_load(&bigtux_right[0], datadir + "/images/shared/bigtux-right-0.png", USE_ALPHA); texture_load(&bigtux_right[1], datadir + "/images/shared/bigtux-right-1.png", USE_ALPHA); texture_load(&bigtux_right[2], datadir + "/images/shared/bigtux-right-2.png", USE_ALPHA); texture_load(&bigtux_right_jump, datadir + "/images/shared/bigtux-right-jump.png", USE_ALPHA); texture_load(&bigtux_left[0], datadir + "/images/shared/bigtux-left-0.png", USE_ALPHA); texture_load(&bigtux_left[1], datadir + "/images/shared/bigtux-left-1.png", USE_ALPHA); texture_load(&bigtux_left[2], datadir + "/images/shared/bigtux-left-2.png", USE_ALPHA); texture_load(&bigtux_left_jump, datadir + "/images/shared/bigtux-left-jump.png", USE_ALPHA); texture_load(&bigcape_right[0], datadir + "/images/shared/bigcape-right-0.png", USE_ALPHA); texture_load(&bigcape_right[1], datadir + "/images/shared/bigcape-right-1.png", USE_ALPHA); texture_load(&bigcape_left[0], datadir + "/images/shared/bigcape-left-0.png", USE_ALPHA); texture_load(&bigcape_left[1], datadir + "/images/shared/bigcape-left-1.png", USE_ALPHA); texture_load(&bigfiretux_right[0], datadir + "/images/shared/bigfiretux-right-0.png", USE_ALPHA); texture_load(&bigfiretux_right[1], datadir + "/images/shared/bigfiretux-right-1.png", USE_ALPHA); texture_load(&bigfiretux_right[2], datadir + "/images/shared/bigfiretux-right-2.png", USE_ALPHA); texture_load(&bigfiretux_right_jump, datadir + "/images/shared/bigfiretux-right-jump.png", USE_ALPHA); texture_load(&bigfiretux_left[0], datadir + "/images/shared/bigfiretux-left-0.png", USE_ALPHA); texture_load(&bigfiretux_left[1], datadir + "/images/shared/bigfiretux-left-1.png", USE_ALPHA); texture_load(&bigfiretux_left[2], datadir + "/images/shared/bigfiretux-left-2.png", USE_ALPHA); texture_load(&bigfiretux_left_jump, datadir + "/images/shared/bigfiretux-left-jump.png", USE_ALPHA); texture_load(&bigcape_right[0], datadir + "/images/shared/bigcape-right-0.png", USE_ALPHA); texture_load(&bigcape_right[1], datadir + "/images/shared/bigcape-right-1.png", USE_ALPHA); texture_load(&bigcape_left[0], datadir + "/images/shared/bigcape-left-0.png", USE_ALPHA); texture_load(&bigcape_left[1], datadir + "/images/shared/bigcape-left-1.png", USE_ALPHA); texture_load(&ducktux_right, datadir + "/images/shared/ducktux-right.png", USE_ALPHA); texture_load(&ducktux_left, datadir + "/images/shared/ducktux-left.png", USE_ALPHA); texture_load(&skidtux_right, datadir + "/images/shared/skidtux-right.png", USE_ALPHA); texture_load(&skidtux_left, datadir + "/images/shared/skidtux-left.png", USE_ALPHA); texture_load(&duckfiretux_right, datadir + "/images/shared/duckfiretux-right.png", USE_ALPHA); texture_load(&duckfiretux_left, datadir + "/images/shared/duckfiretux-left.png", USE_ALPHA); texture_load(&skidfiretux_right, datadir + "/images/shared/skidfiretux-right.png", USE_ALPHA); texture_load(&skidfiretux_left, datadir + "/images/shared/skidfiretux-left.png", USE_ALPHA); /* Boxes: */ texture_load(&img_box_full, datadir + "/images/shared/box-full.png", IGNORE_ALPHA); texture_load(&img_box_empty, datadir + "/images/shared/box-empty.png", IGNORE_ALPHA); /* Water: */ texture_load(&img_water, datadir + "/images/shared/water.png", IGNORE_ALPHA); texture_load(&img_waves[0], datadir + "/images/shared/waves-0.png", USE_ALPHA); texture_load(&img_waves[1], datadir + "/images/shared/waves-1.png", USE_ALPHA); texture_load(&img_waves[2], datadir + "/images/shared/waves-2.png", USE_ALPHA); /* Pole: */ texture_load(&img_pole, datadir + "/images/shared/pole.png", USE_ALPHA); texture_load(&img_poletop, datadir + "/images/shared/poletop.png", USE_ALPHA); /* Flag: */ texture_load(&img_flag[0], datadir + "/images/shared/flag-0.png", USE_ALPHA); texture_load(&img_flag[1], datadir + "/images/shared/flag-1.png", USE_ALPHA); /* Cloud: */ texture_load(&img_cloud[0][0], datadir + "/images/shared/cloud-00.png", USE_ALPHA); texture_load(&img_cloud[0][1], datadir + "/images/shared/cloud-01.png", USE_ALPHA); texture_load(&img_cloud[0][2], datadir + "/images/shared/cloud-02.png", USE_ALPHA); texture_load(&img_cloud[0][3], datadir + "/images/shared/cloud-03.png", USE_ALPHA); texture_load(&img_cloud[1][0], datadir + "/images/shared/cloud-10.png", USE_ALPHA); texture_load(&img_cloud[1][1], datadir + "/images/shared/cloud-11.png", USE_ALPHA); texture_load(&img_cloud[1][2], datadir + "/images/shared/cloud-12.png", USE_ALPHA); texture_load(&img_cloud[1][3], datadir + "/images/shared/cloud-13.png", USE_ALPHA); /* Bad guys: */ load_badguy_gfx(); /* Upgrades: */ texture_load(&img_mints, datadir + "/images/shared/mints.png", USE_ALPHA); texture_load(&img_coffee, datadir + "/images/shared/coffee.png", USE_ALPHA); /* Weapons: */ texture_load(&img_bullet, datadir + "/images/shared/bullet.png", USE_ALPHA); texture_load(&img_red_glow, datadir + "/images/shared/red-glow.png", USE_ALPHA); /* Distros: */ texture_load(&img_distro[0], datadir + "/images/shared/distro-0.png", USE_ALPHA); texture_load(&img_distro[1], datadir + "/images/shared/distro-1.png", USE_ALPHA); texture_load(&img_distro[2], datadir + "/images/shared/distro-2.png", USE_ALPHA); texture_load(&img_distro[3], datadir + "/images/shared/distro-3.png", USE_ALPHA); /* Tux life: */ texture_load(&tux_life, datadir + "/images/shared/tux-life.png", USE_ALPHA); /* Herring: */ texture_load(&img_golden_herring, datadir + "/images/shared/golden-herring.png", USE_ALPHA); /* Super background: */ texture_load(&img_super_bkgd, datadir + "/images/shared/super-bkgd.png", IGNORE_ALPHA); /* Sound effects: */ /* if (use_sound) // this will introduce SERIOUS bugs here ! because "load_sound" // initialize sounds[i] with the correct pointer's value: // NULL or something else. And it will be dangerous to // play with not-initialized pointers. // This is also true with if (use_music) Send a mail to me: neo...@us..., if you have another opinion. :) */ for (i = 0; i < NUM_SOUNDS; i++) sounds[i] = load_sound(datadir + soundfilenames[i]); /* Herring song */ herring_song = load_song(datadir + "/music/SALCON.MOD"); } /* Free shared data: */ void unloadshared(void) { int i; for (i = 0; i < 3; i++) { texture_free(&tux_right[i]); texture_free(&tux_left[i]); texture_free(&bigtux_right[i]); texture_free(&bigtux_left[i]); } texture_free(&bigtux_right_jump); texture_free(&bigtux_left_jump); for (i = 0; i < 2; i++) { texture_free(&cape_right[i]); texture_free(&cape_left[i]); texture_free(&bigcape_right[i]); texture_free(&bigcape_left[i]); } texture_free(&ducktux_left); texture_free(&ducktux_right); texture_free(&skidtux_left); texture_free(&skidtux_right); free_badguy_gfx(); texture_free(&img_box_full); texture_free(&img_box_empty); texture_free(&img_water); for (i = 0; i < 3; i++) texture_free(&img_waves[i]); texture_free(&img_pole); texture_free(&img_poletop); for (i = 0; i < 2; i++) texture_free(&img_flag[i]); texture_free(&img_mints); texture_free(&img_coffee); for (i = 0; i < 4; i++) { texture_free(&img_distro[i]); texture_free(&img_cloud[0][i]); texture_free(&img_cloud[1][i]); } texture_free(&img_golden_herring); for (i = 0; i < NUM_SOUNDS; i++) free_chunk(sounds[i]); /* free the herring song */ free_music( herring_song ); } /* EOF */ |