return true;
}
-void
+void
Zeekling::onBumpHorizontal() {
if (state == FLYING) {
dir = (dir == LEFT ? RIGHT : LEFT);
}
}
-void
+void
Zeekling::onBumpVertical() {
if (state == FLYING) {
physic.set_velocity_y(0);
Zeekling::collision_solid(const CollisionHit& hit)
{
if(hit.top || hit.bottom) {
- onBumpVertical();
+ onBumpVertical();
} else if(hit.left || hit.right) {
onBumpHorizontal();
}
/**
* linear prediction of player and badguy positions to decide if we should enter the DIVING state
*/
-bool
+bool
Zeekling::should_we_dive() {
const MovingObject* player = this->get_nearest_player();
if (!player) return false;
// guess number of frames to descend to same height as player
float estFrames = height / relSpeed;
-
+
// guess where the player would be at this time
float estPx = (playerPos.x + (estFrames * playerMov.x));
return false;
}
-void
+void
Zeekling::active_update(float elapsed_time) {
if (state == FLYING) {
if (should_we_dive()) {