src/PhysicsWorld.hh
changeset 197 d9ac888de778
child 199 f5c86420facd
equal deleted inserted replaced
196:e2d32c4601ce 197:d9ac888de778
       
     1 #ifndef PHYSICS_WORLD_HH
       
     2 #define PHYSICS_WORLD_HH
       
     3 
       
     4 #include <ClanLib/display.h>
       
     5 #include <ClanLib/core.h>
       
     6 
       
     7 #include <algorithm>
       
     8 #include <functional>
       
     9 #include <cmath>
       
    10            
       
    11 #include "Terrain.hh"          
       
    12 class PhysicsWorld;
       
    13 
       
    14 #include "PhysicsObject.hh"
       
    15 #include "Vector.hh"
       
    16 #include "Config.hh"
       
    17 #include "Projectile.hh"
       
    18 
       
    19 /**
       
    20 * PhysicsWorld class. PhysicsWorld contains PhysicsObjects that are
       
    21 * simulated in the PhysicsWorld.
       
    22 */
       
    23 class PhysicsWorld : public Terrain {
       
    24     friend class PhysicsObject;
       
    25 
       
    26 private:
       
    27     CL_Timer tick_timer;
       
    28     uint32_t tick_counter;
       
    29 
       
    30     //    Terrain terrain;
       
    31 
       
    32 protected:
       
    33     std::list<PhysicsObject*> players;
       
    34     std::list<Shot*> projectiles;
       
    35 //    std::vector<PhysicsObject*> objects;
       
    36 
       
    37     // Contains connections between signals and slots
       
    38     CL_SlotContainer slots;
       
    39 
       
    40     PhysicsWorld(Vector gravity, Vector dimensions);
       
    41 
       
    42     // TODO: Should these be somewhere else?
       
    43     Vector dimensions;
       
    44     Vector gravity;
       
    45 
       
    46 
       
    47 
       
    48 public:
       
    49     // TODO: Replace addObject with these?
       
    50     //void addPlayerObject(PlayerObject *object);
       
    51     //void addProjectileObject(ProjectileObject *object);
       
    52     
       
    53     /**
       
    54      * Add object to the PhysicsWorld.
       
    55      *
       
    56      * @param object Pointer to the PhysicsObject to add.
       
    57      */
       
    58     void addPlayerObject(PhysicsObject *object);
       
    59     
       
    60     void addProjectile(Shot *projectile);
       
    61 
       
    62     /**
       
    63      * Advance one time step in physics simulation.
       
    64      */
       
    65     void tick();
       
    66 
       
    67     /**
       
    68      * Get current tick in physics simulation.
       
    69      *
       
    70      * @return tick Current simulation tick.
       
    71      */
       
    72     uint32_t getTick();
       
    73 
       
    74     virtual void draw(CL_GraphicContext *gc);
       
    75 
       
    76     // TODO This should probably be protected or in GameStat or in GameStatee
       
    77 };
       
    78 
       
    79 #endif