--- a/src/proto2/GameState.cc Fri Nov 28 13:00:24 2008 +0000
+++ b/src/proto2/GameState.cc Fri Nov 28 13:11:51 2008 +0000
@@ -36,3 +36,7 @@
void Player::debugInfo (void) {
Engine::log(DEBUG, "Player.debugInfo") << "In air: " << this->inAir;
}
+
+void Shot::onCollision() {
+// world.removeGround(position, 20);
+}
--- a/src/proto2/GameState.hh Fri Nov 28 13:00:24 2008 +0000
+++ b/src/proto2/GameState.hh Fri Nov 28 13:11:51 2008 +0000
@@ -55,6 +55,21 @@
};
+class Shot : public PhysicsObject {
+protected:
+ GameState &state;
+ bool visible;
+ uint32_t birth_tick;
+ uint32_t death_tick;
+public:
+ Shot(GameState &state, Vector position, bool visible) :
+ PhysicsObject((PhysicsWorld &) state, PLAYER_MASS, position, Vector(0, 0)), state(state), visible(visible) {
+
+ }
+private:
+ virtual void onCollision();
+};
+
class LocalPlayer : public Player {
protected:
LocalPlayer (GameState &state, Vector pos, bool visible) : Player(state, pos, visible) { }
--- a/src/proto2/Graphics.cc Fri Nov 28 13:00:24 2008 +0000
+++ b/src/proto2/Graphics.cc Fri Nov 28 13:11:51 2008 +0000
@@ -72,7 +72,10 @@
if (keyboard.get_keycode(CL_KEY_I))
player->debugInfo();
-
+
+ if (keyboard.get_keycode(CL_KEY_M))
+ input_move |= INPUT_MOVE_DIG;
+
// apply movement if applicable
if (input_move)
player->handleMove(input_move);
--- a/src/proto2/Input.hh Fri Nov 28 13:00:24 2008 +0000
+++ b/src/proto2/Input.hh Fri Nov 28 13:11:51 2008 +0000
@@ -12,6 +12,7 @@
INPUT_MOVE_RIGHT = 0x0008,
INPUT_MOVE_JUMP = 0x0010,
+ INPUT_MOVE_DIG = 0x0020,
};
typedef uint16_t PlayerInput_Move;
--- a/src/proto2/Physics.cc Fri Nov 28 13:00:24 2008 +0000
+++ b/src/proto2/Physics.cc Fri Nov 28 13:11:51 2008 +0000
@@ -78,7 +78,7 @@
// We can start a free fall now
//
// TODO it should be set inAir if it falls from a cliff
- //this->inAir = true;
+ this->inAir = true;
// Put some speed there to make loke smoother
//this->velocity.y = -5;
@@ -234,6 +234,7 @@
}
} else {
newPosition = reached;
+ onCollision();
//this->velocity = Vector(0, 0);
//TODO: it shouldn't just stop on collision
}
--- a/src/proto2/Physics.hh Fri Nov 28 13:00:24 2008 +0000
+++ b/src/proto2/Physics.hh Fri Nov 28 13:11:51 2008 +0000
@@ -143,6 +143,8 @@
Derivative evaluate(Force force, TimeMS dt, Derivative &d);
Vector acceleration(const Force &force);
+ virtual void onCollision() {}
+
public:
Vector getPosition (void);
std::vector<Vector>& getShape(void);