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

  1. //-------------------------------------------------------------
  2. //
  3. // Class:    CScoreEntryState
  4. //
  5. // Author:    John M Phillips
  6. //
  7. // Started:    06/05/00
  8. //
  9. // Base:    CGameState
  10. //
  11. // Derived:    None
  12. //
  13. //-------------------------------------------------------------
  14.  
  15. #include "game.h"
  16.  
  17. //-------------------------------------------------------------
  18.  
  19. CScoreEntryState *CScoreEntryState::m_instance = 0;
  20.  
  21. char *CScoreEntryState::m_congratulation_messages[] = {
  22.     "That's the best score today !",
  23.     "Almost the best score today !",
  24.     "You're in the top three !",
  25.     "An above average performance !",
  26.     "An average performance !",
  27.     "A below average performance !",
  28.     "A fairly good score !",
  29.     "At least you're not last !",
  30.     "You made the grade (just)",
  31.     "You'll have to try harder !!",
  32. };
  33.  
  34. //-------------------------------------------------------------
  35.  
  36. CScoreEntryState::CScoreEntryState()
  37. {
  38. }
  39.  
  40. //-------------------------------------------------------------
  41.  
  42. CScoreEntryState::~CScoreEntryState()
  43. {
  44. }
  45.  
  46. //-------------------------------------------------------------
  47.  
  48. CGameState *CScoreEntryState::instance()
  49. {
  50.     if (!m_instance)
  51.         m_instance = new CScoreEntryState;
  52.  
  53.     return m_instance;
  54. }
  55.  
  56. //-------------------------------------------------------------
  57.  
  58. bool CScoreEntryState::create()
  59. {
  60.     stopSamples();
  61.     playMusic(MUSIC_HISCORE);
  62.  
  63.     return true;
  64. }
  65.  
  66. //-------------------------------------------------------------
  67.  
  68. bool CScoreEntryState::update()
  69. {
  70.     if (!CGameState::update())
  71.         return false;
  72.  
  73.     if (Options.getOption(OPTION_BACKDROP))
  74.         m_backdrop.draw(gsCPoint(0,0));
  75.     else
  76.         m_screen.clear(gsCColour(gsBLACK));
  77.  
  78.     m_starfield.move(4);
  79.     m_starfield.draw();
  80.  
  81.     char *m = m_congratulation_messages[m_score_table.getCurrentItem()];
  82.  
  83.     m_medium_font.setTextCursor(gsCPoint(0,50));
  84.     m_medium_font.justifyString(m);
  85.  
  86.     m_score_table.draw();
  87.  
  88.     m_medium_font.setTextCursor(gsCPoint(0,400));
  89.     m_medium_font.justifyString("Use Movement Keys To Enter Your Name");
  90.     m_medium_font.setTextCursor(gsCPoint(0,430));
  91.     m_medium_font.justifyString("Press Fire To Exit To Main Menu");
  92.  
  93.     m_screen.flip();
  94.     
  95.     switch (getKey()) {
  96.         case gsKEY_RETURN:
  97.         case gsKEY_ENTER:
  98.         case gsKEY_LCONTROL:
  99.             playSample(SAMPLE_MENU_BACK);
  100.             return changeState(CMainMenuState::instance());
  101.         case gsKEY_UP:
  102.             playSample(SAMPLE_MENU_OPTION);
  103.             m_score_table.cycleLetter(1);
  104.             break;
  105.         case gsKEY_DOWN:
  106.             playSample(SAMPLE_MENU_OPTION);
  107.             m_score_table.cycleLetter(-1);
  108.             break;
  109.         case gsKEY_LEFT:
  110.             playSample(SAMPLE_MENU_SELECTION);
  111.             m_score_table.scrollLetter(-1);
  112.             break;
  113.         case gsKEY_RIGHT:
  114.             playSample(SAMPLE_MENU_SELECTION);
  115.             m_score_table.scrollLetter(1);
  116.             break;
  117.         }
  118.  
  119.     if (m_sound_system.isMusicFinished())
  120.         playMusic(MUSIC_HISCORE);
  121.  
  122.     return true;
  123. }
  124.  
  125. //-------------------------------------------------------------
  126.