src/proto2/GameState.cc
author nireco
Mon, 24 Nov 2008 22:18:49 +0000
changeset 106 731f9dd775d4
parent 96 4a801210096c
child 108 1b93045a5b0a
permissions -rw-r--r--
get index or something

#include "GameState.hh"
#include "Engine.hh"

void Player::handleMove (PlayerInput_Move input) {
    float fx = 0;

    // handle left/right
    if (input & INPUT_MOVE_LEFT)
            fx -= PLAYER_MOVE_FORCE;

    if (input & INPUT_MOVE_RIGHT)
            fx += PLAYER_MOVE_FORCE;
    
    // we behave differently depending on if we're in the air or on the ground
    if (inAir) {
        // apply horizontal force
        if (fx)
            applyForce(Vector(fx, 0), INPUT_INTERVAL_MS);

    } else {
        // walk right
        if (fx)
            this->position = walk(fx > 0);
        
        // jump?
        if (input & INPUT_MOVE_JUMP)
            jump();    
    }
}

void Player::debugInfo (void) {
	Engine::log(DEBUG, "Player.debugInfo") << "In air: " << this->inAir;
}