| author | nireco |
| Mon, 24 Nov 2008 22:18:49 +0000 | |
| changeset 106 | 731f9dd775d4 |
| parent 96 | 4a801210096c |
| child 108 | 1b93045a5b0a |
| 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) {
|
|
4a801210096c
fix movement physics+network code to some degree, jumping is now buggy?
terom
parents:
94
diff
changeset
|
6 |
float fx = 0; |
| 26 | 7 |
|
|
96
4a801210096c
fix movement physics+network code to some degree, jumping is now buggy?
terom
parents:
94
diff
changeset
|
8 |
// handle left/right |
| 54 | 9 |
if (input & INPUT_MOVE_LEFT) |
| 60 | 10 |
fx -= PLAYER_MOVE_FORCE; |
|
50
9e1a6506f5a1
some rough-handed code modifications towards a newer, better, working Physics
terom
parents:
26
diff
changeset
|
11 |
|
| 54 | 12 |
if (input & INPUT_MOVE_RIGHT) |
| 60 | 13 |
fx += PLAYER_MOVE_FORCE; |
|
96
4a801210096c
fix movement physics+network code to some degree, jumping is now buggy?
terom
parents:
94
diff
changeset
|
14 |
|
|
4a801210096c
fix movement physics+network code to some degree, jumping is now buggy?
terom
parents:
94
diff
changeset
|
15 |
// we behave differently depending on if we're in the air or on the ground |
|
4a801210096c
fix movement physics+network code to some degree, jumping is now buggy?
terom
parents:
94
diff
changeset
|
16 |
if (inAir) {
|
|
4a801210096c
fix movement physics+network code to some degree, jumping is now buggy?
terom
parents:
94
diff
changeset
|
17 |
// apply horizontal force |
|
4a801210096c
fix movement physics+network code to some degree, jumping is now buggy?
terom
parents:
94
diff
changeset
|
18 |
if (fx) |
|
4a801210096c
fix movement physics+network code to some degree, jumping is now buggy?
terom
parents:
94
diff
changeset
|
19 |
applyForce(Vector(fx, 0), INPUT_INTERVAL_MS); |
| 94 | 20 |
|
|
96
4a801210096c
fix movement physics+network code to some degree, jumping is now buggy?
terom
parents:
94
diff
changeset
|
21 |
} else {
|
|
4a801210096c
fix movement physics+network code to some degree, jumping is now buggy?
terom
parents:
94
diff
changeset
|
22 |
// walk right |
|
4a801210096c
fix movement physics+network code to some degree, jumping is now buggy?
terom
parents:
94
diff
changeset
|
23 |
if (fx) |
|
4a801210096c
fix movement physics+network code to some degree, jumping is now buggy?
terom
parents:
94
diff
changeset
|
24 |
this->position = walk(fx > 0); |
|
4a801210096c
fix movement physics+network code to some degree, jumping is now buggy?
terom
parents:
94
diff
changeset
|
25 |
|
|
4a801210096c
fix movement physics+network code to some degree, jumping is now buggy?
terom
parents:
94
diff
changeset
|
26 |
// jump? |
|
4a801210096c
fix movement physics+network code to some degree, jumping is now buggy?
terom
parents:
94
diff
changeset
|
27 |
if (input & INPUT_MOVE_JUMP) |
|
4a801210096c
fix movement physics+network code to some degree, jumping is now buggy?
terom
parents:
94
diff
changeset
|
28 |
jump(); |
|
4a801210096c
fix movement physics+network code to some degree, jumping is now buggy?
terom
parents:
94
diff
changeset
|
29 |
} |
| 26 | 30 |
} |
| 94 | 31 |
|
32 |
void Player::debugInfo (void) {
|
|
33 |
Engine::log(DEBUG, "Player.debugInfo") << "In air: " << this->inAir; |
|
34 |
} |