src/proto2/GameState.cc
author terom
Tue, 18 Nov 2008 19:59:43 +0000
changeset 58 a53f5ad69500
parent 54 b8b043ba0abd
child 60 26571fd9a8d1
permissions -rw-r--r--
"working" singleplayer

#include "GameState.hh"

bool LocalPlayer::handleMove (PlayerInput_Move input) {
    int dx = 0, dy = 0;

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

    if (input & INPUT_MOVE_LEFT)
            dx -= PLAYER_MOVE_FORCE;

    if (input & INPUT_MOVE_RIGHT)
            dx += PLAYER_MOVE_FORCE;
    
    // apply force
    applyForce(Vector(dx, dy));
}