src/proto2/GameState.cc
author saiam
Thu, 20 Nov 2008 21:25:09 +0000
changeset 83 cbba9729e92b
parent 66 1415a2d45686
child 94 08bebac3d0c2
permissions -rw-r--r--
Integrointia fyssaan, jotain pikkubugausta havaittavissa.

#include "GameState.hh"

void LocalPlayer::handleMove (PlayerInput_Move input) {
    float fx = 0, fy = 0;

    // handle up/down/left/right
    if (input & INPUT_MOVE_UP)
            fy -= PLAYER_MOVE_FORCE;
    
    if (input & INPUT_MOVE_DOWN)
            fy += PLAYER_MOVE_FORCE;

    if (input & INPUT_MOVE_LEFT)
            fx -= PLAYER_MOVE_FORCE;

    if (input & INPUT_MOVE_RIGHT)
            fx += PLAYER_MOVE_FORCE;
    
    if (fx || fy) {
        // apply force
        applyForce(Vector(fx, fy), INPUT_INTERVAL_MS);
    }
}