src/PhysicsWorld.hh
author nireco
Sat, 31 Jan 2009 12:33:08 +0200
changeset 443 5d1119729f58
parent 423 947ab54de4b7
permissions -rw-r--r--
worm02 two pics to comment
197
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
     1
#ifndef PHYSICS_WORLD_HH
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
     2
#define PHYSICS_WORLD_HH
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
     3
205
905028e58ed1 implement a new tick-timer that doesn't suck
terom
parents: 201
diff changeset
     4
#include "Terrain.hh"          
199
f5c86420facd Jeejee, hirvee hinaus ohi toistaseks.
saiam
parents: 197
diff changeset
     5
197
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
     6
class PhysicsWorld;
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
     7
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
     8
#include "PhysicsObject.hh"
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
     9
#include "Vector.hh"
205
905028e58ed1 implement a new tick-timer that doesn't suck
terom
parents: 201
diff changeset
    10
#include "Timer.hh"
197
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
    11
#include "Config.hh"
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
    12
423
947ab54de4b7 fix worst compilation errors when using the debian lenny gcc/libc...
Tero Marttila <terom@fixme.fi>
parents: 409
diff changeset
    13
#include <ClanLib/core.h>
947ab54de4b7 fix worst compilation errors when using the debian lenny gcc/libc...
Tero Marttila <terom@fixme.fi>
parents: 409
diff changeset
    14
197
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
    15
/**
408
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 300
diff changeset
    16
* PhysicsWorld class. PhysicsWorld contains a number of PhysicsObjects that are simulated forward in time using
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 300
diff changeset
    17
* the physics tick rate
197
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
    18
*/
408
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 300
diff changeset
    19
class PhysicsWorld {
197
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
    20
    friend class PhysicsObject;
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
    21
408
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 300
diff changeset
    22
// XXX: needs some fixing up, move Terrain methods
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 300
diff changeset
    23
public:   
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 300
diff changeset
    24
    /** The world's terrain */
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 300
diff changeset
    25
    Terrain &terrain;
409
1a03ff151abc add --terrain-seed and --terrain-size arguments, plus bugfixes
Tero Marttila <terom@fixme.fi>
parents: 408
diff changeset
    26
    
1a03ff151abc add --terrain-seed and --terrain-size arguments, plus bugfixes
Tero Marttila <terom@fixme.fi>
parents: 408
diff changeset
    27
    /** Size of simulation area */
1a03ff151abc add --terrain-seed and --terrain-size arguments, plus bugfixes
Tero Marttila <terom@fixme.fi>
parents: 408
diff changeset
    28
    Vector dimensions;
197
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
    29
408
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 300
diff changeset
    30
protected:
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 300
diff changeset
    31
    /** List of simulated objects*/
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 300
diff changeset
    32
    std::list<PhysicsObject*> objects;
208
7709571e1131 Digging now uses projectiles.
saiam
parents: 205
diff changeset
    33
    
408
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 300
diff changeset
    34
    /** Gravity vector */
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 300
diff changeset
    35
    Vector gravity;
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 300
diff changeset
    36
    
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 300
diff changeset
    37
    /** Physics simulation ticks */
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 300
diff changeset
    38
    Timer tick_timer;
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 300
diff changeset
    39
    
197
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
    40
    CL_SlotContainer slots;
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
    41
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
    42
public:
408
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 300
diff changeset
    43
    /**
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 300
diff changeset
    44
     * Construct a world with the given configuration. 
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 300
diff changeset
    45
     */
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 300
diff changeset
    46
    PhysicsWorld (Vector gravity, Vector dimensions, Terrain &terrain);
199
f5c86420facd Jeejee, hirvee hinaus ohi toistaseks.
saiam
parents: 197
diff changeset
    47
225
22ecb9cb9245 Rope can be drawn.
ekku
parents: 222
diff changeset
    48
    /**
197
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
    49
     * Add object to the PhysicsWorld.
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
    50
     *
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
    51
     * @param object Pointer to the PhysicsObject to add.
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
    52
     */
408
e6cfc44266af reorganize Terrain/PhysicsWorld/GameState/Engine to use NetworkClientConnect, and hence handle the connection process asynchronously, and finally properly implement receiving the terrain data from the server
Tero Marttila <terom@fixme.fi>
parents: 300
diff changeset
    53
    void addPhysicsObject (PhysicsObject *object);
197
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
    54
    
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
    55
    /**
225
22ecb9cb9245 Rope can be drawn.
ekku
parents: 222
diff changeset
    56
     * Remove the object from the PhysicsWorld.
22ecb9cb9245 Rope can be drawn.
ekku
parents: 222
diff changeset
    57
     */
22ecb9cb9245 Rope can be drawn.
ekku
parents: 222
diff changeset
    58
    void removePhysicsObject (PhysicsObject *po);
22ecb9cb9245 Rope can be drawn.
ekku
parents: 222
diff changeset
    59
    
22ecb9cb9245 Rope can be drawn.
ekku
parents: 222
diff changeset
    60
    /**
197
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
    61
     * Advance one time step in physics simulation.
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
    62
     */
300
417183866f35 suicide key and respawning
terom
parents: 255
diff changeset
    63
    void tick (TimeMS tick_length);
197
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
    64
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
    65
    /**
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
    66
     * Get current tick in physics simulation.
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
    67
     *
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
    68
     * @return tick Current simulation tick.
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
    69
     */
300
417183866f35 suicide key and respawning
terom
parents: 255
diff changeset
    70
    TickCount getTicks (void);
197
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
    71
};
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
    72
d9ac888de778 Hajotetaan lis??
ekku
parents:
diff changeset
    73
#endif