[Super-tux-commit] supertux/src level.cpp,1.65,1.66 level.h,1.45,1.46 player.cpp,1.83,1.84 world.cpp
Brought to you by:
wkendrick
From: Ricardo C. <rm...@us...> - 2004-05-07 23:10:21
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25019/src Modified Files: level.cpp level.h player.cpp world.cpp Log Message: Added horizontal auto scrolling! Hope you like it ;) Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.83 retrieving revision 1.84 diff -u -d -r1.83 -r1.84 --- player.cpp 4 May 2004 13:58:59 -0000 1.83 +++ player.cpp 7 May 2004 23:09:53 -0000 1.84 @@ -27,6 +27,8 @@ #include "sprite.h" #include "screen.h" +#define AUTOSCROLL_DEAD_INTERVAL 300 + Surface* tux_life; Sprite* smalltux_gameover; @@ -721,7 +723,7 @@ bool Player::is_dead() { - if(base.y > screen->h) + if(base.y > screen->h || base.x < scroll_x - AUTOSCROLL_DEAD_INTERVAL) // last condition can happen in auto-scrolling return true; else return false; @@ -754,6 +756,15 @@ if(base.x < scroll_x) // can happen if back scrolling is disabled base.x = scroll_x; + + if(base.x == scroll_x) + if(issolid(base.x, base.y) || issolid(base.x, base.y+32)) + kill(KILL); + + if(base.x + base.width > scroll_x + screen->w) + base.x = scroll_x + screen->w - base.width; + + } // EOF // Index: level.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level.cpp,v retrieving revision 1.65 retrieving revision 1.66 diff -u -d -r1.65 -r1.66 --- level.cpp 6 May 2004 20:02:26 -0000 1.65 +++ level.cpp 7 May 2004 23:09:52 -0000 1.66 @@ -237,6 +237,7 @@ time_left = 100; gravity = 10.; back_scrolling = false; + hor_autoscroll_speed = 0; bkgd_speed = 2; bkgd_top.red = 0; bkgd_top.green = 0; @@ -316,6 +317,9 @@ back_scrolling = false; reader.read_bool("back_scrolling", &back_scrolling); + hor_autoscroll_speed = 0; + reader.read_float("hor_autoscroll_speed", &hor_autoscroll_speed); + bkgd_speed = 2; reader.read_int("bkgd_speed", &bkgd_speed); @@ -561,6 +565,7 @@ fprintf(fi," (back_scrolling #t)\n"); else fprintf(fi," (back_scrolling #f)\n"); + fprintf(fi," (hor_autoscroll_speed %2.1f)\n", hor_autoscroll_speed); fprintf(fi," (gravity %2.1f)\n", gravity); fprintf(fi," (background-tm "); Index: world.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.cpp,v retrieving revision 1.67 retrieving revision 1.68 diff -u -d -r1.67 -r1.68 --- world.cpp 6 May 2004 18:49:52 -0000 1.67 +++ world.cpp 7 May 2004 23:09:53 -0000 1.68 @@ -318,6 +318,12 @@ /* This functions takes cares of the scrolling */ void World::scrolling(double frame_ratio) { + if(level->hor_autoscroll_speed) + { + scroll_x += level->hor_autoscroll_speed * frame_ratio; + return; + } + int tux_pos_x = (int)(tux.base.x + (tux.base.width/2)); if (level->back_scrolling || debug_mode) Index: level.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level.h,v retrieving revision 1.45 retrieving revision 1.46 diff -u -d -r1.45 -r1.46 --- level.h 3 May 2004 23:06:19 -0000 1.45 +++ level.h 7 May 2004 23:09:52 -0000 1.46 @@ -90,6 +90,7 @@ int start_pos_y; float gravity; bool back_scrolling; + float hor_autoscroll_speed; std::vector<BadGuyData> badguy_data; |