author | ekku |
Wed, 03 Dec 2008 12:09:42 +0000 | |
changeset 180 | bfe1077edab3 |
parent 170 | fe74105c07ea |
child 182 | 84675387ca74 |
permissions | -rw-r--r-- |
26 | 1 |
|
2 |
#include "GameState.hh" |
|
94 | 3 |
#include "Engine.hh" |
26 | 4 |
|
180 | 5 |
void Player::shoot (void) { |
6 |
this->state.addProjectile(new Shot(this->state, this->position, true)); |
|
7 |
} |
|
8 |
||
96
4a801210096c
fix movement physics+network code to some degree, jumping is now buggy?
terom
parents:
94
diff
changeset
|
9 |
void Player::handleMove (PlayerInput_Move input) { |
108 | 10 |
float fx = 0; // Force in x-direction |
11 |
float da = 0; // Crosshair angle |
|
26 | 12 |
|
96
4a801210096c
fix movement physics+network code to some degree, jumping is now buggy?
terom
parents:
94
diff
changeset
|
13 |
// handle left/right |
160 | 14 |
if ((input & INPUT_MOVE_LEFT) && (velocity.x > -PLAYER_MAX_SPEED)) |
108 | 15 |
fx -= PLAYER_MOVE_FORCE; |
50
9e1a6506f5a1
some rough-handed code modifications towards a newer, better, working Physics
terom
parents:
26
diff
changeset
|
16 |
|
160 | 17 |
if ((input & INPUT_MOVE_RIGHT) && (velocity.x < PLAYER_MAX_SPEED)) |
108 | 18 |
fx += PLAYER_MOVE_FORCE; |
94 | 19 |
|
108 | 20 |
if (input & INPUT_MOVE_UP) |
21 |
da += CROSSHAIR_ANGLE_SPEED; |
|
22 |
||
23 |
if (input & INPUT_MOVE_DOWN) |
|
24 |
da -= CROSSHAIR_ANGLE_SPEED; |
|
25 |
||
170 | 26 |
if (input & INPUT_MOVE_JUMP) { |
27 |
if ((input & INPUT_MOVE_LEFT)) |
|
28 |
jump(-1); |
|
29 |
else if ((input & INPUT_MOVE_RIGHT)) |
|
30 |
jump(1); |
|
31 |
else |
|
32 |
jump(0); |
|
33 |
} |
|
114
71f7e9d3d052
V?h?n siistin tota walkkia, viel? on kyll? tekemist?.
saiam
parents:
108
diff
changeset
|
34 |
|
71f7e9d3d052
V?h?n siistin tota walkkia, viel? on kyll? tekemist?.
saiam
parents:
108
diff
changeset
|
35 |
this->changeAim(da); // Move crosshair |
71f7e9d3d052
V?h?n siistin tota walkkia, viel? on kyll? tekemist?.
saiam
parents:
108
diff
changeset
|
36 |
|
108 | 37 |
// Player facing |
38 |
if (fx < 0) setFacing(false); |
|
39 |
else if (fx > 0) setFacing(true); |
|
40 |
||
114
71f7e9d3d052
V?h?n siistin tota walkkia, viel? on kyll? tekemist?.
saiam
parents:
108
diff
changeset
|
41 |
// Apply force |
122
16a73ebca810
No warnings anymore, but well have to think about that applyForce
saiam
parents:
117
diff
changeset
|
42 |
applyForce(Vector(fx, 0)); |
108 | 43 |
|
117 | 44 |
// dig/shoot or something |
45 |
if (input & INPUT_MOVE_DIG) { |
|
46 |
// Should create Shot which destroys ground, but also should be destroyed then, |
|
47 |
// but it doesn't. |
|
48 |
// But this now just segfaults |
|
49 |
// world.addObject(new Shot(state, position, true)); |
|
50 |
||
153
73402d5b778e
Lots of small fixe. Moved drawing PhysicsObjects away from Graphics.cc.
saiam
parents:
122
diff
changeset
|
51 |
world.removeGround(position, 15); |
117 | 52 |
} |
26 | 53 |
} |
94 | 54 |
|
55 |
void Player::debugInfo (void) { |
|
108 | 56 |
Engine::log(DEBUG, "Player.debugInfo") << "In air: " << this->inAir; |
94 | 57 |
} |
116 | 58 |
|
59 |
void Shot::onCollision() { |
|
60 |
// world.removeGround(position, 20); |
|
61 |
} |