| author | saiam |
| Thu, 20 Nov 2008 21:25:09 +0000 | |
| changeset 83 | cbba9729e92b |
| parent 66 | 1415a2d45686 |
| child 94 | 08bebac3d0c2 |
| permissions | -rw-r--r-- |
| 26 | 1 |
|
2 |
#include "GameState.hh" |
|
3 |
||
| 60 | 4 |
void LocalPlayer::handleMove (PlayerInput_Move input) {
|
5 |
float fx = 0, fy = 0; |
|
| 26 | 6 |
|
|
50
9e1a6506f5a1
some rough-handed code modifications towards a newer, better, working Physics
terom
parents:
26
diff
changeset
|
7 |
// handle up/down/left/right |
| 54 | 8 |
if (input & INPUT_MOVE_UP) |
| 60 | 9 |
fy -= PLAYER_MOVE_FORCE; |
|
50
9e1a6506f5a1
some rough-handed code modifications towards a newer, better, working Physics
terom
parents:
26
diff
changeset
|
10 |
|
| 54 | 11 |
if (input & INPUT_MOVE_DOWN) |
| 60 | 12 |
fy += PLAYER_MOVE_FORCE; |
| 26 | 13 |
|
| 54 | 14 |
if (input & INPUT_MOVE_LEFT) |
| 60 | 15 |
fx -= PLAYER_MOVE_FORCE; |
|
50
9e1a6506f5a1
some rough-handed code modifications towards a newer, better, working Physics
terom
parents:
26
diff
changeset
|
16 |
|
| 54 | 17 |
if (input & INPUT_MOVE_RIGHT) |
| 60 | 18 |
fx += PLAYER_MOVE_FORCE; |
|
50
9e1a6506f5a1
some rough-handed code modifications towards a newer, better, working Physics
terom
parents:
26
diff
changeset
|
19 |
|
| 66 | 20 |
if (fx || fy) {
|
21 |
// apply force |
|
22 |
applyForce(Vector(fx, fy), INPUT_INTERVAL_MS); |
|
23 |
} |
|
| 26 | 24 |
} |