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

  1. //-------------------------------------------------------------
  2. //
  3. // Program:    Demo 2
  4. //
  5. // Author:    John M Phillips
  6. //
  7. // Started:    20/08/00
  8. //
  9. // Remarks:    This is a simple demo program using the GameSystem library
  10. //            which draws a spaceship which you can move around with the
  11. //            cursor keys, and fire missiles with the space bar.
  12. //
  13. //-------------------------------------------------------------
  14.  
  15. #include "demo2.h"
  16.  
  17. //-------------------------------------------------------------
  18. // Create an instance of the application class
  19. // GameSystem will run this automatically
  20.  
  21. CDemo2 myApp("Demo 2");
  22.  
  23. //-------------------------------------------------------------
  24.  
  25. bool CDemo2::changeState(CGameState *new_game_state)
  26. {
  27.     if (m_game_state) {
  28.         if (!m_game_state->destroy())
  29.             return false;
  30.         }
  31.  
  32.     m_game_state = new_game_state;
  33.  
  34.     if (m_game_state)
  35.         return m_game_state->create();
  36.  
  37.     return true;
  38. }
  39.  
  40. //-------------------------------------------------------------
  41. // Initialize the demo
  42. //
  43. // Return: true if successful
  44.  
  45. bool CDemo2::initialize()
  46. {
  47.     if (!gsCApplication::initialize())
  48.         return false;
  49.  
  50.     if (!CGameState::initialize(this))
  51.         return false;
  52.  
  53.     return true;
  54. }
  55.  
  56. //-------------------------------------------------------------
  57.  
  58. bool CDemo2::mainloop()
  59. {
  60.     if (m_game_state)
  61.         return m_game_state->update();
  62.  
  63.     return false;
  64. }
  65.  
  66. //-------------------------------------------------------------
  67.  
  68. bool CDemo2::shutdown()
  69. {
  70.     changeState(0);
  71.  
  72.     if (!CGameState::shutdown())
  73.         return false;
  74.  
  75.     if (!gsCApplication::shutdown())
  76.         return false;
  77.  
  78.     return true;
  79. }
  80.  
  81. //-------------------------------------------------------------
  82.