home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 June / PCFJune.iso / Xenon / XenonSource.exe / demo2 / scene.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-13  |  3.0 KB  |  134 lines

  1. //-------------------------------------------------------------
  2. //
  3. // Class:    CScene
  4. //
  5. // Author:    John M Phillips
  6. //
  7. // Started:    06/05/00
  8. //
  9. // Base:    None
  10. //
  11. // Derived:    None
  12. //
  13. //-------------------------------------------------------------
  14.  
  15. #ifndef _INCLUDE_SCENE_H
  16. #define _INCLUDE_SCENE_H
  17.  
  18. #include "gamesystem.h"
  19. #include "actor.h"
  20.  
  21. //-------------------------------------------------------------
  22. // Image info for loading graphics
  23.  
  24. struct ImageInfo
  25. {
  26.     char *m_filename;            // file name
  27.     int m_tile_width;            // width of each tile
  28.     int m_tile_height;            // height of each tile
  29.     bool m_colour_key;            // if true use colour key
  30. };
  31.  
  32. //-------------------------------------------------------------
  33. // Entry in m_image_list
  34.  
  35. struct ImageEntry
  36. {
  37.     char m_filename[MAX_PATH];    // file name
  38.     gsCTiledImage m_image;        // the image itself
  39. };
  40.  
  41. //-------------------------------------------------------------
  42.  
  43. class CScene
  44. {
  45.     private:
  46.  
  47.         gsCList<CActor *> m_actor_list;
  48.         gsCList<ImageEntry *> m_image_list;
  49.         gsCCollisionList m_collision_list;
  50.         int m_frame_count;
  51.  
  52.         bool m_checkpoint_active;
  53.         gsCVector m_checkpoint;
  54.  
  55.         bool m_is_warping;
  56.  
  57.         void updateActorsOfType(ActorType type,Controls *controls);
  58.         void drawActorsOfType(ActorType type,int total);
  59.  
  60.         static void actorCollisionCallback(void *object1,void *object2);
  61.  
  62.         bool m_ship_is_cloaked;
  63.  
  64.     public:
  65.         CScene();
  66.         ~CScene();
  67.  
  68.         bool loadImages();
  69.         void setCollisionListSize(const gsCPoint& pixel_size,const gsCPoint& zone_size);
  70.         void updateAllActors(Controls *controls);
  71.         void drawAllActors();
  72.         void checkActorCollisions();
  73.         void killAllActors();
  74.         void removeDeadActors();
  75.         void destroyAll();
  76.         CActor *findNearestActor(ActorType type,const gsCVector& position,int dir);
  77.  
  78.         gsCTiledImage *getImage(const char *filename);
  79.         int getNumberOfImages();
  80.  
  81.         void addActor(CActor *actor);
  82.         void removeActor(CActor *actor);
  83.         
  84.         int getNumberOfActors();
  85.         CActor *getActor(int index);
  86.  
  87.         CShip *findShip();
  88.  
  89.         void addToCollisionList(CActor *actor,const gsCRect& rect);
  90. };
  91.  
  92. //-------------------------------------------------------------
  93.  
  94. inline int CScene::getNumberOfActors()
  95. {
  96.     return m_actor_list.getSize();
  97. }
  98.  
  99. //-------------------------------------------------------------
  100.  
  101. inline void CScene::addActor(CActor *actor)
  102. {
  103.     actor->setScene(this);
  104.     m_actor_list.addItem(actor);
  105. }
  106.  
  107. //-------------------------------------------------------------
  108.  
  109. inline void CScene::removeActor(CActor *actor)
  110. {
  111.     actor->setScene(0);
  112.     m_actor_list.removeItem(actor);
  113. }
  114.  
  115. //-------------------------------------------------------------
  116.  
  117. inline int CScene::getNumberOfImages()
  118. {
  119.     return m_image_list.getSize();
  120. }
  121.  
  122. //-------------------------------------------------------------
  123.  
  124. inline void CScene::setCollisionListSize(const gsCPoint& pixel_size,const gsCPoint& zones)
  125. {
  126.     m_collision_list.setSize(pixel_size,zones);
  127. }
  128.  
  129. //-------------------------------------------------------------
  130.  
  131. #endif
  132.  
  133.  
  134.