Claypool

Courses

Publications

Students

Projects

Service

Downloads

Misc


Dragonfly: SceneGraph.h Source File
Dragonfly 2.2
A text-based game engine

SceneGraph.h

00001 //
00002 // SceneGraph.h
00003 //
00004 
00005 #ifndef __SCENE_GRAPH_H__
00006 #define __SCENE_GRAPH_H__
00007 
00008 #include "GameObject.h"
00009 #include "ObjectList.h"
00010 #include "ViewObject.h"
00011 
00012 #define MAX_ALTITUDE 4
00013 #define MAX_LEVEL 10  // objects on level 0 are persistent
00014 
00015 class SceneGraph {
00016 
00017  protected:
00018   int level;                    ///< "Level" the game is on
00019   ObjectList game_objects[MAX_LEVEL+1];
00020   ObjectList solid_game_objects[MAX_LEVEL+1];
00021   ObjectList visible_game_objects[MAX_LEVEL+1][MAX_ALTITUDE+1];
00022   ObjectList view_objects[MAX_LEVEL+1];
00023   ObjectList visible_view_objects[MAX_LEVEL+1];
00024 
00025  public:
00026   SceneGraph();
00027   ~SceneGraph();
00028 
00029   /// Insert/remove objects
00030   int removeObject(GameObject *p_go);
00031   int removeObject(ViewObject *p_vo);
00032   int insertObject(GameObject *p_go);
00033   int insertObject(ViewObject *p_vo);
00034 
00035   /// Return GameObjects. Empty list if none.
00036   ObjectList gameObjects();
00037   ObjectList solidGameObjects();
00038   ObjectList visibleGameObjects(int altitude);
00039 
00040   /// Return ViewObjects. Empty list if none.
00041   ObjectList viewObjects();
00042   ObjectList visibleViewObjects();
00043 
00044   /// Return current game level.
00045   int getLevel();
00046 
00047   /// Set game level. Return 0 if ok, else -1.
00048   int setLevel(int new_level);
00049 
00050   /// Re-position object in SceneGraph to new altitude.
00051   /// Return 0 if ok, else -1.
00052   int updateAltitude(GameObject *p_go, int new_alt);
00053 
00054   // Re-position object in SceneGraph based on properties.
00055   // Return 0 if ok, else -1.
00056   int updateSolidness(GameObject *p_go, Solidness new_solidness);
00057   int updateVisibility(ViewObject *p_go, bool new_visibility);
00058   int updateVisibility(GameObject *p_vo, bool new_visibility);
00059   int updatePersistence(GameObject *p_go, bool new_persistence);
00060   int updatePersistence(ViewObject *p_vo, bool new_persistence);
00061 };
00062 
00063 #endif // __SCENE_GRAPH_H__
00064 
00065 
 All Classes Functions Variables Friends