26
|
1 |
|
|
2 |
#include "GameState.hh"
|
|
3 |
|
35
|
4 |
void LocalPlayer::handleMove (PlayerInput_Move input) {
|
|
5 |
float fx = 0, fy = 0;
|
26
|
6 |
|
35
|
7 |
// handle up/down/left/right
|
|
8 |
if (input & INPUT_MOVE_UP)
|
|
9 |
fy -= PLAYER_MOVE_FORCE;
|
|
10 |
|
|
11 |
if (input & INPUT_MOVE_DOWN)
|
|
12 |
fy += PLAYER_MOVE_FORCE;
|
26
|
13 |
|
35
|
14 |
if (input & INPUT_MOVE_LEFT)
|
|
15 |
fx -= PLAYER_MOVE_FORCE;
|
|
16 |
|
|
17 |
if (input & INPUT_MOVE_RIGHT)
|
|
18 |
fx += PLAYER_MOVE_FORCE;
|
|
19 |
|
|
20 |
if (fx || fy) {
|
|
21 |
// apply force
|
|
22 |
applyForce(Vector(fx, fy), INPUT_INTERVAL_MS);
|
26
|
23 |
}
|
|
24 |
}
|