[Super-tux-commit] supertux/src/object block.cpp,1.3,1.4
Brought to you by:
wkendrick
From: Matze B. <mat...@us...> - 2004-11-24 03:43:09
|
Update of /cvsroot/super-tux/supertux/src/object In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22752/src/object Modified Files: block.cpp Log Message: Improved collision detection by taking movement into account. Fixed long standing bug where returning from bonuslevel to mainmenu and going back to bonuslevels makes supertux crash Index: block.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/object/block.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- block.cpp 23 Nov 2004 14:32:19 -0000 1.3 +++ block.cpp 24 Nov 2004 03:42:57 -0000 1.4 @@ -35,22 +35,18 @@ HitResponse Block::collision(GameObject& other, const CollisionHit& hitdata) { - if(bouncing) - return FORCE_MOVE; - // TODO kill badguys when bumping them... Player* player = dynamic_cast<Player*> (&other); - if(!player) - return ABORT_MOVE; - - // collided from below? - if(hitdata.normal.x == 0 && hitdata.normal.y < 0 - && player->get_movement().y < 0) { - hit(*player); + if(player) { + // collided from below? + if(hitdata.normal.x == 0 && hitdata.normal.y < 0 + && player->get_movement().y < 0) { + hit(*player); + } } - return ABORT_MOVE; + return FORCE_MOVE; } void @@ -61,9 +57,9 @@ float offset = original_y - get_pos().y; if(offset > BOUNCY_BRICK_MAX_OFFSET) { - bounce_dir *= -1; + bounce_dir = BOUNCY_BRICK_SPEED; movement = Vector(0, bounce_dir * elapsed_time); - } else if(offset < -EPSILON) { + } else if(offset < BOUNCY_BRICK_SPEED * elapsed_time && bounce_dir > 0) { movement = Vector(0, offset); bounce_dir = 0; bouncing = false; |