src/proto2/Physics.hh
author terom
Wed, 12 Nov 2008 13:59:01 +0000
changeset 42 eb1a93a38cde
child 43 e510a5e62917
permissions -rw-r--r--
lazy commit that breaks everything, should be a branch
42
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
     1
#ifndef PHYSICS_HH
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
     2
#define PHYSICS_HH
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
     3
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
     4
#include "Vector.hh"
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
     5
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
     6
const uint16_t PHYSICS_TICK_MS = 50;
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
     7
const uint16_t PHYSICS_WORLD_WIDTH = 800;
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
     8
const uint16_t PHYSICS_WORLD_HEIGHT = 600;
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
     9
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
    10
class PhysicsWorld {
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
    11
    protected:
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
    12
        std::vector<PhysicsObject*> objects;
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
    13
        Vector dimensions;
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
    14
        
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
    15
        PhysicsWorld (Vector dimensions);
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
    16
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
    17
    public:
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
    18
        void addObject (PhysicsObject *object);
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
    19
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
    20
        void tick (void);
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
    21
};
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
    22
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
    23
class PhysicsObject {
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
    24
    protected:
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
    25
        Vector position;
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
    26
        Vector velocity;
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
    27
        Vector force;
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
    28
        uint16_t mass;
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
    29
    
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
    30
        PhysicsObject (mass, position, velocity, force);
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
    31
    
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
    32
    private:
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
    33
        void updatePosition (void);
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
    34
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
    35
    protected:
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
    36
        void applyForce (Vector force);
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
    37
        void updatePhysics (Vector position, Vector velocity, Vector force);
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
    38
    
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
    39
    public:
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
    40
        Vector getPosition (void);
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
    41
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
    42
        void tick (void);
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
    43
};
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
    44
eb1a93a38cde lazy commit that breaks everything, should be a branch
terom
parents:
diff changeset
    45
#endif