kaikki hajoo
authorekku
Thu, 04 Dec 2008 19:53:16 +0000
changeset 196 e2d32c4601ce
parent 195 53feb13a3d1c
child 197 d9ac888de778
kaikki hajoo
src/GameState.cc
src/GameState.hh
src/Graphics.cc
--- a/src/GameState.cc	Thu Dec 04 17:12:46 2008 +0000
+++ b/src/GameState.cc	Thu Dec 04 19:53:16 2008 +0000
@@ -79,6 +79,11 @@
 
 void Shot::onCollision() {
     world.removeGround(position, 20);
+    this->destroyed = true;
+}
+
+bool Shot::isDestroyed (void) {
+    return this->destroyed;
 }
 
 void Shot::draw(CL_GraphicContext *gc) {
--- a/src/GameState.hh	Thu Dec 04 17:12:46 2008 +0000
+++ b/src/GameState.hh	Thu Dec 04 19:53:16 2008 +0000
@@ -1,7 +1,12 @@
 #ifndef GAMESTATE_HH
 #define GAMESTATE_HH
 
-#include "Physics.hh"
+class GameState;
+
+#include "PhysicsWorld.hh"
+#include "PhysicsObject.hh"
+#include "Player.hh"
+#include "Projectile.hh"
 #include "Input.hh"
 #include "Config.hh"
 
@@ -9,73 +14,6 @@
 #include <stdexcept>
 #include <cmath>
 
-// forward-declare GameState
-class GameState;
-
-class Player : public PhysicsObject {
-protected:
-    GameState &state;
-    bool visible;
-    
-public:
-    Player(GameState &state, Vector position, bool visible) : 
-        PhysicsObject((PhysicsWorld &) state, PLAYER_MASS, position, Vector(0, 0)), state(state), visible(visible) {
-            
-        std::vector<Vector> shape(4);
-        shape[0] = Vector(0,-9);
-        shape[1] = Vector(6,0);
-        shape[2] = Vector(0,9); 
-        shape[3] = Vector(-6,0);
-        // Initialize the shape of the player (salmiakki shape)
-        setShape(shape);
-        collision_elasticity = PLAYER_COLLISION_ELASTICITY;
-        world.addPlayerObject(this);
-        // TODO: DEBUG: remove
-//        this->position = position-Vector(60, 40);
-    }
-    
-    void debugInfo ();
-    virtual void handleMove (PlayerInput_Move input);
-    void shoot (void);
-
-};
-
-class Shot : public PhysicsObject {
-protected:
-    GameState &state;
-    bool visible;
-    uint32_t birth_tick;
-    uint32_t death_tick;
-    bool target_visible;
-public:
-    Shot(GameState &state, Vector position, Vector velocity, bool visible) :
-        PhysicsObject((PhysicsWorld &) state, PLAYER_MASS, position, velocity), state(state), visible(visible) {
-        // Looks kind of dumb, for ammunition to have shape
-        std::vector<Vector> shape(4);
-        shape[0] = Vector(-1, -1);
-        shape[1] = Vector(-1, 1);
-        shape[2] = Vector(1, 1);
-        shape[3] = Vector(1, -1);
-        setShape(shape);
-        target_visible = false;
-        collision_elasticity = 0.9; // = shotType.elasticity
-        world.addProjectile(this);
-    }
-private:
-    virtual void onCollision();
-    virtual void draw(CL_GraphicContext *gc);
-};
-
-class LocalPlayer : public Player {
-protected:
-    LocalPlayer (GameState &state, Vector pos, bool visible) : Player(state, pos, visible) { }
-};
-
-class RemotePlayer : public Player {
-protected:
-    RemotePlayer (GameState &state, Vector pos, bool visible) : Player(state, pos, visible) { }
-};
-
 class GameState : public PhysicsWorld {
 public:
     std::list<Player*> player_list;
--- a/src/Graphics.cc	Thu Dec 04 17:12:46 2008 +0000
+++ b/src/Graphics.cc	Thu Dec 04 19:53:16 2008 +0000
@@ -1,6 +1,5 @@
 
 #include "Graphics.hh"
-#include "Physics.hh"
 #include "GameState.hh"
 #include <cmath>