[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r3376 - trunk/pingus/src/actions
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r3376 - trunk/pingus/src/actions |
Date: |
Mon, 29 Oct 2007 05:23:04 +0100 |
Author: grumbel
Date: 2007-10-29 05:23:03 +0100 (Mon, 29 Oct 2007)
New Revision: 3376
Modified:
trunk/pingus/src/actions/faller.cpp
Log:
- removed while loop fixed head bounce a bit
Modified: trunk/pingus/src/actions/faller.cpp
===================================================================
--- trunk/pingus/src/actions/faller.cpp 2007-10-29 03:37:44 UTC (rev 3375)
+++ trunk/pingus/src/actions/faller.cpp 2007-10-29 04:23:03 UTC (rev 3376)
@@ -72,77 +72,66 @@
Movers::LinearMover mover(WorldObj::get_world(), pingu->get_pos());
- do
- {
- // Move the Pingu as far is it can go
- mover.update(move, Colliders::PinguCollider(pingu_height));
+ // Move the Pingu as far is it can go
+ mover.update(move, Colliders::PinguCollider(pingu_height));
- pingu->set_pos(mover.get_pos());
+ pingu->set_pos(mover.get_pos());
- collided = mover.collided();
+ collided = mover.collided();
- // If the Pingu collided with something...
- if (collided)
+ // If the Pingu collided with something...
+ if (collided)
+ {
+ if (rel_getpixel(0, -1) == Groundtype::GP_NOTHING &&
+ rel_getpixel(0, -2) == Groundtype::GP_NOTHING &&
+ rel_getpixel(0, -3) == Groundtype::GP_NOTHING &&
+ rel_getpixel(1, 0) != Groundtype::GP_NOTHING &&
+ rel_getpixel(1, 0) != Groundtype::GP_BRIDGE)
{
- move = mover.remaining();
+ // Make Pingu bounce off wall
+ velocity.x = -(velocity.x / 3.0f);
- if (rel_getpixel(0, -1) == Groundtype::GP_NOTHING &&
- rel_getpixel(0, -2) == Groundtype::GP_NOTHING &&
- rel_getpixel(0, -3) == Groundtype::GP_NOTHING)
- {
- // Make Pingu bounce off wall
- move.x = -(move.x / 3.0f);
- velocity.x = -(velocity.x / 3.0f);
+ // Make the Pingu face the correct direction. NB: Pingu may
+ // previously have been facing in the opposite direction of its
+ // velocity because of an explosion.
+ if (velocity.x > 0.0f)
+ pingu->direction.right();
+ else
+ pingu->direction.left();
- // Make the Pingu face the correct direction. NB: Pingu may
- // previously have been facing in the opposite direction of its
- // velocity because of an explosion.
- if (velocity.x > 0.0f)
- pingu->direction.right();
- else
- pingu->direction.left();
-
- pingu->set_velocity(velocity);
- break;
+ pingu->set_velocity(velocity);
+ }
+ else if (velocity.y > 0.0f) // If the Pingu collided into something
while moving down...
+ {
+ // Ping is on ground/water/something
+ if (rel_getpixel(0, -1) == Groundtype::GP_WATER
+ || rel_getpixel(0, -1) == Groundtype::GP_LAVA)
+ {
+ pingu->set_action(Actions::Drown);
}
- else if (velocity.y > 0.0f) // If the Pingu collided into something
while moving down...
+ // Did we stop too fast?
+ else if (fabs(pingu->get_velocity().y) > deadly_velocity)
{
- // Ping is on ground/water/something
- if (rel_getpixel(0, -1) == Groundtype::GP_WATER
- || rel_getpixel(0, -1) == Groundtype::GP_LAVA)
- {
- pingu->set_action(Actions::Drown);
- }
- // Did we stop too fast?
- else if (fabs(pingu->get_velocity().y) > deadly_velocity)
- {
- //std::cout << "Pingus splashed: " <<
pingu->get_velocity().y << " " << deadly_velocity << std::endl;
- pingu->set_action(Actions::Splashed);
- }
- else
- {
- // This is where the jumper bug happens
- //std::cout << "Reached the unreachable: " <<
pingu->get_velocity().y << std::endl;
- pingu->set_action(Actions::Walker);
- }
-
- break;
+ //std::cout << "Pingus splashed: " << pingu->get_velocity().y <<
" " << deadly_velocity << std::endl;
+ pingu->set_action(Actions::Splashed);
}
- // If the Pingu collided into something while moving up...
- else // if (velocity.y < 0.0f)
+ else
{
- // Don't make the Pingu go up any further.
- move.y = 0.0f;
- velocity.y = 0.0f;
- break;
+ // This is where the jumper bug happens
+ //std::cout << "Reached the unreachable: " <<
pingu->get_velocity().y << std::endl;
+ pingu->set_action(Actions::Walker);
}
}
+ // If the Pingu collided into something while moving up...
+ else // if (velocity.y < 0.0f)
+ {
+ std::cout << "Head bounce" << std::endl;
+ // Don't make the Pingu go up any further.
+ velocity.y = 0;
- // Update the Pingu's velocity
- pingu->set_velocity(velocity);
+ pingu->set_velocity(velocity);
+ }
}
- // Loop if the Pingu still needs to be moved
- while (collided);
}
void
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r3376 - trunk/pingus/src/actions,
grumbel at BerliOS <=