[Super-tux-commit] supertux/src gameobjs.cpp,1.15,1.16 scene.cpp,1.27,1.28 scene.h,1.28,1.29 sprite.
Brought to you by:
wkendrick
From: Ricardo C. <rm...@us...> - 2004-05-11 21:54:01
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19745/src Modified Files: gameobjs.cpp scene.cpp scene.h sprite.cpp world.cpp Log Message: First implementation of vertical scrolling. Index: scene.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/scene.cpp,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- scene.cpp 2 May 2004 16:08:22 -0000 1.27 +++ scene.cpp 11 May 2004 21:53:50 -0000 1.28 @@ -69,7 +69,7 @@ } // FIXME: Move this into a view class -float scroll_x; +float scroll_x, scroll_y; unsigned int global_frame_counter; Index: sprite.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/sprite.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- sprite.cpp 26 Apr 2004 12:21:22 -0000 1.6 +++ sprite.cpp 11 May 2004 21:53:50 -0000 1.7 @@ -79,7 +79,7 @@ unsigned int frame = get_current_frame(); if (frame < surfaces.size()) - surfaces[frame]->draw(x - x_hotspot, y - y_hotspot); + surfaces[frame]->draw(x - x_hotspot, y - y_hotspot - scroll_y); } void Index: world.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.cpp,v retrieving revision 1.73 retrieving revision 1.74 diff -u -d -r1.73 -r1.74 --- world.cpp 10 May 2004 19:06:03 -0000 1.73 +++ world.cpp 11 May 2004 21:53:51 -0000 1.74 @@ -202,7 +202,7 @@ for (x = 0; x < 21; ++x) { Tile::draw(32*x - fmodf(scroll_x, 32), y * 32, - level->bg_tiles[(int)y][(int)x + (int)(scroll_x / 32)]); + level->bg_tiles[(int)y + (int)(scroll_y / 32)][(int)x + (int)(scroll_x / 32)]); } } @@ -212,7 +212,7 @@ for (x = 0; x < 21; ++x) { Tile::draw(32*x - fmodf(scroll_x, 32), y * 32, - level->ia_tiles[(int)y][(int)x + (int)(scroll_x / 32)]); + level->ia_tiles[(int)y + (int)(scroll_y / 32)][(int)x + (int)(scroll_x / 32)]); } } @@ -246,7 +246,7 @@ for (x = 0; x < 21; ++x) { Tile::draw(32*x - fmodf(scroll_x, 32), y * 32, - level->fg_tiles[(int)y][(int)x + (int)(scroll_x / 32)]); + level->fg_tiles[(int)y + (int)(scroll_y / 32)][(int)x + (int)(scroll_x / 32)]); } } @@ -390,6 +390,18 @@ scroll_x = 0; if(scroll_x > level->width * 32 - screen->w) scroll_x = level->width * 32 - screen->w; + + /* Y-axis scrolling */ + + int tux_pos_y = (int)(tux.base.y + (tux.base.height/2)); + + scroll_y = tux_pos_y - (screen->h / 2); + + // this code prevent the screen to scroll before the start or after the level's end + if(scroll_y < 0) + scroll_y = 0; + if(scroll_y > level->height * 32 - screen->h) + scroll_y = level->height * 32 - screen->h; } void Index: scene.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/scene.h,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- scene.h 2 May 2004 16:08:22 -0000 1.28 +++ scene.h 11 May 2004 21:53:50 -0000 1.29 @@ -46,7 +46,7 @@ extern PlayerStatus player_status; -extern float scroll_x; +extern float scroll_x, scroll_y; extern unsigned int global_frame_counter; #endif /*SUPERTUX_SCENE_H*/ Index: gameobjs.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameobjs.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- gameobjs.cpp 29 Apr 2004 10:45:24 -0000 1.15 +++ gameobjs.cpp 11 May 2004 21:53:50 -0000 1.16 @@ -54,7 +54,7 @@ BouncyDistro::draw() { img_distro[0]->draw(base.x - scroll_x, - base.y); + base.y - scroll_y); } @@ -98,7 +98,7 @@ src.h = 16; dest.x = (int)(base.x - scroll_x); - dest.y = (int)base.y; + dest.y = (int)(base.y - scroll_y); dest.w = 16; dest.h = 16; @@ -147,7 +147,7 @@ base.x <= scroll_x + screen->w) { dest.x = (int)(base.x - scroll_x); - dest.y = (int)base.y; + dest.y = (int)(base.y - scroll_y); dest.w = 32; dest.h = 32; @@ -157,7 +157,7 @@ // paint it later at on offseted position if(plevel->bkgd_image[0] == '\0') { - fillrect(base.x - scroll_x, base.y, + fillrect(base.x - scroll_x, base.y - scroll_y, 32,32, plevel->bkgd_top.red, plevel->bkgd_top.green, plevel->bkgd_top.blue, 0); // FIXME: doesn't respect the gradient, futhermore is this necessary at all?? @@ -170,7 +170,7 @@ } Tile::draw(base.x - scroll_x, - base.y + offset, + base.y - scroll_y + offset, shape); } } |