Version of Robotron arcade game using LPC1768, a Gameduino shield, a serial EEPROM (for high scores), two microswitch joysticks and two buttons plus a box to put it in. 20 levels of mayhem.
Dependencies: 25LCxxx_SPI CommonTypes Gameduino mbed
Level0.cpp@0:5fa232ee5fdf, 2013-06-04 (annotated)
- Committer:
- RichardE
- Date:
- Tue Jun 04 20:16:33 2013 +0000
- Revision:
- 0:5fa232ee5fdf
- Child:
- 1:dfd5eaaf96a3
Started conversion from Maple version of game. So far Gameduino seems to have been initialised OK and just displays a sign on message. Lots of commented out code.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
RichardE | 0:5fa232ee5fdf | 1 | /* |
RichardE | 0:5fa232ee5fdf | 2 | * SOURCE FILE : Level0.cpp |
RichardE | 0:5fa232ee5fdf | 3 | * |
RichardE | 0:5fa232ee5fdf | 4 | * Definition of class Level0. |
RichardE | 0:5fa232ee5fdf | 5 | * |
RichardE | 0:5fa232ee5fdf | 6 | */ |
RichardE | 0:5fa232ee5fdf | 7 | |
RichardE | 0:5fa232ee5fdf | 8 | #include "Level0.h" |
RichardE | 0:5fa232ee5fdf | 9 | #if 0 |
RichardE | 0:5fa232ee5fdf | 10 | #include "CharBlocks.h" |
RichardE | 0:5fa232ee5fdf | 11 | #include "EEPROMDump.h" |
RichardE | 0:5fa232ee5fdf | 12 | #endif |
RichardE | 0:5fa232ee5fdf | 13 | |
RichardE | 0:5fa232ee5fdf | 14 | /***************/ |
RichardE | 0:5fa232ee5fdf | 15 | /* CONSTRUCTOR */ |
RichardE | 0:5fa232ee5fdf | 16 | /***************/ |
RichardE | 0:5fa232ee5fdf | 17 | Level0::Level0() { |
RichardE | 0:5fa232ee5fdf | 18 | } |
RichardE | 0:5fa232ee5fdf | 19 | |
RichardE | 0:5fa232ee5fdf | 20 | /**************/ |
RichardE | 0:5fa232ee5fdf | 21 | /* DESTRUCTOR */ |
RichardE | 0:5fa232ee5fdf | 22 | /**************/ |
RichardE | 0:5fa232ee5fdf | 23 | Level0::~Level0() { |
RichardE | 0:5fa232ee5fdf | 24 | } |
RichardE | 0:5fa232ee5fdf | 25 | |
RichardE | 0:5fa232ee5fdf | 26 | /**************/ |
RichardE | 0:5fa232ee5fdf | 27 | /* PLAY LEVEL */ |
RichardE | 0:5fa232ee5fdf | 28 | /**************/ |
RichardE | 0:5fa232ee5fdf | 29 | // Returns code indicating how level ended. |
RichardE | 0:5fa232ee5fdf | 30 | Level::LevelExitCode Level0::Play( void ) { |
RichardE | 0:5fa232ee5fdf | 31 | return PlayLoop(); |
RichardE | 0:5fa232ee5fdf | 32 | } |
RichardE | 0:5fa232ee5fdf | 33 | |
RichardE | 0:5fa232ee5fdf | 34 | static const char startText[] = "OPERATE EITHER JOYSTICK TO START GAME"; |
RichardE | 0:5fa232ee5fdf | 35 | |
RichardE | 0:5fa232ee5fdf | 36 | /********************/ |
RichardE | 0:5fa232ee5fdf | 37 | /* DRAW HIGH SCORES */ |
RichardE | 0:5fa232ee5fdf | 38 | /********************/ |
RichardE | 0:5fa232ee5fdf | 39 | void Level0::DrawHighScores( void ) { |
RichardE | 0:5fa232ee5fdf | 40 | #if 0 |
RichardE | 0:5fa232ee5fdf | 41 | // Draw high score table. |
RichardE | 0:5fa232ee5fdf | 42 | GDExtra::WriteProgString( 16, 11, StringData::HighScoresString ); |
RichardE | 0:5fa232ee5fdf | 43 | PlayerName name; |
RichardE | 0:5fa232ee5fdf | 44 | UInt32 score; |
RichardE | 0:5fa232ee5fdf | 45 | UInt8 y = 13; |
RichardE | 0:5fa232ee5fdf | 46 | for( UInt8 i = 0; i < highScores->GetCapacity(); ++i ) { |
RichardE | 0:5fa232ee5fdf | 47 | highScores->Get( i, &name, &score ); |
RichardE | 0:5fa232ee5fdf | 48 | GD.putstr( 18, y, name.Name ); |
RichardE | 0:5fa232ee5fdf | 49 | GDExtra::WriteBCDNumber( 22, y, score, 8 ); |
RichardE | 0:5fa232ee5fdf | 50 | y += 2; |
RichardE | 0:5fa232ee5fdf | 51 | } |
RichardE | 0:5fa232ee5fdf | 52 | #endif |
RichardE | 0:5fa232ee5fdf | 53 | } |
RichardE | 0:5fa232ee5fdf | 54 | |
RichardE | 0:5fa232ee5fdf | 55 | /*************/ |
RichardE | 0:5fa232ee5fdf | 56 | /* PLAY LOOP */ |
RichardE | 0:5fa232ee5fdf | 57 | /*************/ |
RichardE | 0:5fa232ee5fdf | 58 | // Returns code indicating how level ended. |
RichardE | 0:5fa232ee5fdf | 59 | // This method should be called from the Play method after the |
RichardE | 0:5fa232ee5fdf | 60 | // level data has been initialised and the return value returned |
RichardE | 0:5fa232ee5fdf | 61 | // by the Play method. |
RichardE | 0:5fa232ee5fdf | 62 | Level::LevelExitCode Level0::PlayLoop( void ) { |
RichardE | 0:5fa232ee5fdf | 63 | #if 0 |
RichardE | 0:5fa232ee5fdf | 64 | // Set screen background to black. |
RichardE | 0:5fa232ee5fdf | 65 | GD.wr( BG_COLOR, RGB( 0, 0, 0 ) ); |
RichardE | 0:5fa232ee5fdf | 66 | GDExtra::ClearScreen( TransparentChar ); |
RichardE | 0:5fa232ee5fdf | 67 | GDExtra::HideAllSprites(); |
RichardE | 0:5fa232ee5fdf | 68 | SoundManager::Instance.SilenceAll(); |
RichardE | 0:5fa232ee5fdf | 69 | // Draw border around screen. |
RichardE | 0:5fa232ee5fdf | 70 | CharFrame::Draw( 0, 0, VISIBLE_CHAR_WIDTH, VISIBLE_CHAR_HEIGHT ); |
RichardE | 0:5fa232ee5fdf | 71 | // Draw big block of characters that read "ROBOTRIC". |
RichardE | 0:5fa232ee5fdf | 72 | GDExtra::WriteProgCharBlock( 2, 2, CharBlocks::RobotRicText ); |
RichardE | 0:5fa232ee5fdf | 73 | // Write message telling user how to start game. |
RichardE | 0:5fa232ee5fdf | 74 | GDExtra::WriteProgString( 2, VISIBLE_CHAR_HEIGHT - 3, startText ); |
RichardE | 0:5fa232ee5fdf | 75 | // Validate high scores in EEPROM which will re-write the entire |
RichardE | 0:5fa232ee5fdf | 76 | // table with default data if it finds nonsense in the EEPROM. |
RichardE | 0:5fa232ee5fdf | 77 | // Then check if EEPROM now makes sense. If it does then display |
RichardE | 0:5fa232ee5fdf | 78 | // the high score table. If it does not then chances are there |
RichardE | 0:5fa232ee5fdf | 79 | // is no EEPROM connected so don't bother with high scores. |
RichardE | 0:5fa232ee5fdf | 80 | if( highScores != (HighScoreTable*)NULL ) { |
RichardE | 0:5fa232ee5fdf | 81 | highScores->ValidateEEPROM(); |
RichardE | 0:5fa232ee5fdf | 82 | if( highScores->EEPROMValid() ) { |
RichardE | 0:5fa232ee5fdf | 83 | DrawHighScores(); |
RichardE | 0:5fa232ee5fdf | 84 | } |
RichardE | 0:5fa232ee5fdf | 85 | } |
RichardE | 0:5fa232ee5fdf | 86 | // Must have a player with non-NULL controls. |
RichardE | 0:5fa232ee5fdf | 87 | PanelControls *controls; |
RichardE | 0:5fa232ee5fdf | 88 | if( |
RichardE | 0:5fa232ee5fdf | 89 | ( player != (PlayerObject*)NULL ) && |
RichardE | 0:5fa232ee5fdf | 90 | ( ( controls = player->GetControls() ) != (PanelControls*)NULL ) |
RichardE | 0:5fa232ee5fdf | 91 | ) { |
RichardE | 0:5fa232ee5fdf | 92 | // Wait until all panel controls are released. |
RichardE | 0:5fa232ee5fdf | 93 | UInt16 inputs; |
RichardE | 0:5fa232ee5fdf | 94 | do { |
RichardE | 0:5fa232ee5fdf | 95 | controls->Read(); |
RichardE | 0:5fa232ee5fdf | 96 | inputs = controls->GetInputs(); |
RichardE | 0:5fa232ee5fdf | 97 | } while( inputs != 0 ); |
RichardE | 0:5fa232ee5fdf | 98 | // Wait until a panel control is activated. |
RichardE | 0:5fa232ee5fdf | 99 | do { |
RichardE | 0:5fa232ee5fdf | 100 | controls->Read(); |
RichardE | 0:5fa232ee5fdf | 101 | inputs = controls->GetInputs(); |
RichardE | 0:5fa232ee5fdf | 102 | } while( inputs == 0 ); |
RichardE | 0:5fa232ee5fdf | 103 | } |
RichardE | 0:5fa232ee5fdf | 104 | #endif |
RichardE | 0:5fa232ee5fdf | 105 | return Completed; |
RichardE | 0:5fa232ee5fdf | 106 | } |
RichardE | 0:5fa232ee5fdf | 107 |