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

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