[Super-tux-commit] supertux/src player.cpp,1.204,1.205 player.h,1.94,1.95 sector.cpp,1.45,1.46
Brought to you by:
wkendrick
From: Matze B. <mat...@us...> - 2004-11-24 23:10:49
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16564/src Modified Files: player.cpp player.h sector.cpp Log Message: some cleanups in the sprite class, increased delta for collision response Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.204 retrieving revision 1.205 diff -u -d -r1.204 -r1.205 --- player.cpp 24 Nov 2004 14:10:25 -0000 1.204 +++ player.cpp 24 Nov 2004 23:10:02 -0000 1.205 @@ -91,29 +91,16 @@ } void -TuxBodyParts::set_action(std::string action) -{ - if(head != NULL) - head->set_action(action); - if(body != NULL) - body->set_action(action); - if(arms != NULL) - arms->set_action(action); - if(feet != NULL) - feet->set_action(action); -} - -void -TuxBodyParts::one_time_animation() +TuxBodyParts::set_action(std::string action, int loops) { if(head != NULL) - head->start_animation(1); + head->set_action(action, loops); if(body != NULL) - body->start_animation(1); + body->set_action(action, loops); if(arms != NULL) - arms->start_animation(1); + arms->set_action(action, loops); if(feet != NULL) - feet->start_animation(1); + feet->set_action(action, loops); } void @@ -789,11 +776,9 @@ if(size == BIG) { if(dir == LEFT) - tux_body->head->set_action("idle-left"); + tux_body->head->set_action("idle-left", 1); else // dir == RIGHT - tux_body->head->set_action("idle-right"); - - tux_body->head->start_animation(1); + tux_body->head->set_action("idle-right", 1); } } Index: player.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.h,v retrieving revision 1.94 retrieving revision 1.95 diff -u -d -r1.94 -r1.95 --- player.h 22 Nov 2004 21:35:04 -0000 1.94 +++ player.h 24 Nov 2004 23:10:03 -0000 1.95 @@ -111,7 +111,7 @@ delete feet; } - void set_action(std::string action); + void set_action(std::string action, int loops = -1); void one_time_animation(); void draw(DrawingContext& context, const Vector& pos, int layer, Uint32 drawing_effect = NONE_EFFECT); Index: sector.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/sector.cpp,v retrieving revision 1.45 retrieving revision 1.46 diff -u -d -r1.45 -r1.46 --- sector.cpp 24 Nov 2004 17:33:49 -0000 1.45 +++ sector.cpp 24 Nov 2004 23:10:04 -0000 1.46 @@ -600,6 +600,8 @@ context.pop_transform(); } +static const float DELTA = .001; + void Sector::collision_tilemap(MovingObject* object, int depth) { @@ -701,7 +703,7 @@ return; } // move out of collision and try again - object->movement += hit.normal * (hit.depth + .05); + object->movement += hit.normal * (hit.depth + DELTA); collision_tilemap(object, depth+1); } @@ -724,15 +726,15 @@ if(response1 == ABORT_MOVE) object1->movement = Vector(0, 0); if(response2 == CONTINUE) - object2->movement += hit.normal * (hit.depth + .05); + object2->movement += hit.normal * (hit.depth + DELTA); } else if(response2 != CONTINUE) { if(response2 == ABORT_MOVE) object2->movement = Vector(0, 0); if(response1 == CONTINUE) - object1->movement += -hit.normal * (hit.depth + .05); + object1->movement += -hit.normal * (hit.depth + DELTA); } else { - object1->movement += -hit.normal * (hit.depth/2 + .05); - object2->movement += hit.normal * (hit.depth/2 + .05); + object1->movement += -hit.normal * (hit.depth/2 + DELTA); + object2->movement += hit.normal * (hit.depth/2 + DELTA); } } } @@ -743,12 +745,16 @@ for(std::vector<GameObject*>::iterator i = gameobjects.begin(); i != gameobjects.end(); ++i) { GameObject* gameobject = *i; - if(!gameobject->is_valid() - || gameobject->get_flags() & GameObject::FLAG_NO_COLLDET) + if(!gameobject->is_valid()) continue; MovingObject* movingobject = dynamic_cast<MovingObject*> (gameobject); if(!movingobject) continue; + if(movingobject->get_flags() & GameObject::FLAG_NO_COLLDET) { + movingobject->bbox.move(movingobject->movement); + movingobject->movement = Vector(0, 0); + continue; + } // collision with tilemap if(! (movingobject->movement == Vector(0, 0))) |