src/PhysicsObject.hh
changeset 222 293ddf4c067d
parent 221 fbc5db6fce45
child 225 22ecb9cb9245
equal deleted inserted replaced
221:fbc5db6fce45 222:293ddf4c067d
    19 /**
    19 /**
    20  * PhysicObject class. A basic PhysicsObject class.
    20  * PhysicObject class. A basic PhysicsObject class.
    21  */
    21  */
    22 class PhysicsObject {
    22 class PhysicsObject {
    23 protected:
    23 protected:
    24     // This probably shouldn't be done this way.
       
    25 
       
    26 
       
    27     Vector position;
    24     Vector position;
    28     Vector velocity;
    25     Vector velocity;
    29     float mass;
    26     float mass;
    30     bool inAir; // Is the object "on the ground"
    27     bool inAir; // Is the object "on the ground"
    31     float collision_elasticity;
    28     float collision_elasticity;
    32 
    29 
    33     // Attributes for players
    30     // Attributes for players
    34     float aim; // Aim direction (half circle)
    31     float aim; // Aim direction (half circle)
    35     bool facingRight; // Player facing
    32     bool facingRight; // Player facing
    36 
    33 
       
    34     bool alive;
       
    35 
    37     PhysicsObject(PhysicsWorld &world, float mass, Vector position, 
    36     PhysicsObject(PhysicsWorld &world, float mass, Vector position, 
    38                   Vector velocity);
    37                   Vector velocity);
    39     ~PhysicsObject() {}
    38     virtual ~PhysicsObject (void);
    40 
    39 
    41 
    40 
    42     /**
    41     /**
    43      * Add force to the force queue to be applied on next tick.
    42      * Add force to the force queue to be applied on next tick.
    44      *
    43      *
   157      * @return Position vector
   156      * @return Position vector
   158      */
   157      */
   159     Vector getPosition();
   158     Vector getPosition();
   160 
   159 
   161     /**
   160     /**
       
   161      * Get current object velocity.
       
   162      *
       
   163      * @return Velocity vector
       
   164      */
       
   165     Vector getVelocity();
       
   166 
       
   167     /**
   162      * Return object shape.
   168      * Return object shape.
   163      *
   169      *
   164      * @return Polygon points
   170      * @return Polygon points
   165      */
   171      */
   166     std::vector<Vector>& getShape();
   172     std::vector<Vector>& getShape();
   183      * Return object aim angle.
   189      * Return object aim angle.
   184      *
   190      *
   185      * @return Object aim angle
   191      * @return Object aim angle
   186      */
   192      */
   187     float getAim();
   193     float getAim();
       
   194 
       
   195     /**
       
   196      *  Mark object as destroyed, it will be delete'd later
       
   197      */
       
   198     void destroy (void);
       
   199 
       
   200     /*
       
   201      * Had the object been destroyed?
       
   202      */
       
   203     bool isDestroyed (void);
       
   204     
       
   205     /**
       
   206      * Delete ourselves if we've been destroyed and return true, else return false
       
   207      */
       
   208     bool removeIfDestroyed (void);
   188 
   209 
   189     /**
   210     /**
   190      * Update object in physics simulation.
   211      * Update object in physics simulation.
   191      */
   212      */
   192     virtual void tick (TimeMS tick_length);
   213     virtual void tick (TimeMS tick_length);