Now we use different lists for players and projectiles
authorsaiam
Wed, 03 Dec 2008 16:47:17 +0000
changeset 183 e31ff2152774
parent 182 84675387ca74
child 184 561892e2a30e
Now we use different lists for players and projectiles
src/proto2/GameState.cc
src/proto2/GameState.hh
src/proto2/Physics.cc
src/proto2/Physics.hh
--- a/src/proto2/GameState.cc	Wed Dec 03 14:25:23 2008 +0000
+++ b/src/proto2/GameState.cc	Wed Dec 03 16:47:17 2008 +0000
@@ -46,16 +46,6 @@
             jump(0);
     }
 
-    this->changeAim(da); // Move crosshair
-
-    // Player facing
-    if (fx < 0) setFacing(false);
-    else if (fx > 0) setFacing(true);
-
-    // Apply force
-    applyForce(Vector(fx, 0));
-
-    // dig/shoot or something
     if (input & INPUT_MOVE_DIG) {
         // Should create Shot which destroys ground, but also should be destroyed then,
         // but it doesn't.
@@ -68,6 +58,19 @@
     if (input & INPUT_SHOOT) {
         this->shoot();
     }
+
+
+
+    // Player facing
+    if (fx < 0) setFacing(false);
+    else if (fx > 0) setFacing(true);
+
+
+    this->changeAim(da); // Move crosshair
+
+    // Apply force
+    applyForce(Vector(fx, 0));
+
 }
 
 void Player::debugInfo (void) {
--- a/src/proto2/GameState.hh	Wed Dec 03 14:25:23 2008 +0000
+++ b/src/proto2/GameState.hh	Wed Dec 03 16:47:17 2008 +0000
@@ -29,6 +29,7 @@
         // Initialize the shape of the player (salmiakki shape)
         setShape(shape);
         collision_elasticity = PLAYER_COLLISION_ELASTICITY;
+        world.addPlayerObject(this);
     }
     
     void debugInfo ();
@@ -54,8 +55,9 @@
         shape[2] = Vector(1, 1);
         shape[3] = Vector(1, -1);
         setShape(shape);
-        target_visible = true;
+        target_visible = false;
         collision_elasticity = 0.9; // = shotType.elasticity
+        world.addProjectile(this);
     }
 private:
     virtual void onCollision();
--- a/src/proto2/Physics.cc	Wed Dec 03 14:25:23 2008 +0000
+++ b/src/proto2/Physics.cc	Wed Dec 03 16:47:17 2008 +0000
@@ -1,4 +1,3 @@
-
 #include "Physics.hh"
 #include "Engine.hh"
 #include "GameState.hh"
@@ -16,7 +15,7 @@
     tick_timer.enable();
 }
 
-void PhysicsWorld::addObject (PhysicsObject *object) {
+void PhysicsWorld::addPlayerObject (PhysicsObject *object) {
     players.push_back(object);
 }
 
@@ -31,6 +30,10 @@
         (*i)->tick(); 
     }
 
+    for (std::list<PhysicsObject*>::iterator i = projectiles.begin(); i != projectiles.end(); i++) {
+        (*i)->tick();
+    }
+
     tick_counter++;
 }
 
@@ -56,7 +59,7 @@
     : world(world), position(position), velocity(velocity),
       mass(mass), inAir(true), aim(0), facingRight(true), reloadTimer(0) {
     // TODO: Is thir the right way to do this?
-    world.addObject(this);
+    //world.addPlayerObject(this);
 }
 
 /**
--- a/src/proto2/Physics.hh	Wed Dec 03 14:25:23 2008 +0000
+++ b/src/proto2/Physics.hh	Wed Dec 03 16:47:17 2008 +0000
@@ -62,7 +62,7 @@
      *
      * @param object Pointer to the PhysicsObject to add.
      */
-    void addObject(PhysicsObject *object);
+    void addPlayerObject(PhysicsObject *object);
     
     void addProjectile(PhysicsObject *projectile);