![]() |
Dragonfly 2.2
A text-based game engine
|
Public Member Functions | |
int | startUp () |
Startup the game world (initialize everthing to empty). | |
void | shutDown () |
Shutdown the game world. | |
int | insertObject (GameObject *p_go) |
Add Object to world. | |
int | insertObject (ViewObject *p_vo) |
int | removeObject (GameObject *p_go) |
Remove Object from world. | |
int | removeObject (ViewObject *p_vo) |
ObjectList | getAllGameObjects (void) |
Return a list of all GameObjects in world. | |
ObjectList | getAllViewObjects (void) |
Return a list of all ViewObjects in world. | |
int | markForDelete (Object *p_o) |
Indicate object is to be deleted at end of current game loop. | |
void | update () |
Update world. | |
void | draw () |
Draw, sending draw event to all GameObjects in view. | |
int | moveGameObject (GameObject *p_go, Position where) |
Move GameObject. | |
ObjectList | isCollision (GameObject *p_go, Position where) |
Return list of GameObjects collided with at Position 'where'. | |
ObjectList | gameObjectsAtPosition (Position where) |
Return list of all GameObjects at Position 'where'. | |
ObjectList | gameObjectsInBox (Box box) |
Return list of all GameObjects in Box. | |
ObjectList | gameObjectsOnLine (Line line) |
Return a list of all GameObjects on line from point1 to point2. | |
ObjectList | gameObjectsInCircle (Circle circle) |
Return a list of all GameObjects in circle. | |
Box | getBoundary () |
Get game world boundary. | |
void | setBoundary (Box new_boundary) |
Set game world boundary. | |
Box | getView () |
Get camera view for game world. | |
void | setView (Box new_view) |
Set camera view for game world. | |
int | setViewFollowing (GameObject *p_new_view_following) |
Set camera view to center camera on GameObject. | |
void | setViewPosition (Position view_pos) |
Set camera view to center on Position view_pos. | |
int | getLevel () |
Return current game level. | |
int | setLevel (int new_level) |
Set game level. Return 0 if ok, else -1. | |
SceneGraph & | getSceneGraph () |
Return a reference to SceneGraph. | |
Static Public Member Functions | |
static WorldManager & | getInstance () |
Get the one and only instance of the WorldManager. | |
Protected Attributes | |
SceneGraph | scene_graph |
Storage for all objects, Game and View. | |
ObjectList | deletions |
List of all GameObjects to delete. | |
GameObject * | p_view_following |
GameObject view is following. | |
Box | boundary |
World boundaries. | |
Box | view |
Player window view. | |
Private Member Functions | |
WorldManager () | |
Private since a singleton. | |
WorldManager (WorldManager const &) | |
Don't allow copy. | |
void | operator= (WorldManager const &) |
Don't allow assignment. | |
Private Attributes | |
int | obj_id |
Next object id to assign. | |
int | next_level |
Next level to assign (0 no change). |
void WorldManager::draw | ( | ) |
Draw, sending draw event to all GameObjects in view.
Draw bottom up, from -MAX_ALTITUDE to MAX_ALTITUDE Draw ViewObjects last.
ObjectList WorldManager::gameObjectsAtPosition | ( | Position | where | ) |
Return list of all GameObjects at Position 'where'.
Does include bounding boxes. Return empty list if none found.
ObjectList WorldManager::gameObjectsInBox | ( | Box | box | ) |
Return list of all GameObjects in Box.
Does include bounding boxes. Return empty list if none found.
ObjectList WorldManager::gameObjectsInCircle | ( | Circle | circle | ) |
Return a list of all GameObjects in circle.
Does include bounding boxes. Return empty list if none found.
ObjectList WorldManager::gameObjectsOnLine | ( | Line | line | ) |
Return a list of all GameObjects on line from point1 to point2.
Does include bounding boxes. Return empty list if none found.
ObjectList WorldManager::getAllGameObjects | ( | void | ) |
Return a list of all GameObjects in world.
Return NULL if list is empty.
ObjectList WorldManager::getAllViewObjects | ( | void | ) |
Return a list of all ViewObjects in world.
Return NULL if list is empty.
int WorldManager::insertObject | ( | GameObject * | p_go | ) |
Add Object to world.
Return 0 if ok, else -1.
ObjectList WorldManager::isCollision | ( | GameObject * | p_go, |
Position | where | ||
) |
Return list of GameObjects collided with at Position 'where'.
Collisions only with solid GameObjects. Does not consider if p_go is solid or not.
int WorldManager::markForDelete | ( | Object * | p_o | ) |
Indicate object is to be deleted at end of current game loop.
Return 0 if ok, else -1.
int WorldManager::moveGameObject | ( | GameObject * | p_go, |
Position | where | ||
) |
Move GameObject.
If no collision with solid, move ok else don't move object. If p_go is Spectral, move ok. If move ok, adjust camera if following this GameObject. Return 0 if move ok, else -1 if collision with solid.
int WorldManager::removeObject | ( | GameObject * | p_go | ) |
Remove Object from world.
Return 0 if ok, else -1.
int WorldManager::setViewFollowing | ( | GameObject * | p_new_view_following | ) |
Set camera view to center camera on GameObject.
If p_new_view_following not legit, return -1 else return 0. Set to NULL to stop following.
void WorldManager::setViewPosition | ( | Position | view_pos | ) |
Set camera view to center on Position view_pos.
View edge will not go beyond world boundary.
int WorldManager::startUp | ( | ) | [virtual] |
void WorldManager::update | ( | ) |
Update world.
Send "step" event to all interested objects. Update positions of GameObjects based on their velocities. Update the SceneGraph for those marked for updates. Lastly, delete GameObjectsmarked for deletion.