author | saiam |
Fri, 28 Nov 2008 12:26:39 +0000 | |
changeset 114 | 71f7e9d3d052 |
parent 108 | 1b93045a5b0a |
child 116 | 0d36aade845e |
permissions | -rw-r--r-- |
26 | 1 |
|
2 |
#include "GameState.hh" |
|
94 | 3 |
#include "Engine.hh" |
26 | 4 |
|
96
4a801210096c
fix movement physics+network code to some degree, jumping is now buggy?
terom
parents:
94
diff
changeset
|
5 |
void Player::handleMove (PlayerInput_Move input) { |
108 | 6 |
float fx = 0; // Force in x-direction |
7 |
float da = 0; // Crosshair angle |
|
26 | 8 |
|
96
4a801210096c
fix movement physics+network code to some degree, jumping is now buggy?
terom
parents:
94
diff
changeset
|
9 |
// handle left/right |
54 | 10 |
if (input & INPUT_MOVE_LEFT) |
108 | 11 |
fx -= PLAYER_MOVE_FORCE; |
50
9e1a6506f5a1
some rough-handed code modifications towards a newer, better, working Physics
terom
parents:
26
diff
changeset
|
12 |
|
54 | 13 |
if (input & INPUT_MOVE_RIGHT) |
108 | 14 |
fx += PLAYER_MOVE_FORCE; |
94 | 15 |
|
108 | 16 |
if (input & INPUT_MOVE_UP) |
17 |
da += CROSSHAIR_ANGLE_SPEED; |
|
18 |
||
19 |
if (input & INPUT_MOVE_DOWN) |
|
20 |
da -= CROSSHAIR_ANGLE_SPEED; |
|
21 |
||
114
71f7e9d3d052
V?h?n siistin tota walkkia, viel? on kyll? tekemist?.
saiam
parents:
108
diff
changeset
|
22 |
if (input & INPUT_MOVE_JUMP) |
71f7e9d3d052
V?h?n siistin tota walkkia, viel? on kyll? tekemist?.
saiam
parents:
108
diff
changeset
|
23 |
jump(); |
71f7e9d3d052
V?h?n siistin tota walkkia, viel? on kyll? tekemist?.
saiam
parents:
108
diff
changeset
|
24 |
|
71f7e9d3d052
V?h?n siistin tota walkkia, viel? on kyll? tekemist?.
saiam
parents:
108
diff
changeset
|
25 |
this->changeAim(da); // Move crosshair |
71f7e9d3d052
V?h?n siistin tota walkkia, viel? on kyll? tekemist?.
saiam
parents:
108
diff
changeset
|
26 |
|
108 | 27 |
// Player facing |
28 |
if (fx < 0) setFacing(false); |
|
29 |
else if (fx > 0) setFacing(true); |
|
30 |
||
114
71f7e9d3d052
V?h?n siistin tota walkkia, viel? on kyll? tekemist?.
saiam
parents:
108
diff
changeset
|
31 |
// Apply force |
71f7e9d3d052
V?h?n siistin tota walkkia, viel? on kyll? tekemist?.
saiam
parents:
108
diff
changeset
|
32 |
applyForce(Vector(fx, 0), INPUT_INTERVAL_MS); |
108 | 33 |
|
26 | 34 |
} |
94 | 35 |
|
36 |
void Player::debugInfo (void) { |
|
108 | 37 |
Engine::log(DEBUG, "Player.debugInfo") << "In air: " << this->inAir; |
94 | 38 |
} |