[Super-tux-commit] supertux/src badguy.cpp,1.28,1.29 player.cpp,1.31,1.32
Brought to you by:
wkendrick
From: Ingo R. <gr...@us...> - 2004-04-11 23:20:12
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17828 Modified Files: badguy.cpp player.cpp Log Message: - tweaked scroll behaviour a little bit - added collision rects in debug mode Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- player.cpp 11 Apr 2004 16:33:11 -0000 1.31 +++ player.cpp 11 Apr 2004 23:06:29 -0000 1.32 @@ -722,7 +722,6 @@ else { /* Tux has coffee! */ - if (!duck) { if (!skidding_timer.started()) @@ -785,6 +784,9 @@ if(dying) text_drawf(&gold_text,"Penguins can fly !:",0,0,A_HMIDDLE,A_VMIDDLE,1); + + if (debug_mode) + fillrect(base.x - scroll_x, base.y, 32, 32, 75,75,75, 150); } void @@ -917,42 +919,54 @@ Level* plevel = World::current()->get_level(); /* Keep tux in bounds: */ - if (base.x< 0) - base.x= 0; - else if(base.x< scroll_x) - base.x= scroll_x; - else if (base.x< 160 + scroll_x && scroll_x > 0 && debug_mode) - { - scroll_x = base.x- 160; - /*base.x+= 160;*/ - - if(scroll_x < 0) - scroll_x = 0; - - } - else if (base.x > screen->w / 2 + scroll_x - && 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 - - // Scroll the screen in past center: - scroll_x = base.x - screen->w / 2; - - if (scroll_x > ((plevel->width * 32) - screen->w)) - scroll_x = ((plevel->width * 32) - screen->w); + if (base.x < 0) + { // Lock Tux to the size of the level, so that he doesn't fall of + // on the left side + base.x = 0; } - else if (base.x> 608 + scroll_x) - { - /* ... unless there's no more to scroll! */ - - /*base.x= 608 + scroll_x;*/ + else if (base.x < scroll_x) + { + base.x = scroll_x; } /* Keep in-bounds, vertically: */ - if (base.y > screen->h) { kill(KILL); } + + int scroll_threshold = screen->w/2 - 80; + if (debug_mode) + { + scroll_x += screen->w/2; + // Backscrolling for debug mode + if (scroll_x < base.x - 80) + scroll_x = base.x - 80; + else if (scroll_x > base.x + 80) + scroll_x = base.x + 80; + scroll_x -= screen->w/2; + + if(scroll_x < 0) + scroll_x = 0; + } + else + { + if (base.x > scroll_threshold + scroll_x + && 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 + + // Scroll the screen in past center: + scroll_x = base.x - scroll_threshold; + + // Lock the scrolling to the levelsize, so that we don't + // scroll over the right border + if (scroll_x > 32 * plevel->width - screen->w) + scroll_x = 32 * plevel->width - screen->w; + } + } } + +// EOF // + Index: badguy.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.cpp,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- badguy.cpp 11 Apr 2004 16:23:07 -0000 1.28 +++ badguy.cpp 11 Apr 2004 23:06:29 -0000 1.29 @@ -742,6 +742,9 @@ texture_type* texture = (dir == LEFT) ? &texture_left[frame] : &texture_right[frame]; texture_draw(texture, base.x - scroll_x, base.y); + + if (debug_mode) + fillrect(base.x - scroll_x, base.y, 32, 32, 75,0,75, 150); } void |