author | saiam |
Fri, 28 Nov 2008 22:26:23 +0000 | |
changeset 128 | 890ac82cdcc0 |
parent 122 | 16a73ebca810 |
child 153 | 73402d5b778e |
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 |
122
16a73ebca810
No warnings anymore, but well have to think about that applyForce
saiam
parents:
117
diff
changeset
|
32 |
applyForce(Vector(fx, 0)); |
108 | 33 |
|
117 | 34 |
// dig/shoot or something |
35 |
if (input & INPUT_MOVE_DIG) { |
|
36 |
// Should create Shot which destroys ground, but also should be destroyed then, |
|
37 |
// but it doesn't. |
|
38 |
// But this now just segfaults |
|
39 |
// world.addObject(new Shot(state, position, true)); |
|
40 |
||
41 |
world.removeGround(position, 10); |
|
42 |
} |
|
26 | 43 |
} |
94 | 44 |
|
45 |
void Player::debugInfo (void) { |
|
108 | 46 |
Engine::log(DEBUG, "Player.debugInfo") << "In air: " << this->inAir; |
94 | 47 |
} |
116 | 48 |
|
49 |
void Shot::onCollision() { |
|
50 |
// world.removeGround(position, 20); |
|
51 |
} |