"Lost treasure of mBedungu" 100 level puzzle game for RETRO
Dependencies: LCD_ST7735 RetroPlatform mbed
Diff: Game/IntroScreen.cpp
- Revision:
- 0:f5f961973d01
- Child:
- 1:dcea5500a32d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Game/IntroScreen.cpp Sat Feb 21 06:19:29 2015 +0000 @@ -0,0 +1,121 @@ +#include "mbed.h" +#include "IntroScreen.h" +#include "Sprites.h" +//#include "font_OEM.h" + +#include "Retro.h" + + +char title[] = { + "@SOMEWHERE@IN@SOUTH@\r\n" \ + "@@@@@@@AMERICA@@@@@@" +}; + +char text1[] = { + "RICK@IS@ON@A@MISSION\r\n" \ + "@@TO@FIND@100@LOST@@\r\n" \ + "@@@@TOTEMS@OF@THE@@@\r\n" \ + "@@@MBEDUNGU@TRIBE@@@" +}; + +char text2[] = { + "THE@LEGEND@SAIS@THAT\r\n" \ + "@@@THE@TOTEMS@ARE@@@\r\n" \ + "@@@@HIDDEN@IN@AN@@@@\r\n" \ + "@@UNDERGROUND@MAZE@@" +}; + +char text3[] = { + "FINDING@THE@ENTRANCE\r\n" \ + "TO@THE@MAZE@WAS@EASY\r\n" \ + "@@@BUT@WHAT@AWAITS@@\r\n" \ + "@@@@@@@AHEAD?@@@@@@@" +}; + +char * texts[] = { + text1, + text2, + text3 +}; + +extern Retro retro; + +IntroScreen::IntroScreen() +{ + _state = 0; +} + +char * pText = text1; +int curText = 0; +int y = 80; +int x = 0; +int frame = 0; +Screen IntroScreen::Update() +{ + if( _state == 0 ) { + retro.display.clearScreen(); + drawString(0,0, title); + _state = 1; + pText = text1; + curText = 0; + y=80; + x=0; + frame = 0; + + retro.display.fillRect(0,80,159,127,0); + + } else if( _state == 1 ) { + frame++; + + if( (frame % 2) == 0 ) { + + frame = 0; + + if( *pText != 0 ) { + +// while( *pText++ == '@' ) +// x+=8; + + if( *pText == 13 ) { + x = 0; + pText++; + } else if( *pText == 10 ) { + y += 8; + pText++; + } else { + drawChar(x, y, *pText++); + x+=8; + } + } else + _state = 2; + } + } + + if(retro.buttons.pressed(BTN_ROBOT)) { + _state = 0; + return Game; + + } + + if(retro.buttons.pressed(BTN_SHIP)) { + if( _state == 1 ) { + drawString(0, 80, texts[curText]); + _state = 2; + } else if( _state == 2 ) { + if( curText < 2 ) { + curText++; + pText = texts[curText]; + y=80; + x=0; + frame = 0; + _state = 1; + retro.display.fillRect(0,80,159,127,0); + } else { + _state = 0; + return Game; + } + } + } + + return Intro; +} \ No newline at end of file