author | saiam |
Mon, 24 Nov 2008 23:04:22 +0000 | |
changeset 108 | 1b93045a5b0a |
parent 96 | 4a801210096c |
child 114 | 71f7e9d3d052 |
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 |
||
22 |
// Player facing |
|
23 |
if (fx < 0) setFacing(false); |
|
24 |
else if (fx > 0) setFacing(true); |
|
25 |
||
26 |
this->changeAim(da); // Move crosshair |
|
27 |
||
28 |
// we behave differently depending on if we're in the air or on the ground |
|
29 |
if (inAir) { |
|
30 |
// apply horizontal force |
|
31 |
if (fx) |
|
32 |
applyForce(Vector(fx, 0), INPUT_INTERVAL_MS); |
|
33 |
||
34 |
} else { |
|
35 |
// walk right |
|
36 |
if (fx) |
|
37 |
this->position = walk(fx > 0); |
|
96
4a801210096c
fix movement physics+network code to some degree, jumping is now buggy?
terom
parents:
94
diff
changeset
|
38 |
|
108 | 39 |
// jump? |
40 |
if (input & INPUT_MOVE_JUMP) |
|
41 |
jump(); |
|
42 |
} |
|
26 | 43 |
} |
94 | 44 |
|
45 |
void Player::debugInfo (void) { |
|
108 | 46 |
Engine::log(DEBUG, "Player.debugInfo") << "In air: " << this->inAir; |
94 | 47 |
} |