author | nireco |
Tue, 02 Dec 2008 00:23:16 +0000 | |
changeset 174 | 073f25a84f60 |
parent 170 | fe74105c07ea |
child 180 | bfe1077edab3 |
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 |
160 | 10 |
if ((input & INPUT_MOVE_LEFT) && (velocity.x > -PLAYER_MAX_SPEED)) |
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 |
|
160 | 13 |
if ((input & INPUT_MOVE_RIGHT) && (velocity.x < PLAYER_MAX_SPEED)) |
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 |
||
170 | 22 |
if (input & INPUT_MOVE_JUMP) { |
23 |
if ((input & INPUT_MOVE_LEFT)) |
|
24 |
jump(-1); |
|
25 |
else if ((input & INPUT_MOVE_RIGHT)) |
|
26 |
jump(1); |
|
27 |
else |
|
28 |
jump(0); |
|
29 |
} |
|
114
71f7e9d3d052
V?h?n siistin tota walkkia, viel? on kyll? tekemist?.
saiam
parents:
108
diff
changeset
|
30 |
|
71f7e9d3d052
V?h?n siistin tota walkkia, viel? on kyll? tekemist?.
saiam
parents:
108
diff
changeset
|
31 |
this->changeAim(da); // Move crosshair |
71f7e9d3d052
V?h?n siistin tota walkkia, viel? on kyll? tekemist?.
saiam
parents:
108
diff
changeset
|
32 |
|
108 | 33 |
// Player facing |
34 |
if (fx < 0) setFacing(false); |
|
35 |
else if (fx > 0) setFacing(true); |
|
36 |
||
114
71f7e9d3d052
V?h?n siistin tota walkkia, viel? on kyll? tekemist?.
saiam
parents:
108
diff
changeset
|
37 |
// Apply force |
122
16a73ebca810
No warnings anymore, but well have to think about that applyForce
saiam
parents:
117
diff
changeset
|
38 |
applyForce(Vector(fx, 0)); |
108 | 39 |
|
117 | 40 |
// dig/shoot or something |
41 |
if (input & INPUT_MOVE_DIG) { |
|
42 |
// Should create Shot which destroys ground, but also should be destroyed then, |
|
43 |
// but it doesn't. |
|
44 |
// But this now just segfaults |
|
45 |
// world.addObject(new Shot(state, position, true)); |
|
46 |
||
153
73402d5b778e
Lots of small fixe. Moved drawing PhysicsObjects away from Graphics.cc.
saiam
parents:
122
diff
changeset
|
47 |
world.removeGround(position, 15); |
117 | 48 |
} |
26 | 49 |
} |
94 | 50 |
|
51 |
void Player::debugInfo (void) { |
|
108 | 52 |
Engine::log(DEBUG, "Player.debugInfo") << "In air: " << this->inAir; |
94 | 53 |
} |
116 | 54 |
|
55 |
void Shot::onCollision() { |
|
56 |
// world.removeGround(position, 20); |
|
57 |
} |