src/proto2/GameState.cc
author saiam
Thu, 20 Nov 2008 22:45:10 +0000
changeset 86 ed31ece6f340
parent 66 1415a2d45686
child 94 08bebac3d0c2
permissions -rw-r--r--
Segfault <3 (mik? oli odotettavaa)

#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);
    }
}