terom@26: terom@26: #include "GameState.hh" ekku@94: #include "Engine.hh" terom@26: terom@96: void Player::handleMove (PlayerInput_Move input) { saiam@108: float fx = 0; // Force in x-direction saiam@108: float da = 0; // Crosshair angle terom@26: terom@96: // handle left/right terom@54: if (input & INPUT_MOVE_LEFT) saiam@108: fx -= PLAYER_MOVE_FORCE; terom@50: terom@54: if (input & INPUT_MOVE_RIGHT) saiam@108: fx += PLAYER_MOVE_FORCE; ekku@94: saiam@108: if (input & INPUT_MOVE_UP) saiam@108: da += CROSSHAIR_ANGLE_SPEED; saiam@108: saiam@108: if (input & INPUT_MOVE_DOWN) saiam@108: da -= CROSSHAIR_ANGLE_SPEED; saiam@108: saiam@114: if (input & INPUT_MOVE_JUMP) saiam@114: jump(); saiam@114: saiam@114: this->changeAim(da); // Move crosshair saiam@114: saiam@108: // Player facing saiam@108: if (fx < 0) setFacing(false); saiam@108: else if (fx > 0) setFacing(true); saiam@108: saiam@114: // Apply force saiam@114: applyForce(Vector(fx, 0), INPUT_INTERVAL_MS); saiam@108: terom@26: } ekku@94: ekku@94: void Player::debugInfo (void) { saiam@108: Engine::log(DEBUG, "Player.debugInfo") << "In air: " << this->inAir; ekku@94: }