Documenting more, cleaning variables. This code needs some serious
rewriting. (And we havent too many features either)
#include "GameState.hh"
#include "Engine.hh"
void Player::handleMove (PlayerInput_Move input) {
float fx = 0; // Force in x-direction
float da = 0; // Crosshair angle
// handle left/right
if (input & INPUT_MOVE_LEFT)
fx -= PLAYER_MOVE_FORCE;
if (input & INPUT_MOVE_RIGHT)
fx += PLAYER_MOVE_FORCE;
if (input & INPUT_MOVE_UP)
da += CROSSHAIR_ANGLE_SPEED;
if (input & INPUT_MOVE_DOWN)
da -= CROSSHAIR_ANGLE_SPEED;
if (input & INPUT_MOVE_JUMP)
jump();
this->changeAim(da); // Move crosshair
// Player facing
if (fx < 0) setFacing(false);
else if (fx > 0) setFacing(true);
// Apply force
applyForce(Vector(fx, 0));
// dig/shoot or something
if (input & INPUT_MOVE_DIG) {
// Should create Shot which destroys ground, but also should be destroyed then,
// but it doesn't.
// But this now just segfaults
// world.addObject(new Shot(state, position, true));
world.removeGround(position, 10);
}
}
void Player::debugInfo (void) {
Engine::log(DEBUG, "Player.debugInfo") << "In air: " << this->inAir;
}
void Shot::onCollision() {
// world.removeGround(position, 20);
}