Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of el17dg by
Diff: main/main.cpp
- Revision:
- 24:0570cb4b92d7
- Parent:
- 23:240bc00ef25b
- Child:
- 26:676874c42883
--- a/main/main.cpp Sun Mar 31 01:04:59 2019 +0000 +++ b/main/main.cpp Tue Apr 02 15:38:40 2019 +0000 @@ -14,6 +14,7 @@ #include "game.h" #include "menu.h" #include "models.h" +#include "tutorial.h" @@ -28,6 +29,7 @@ Menu menu; Game game; +Tutorial tutorial; struct IntroMove { int x; @@ -40,17 +42,13 @@ IntroMove lineTwoShips; IntroMove lineThree; - -//static const unsigned int MAX_LINE_LENGTH = 14; - - +void updateAndDrawIntroPartOne(); +void updateAndDrawIntroPartTwo(); +void introPartOneText(); void intro(); void pointer(int x, int y); void pointer_position(int menu_number); void ship_movement(); -//char line_buffer[MAX_LINE_LENGTH]; - - ScreenOption current_screen = ScreenOption_Menu; @@ -73,6 +71,13 @@ current_screen = ScreenOption_Menu; } } + if (current_screen == ScreenOption_Tutorial) { + bool back_to_menu = tutorial.updateAndWriteTutorial(); + + if (back_to_menu) { + current_screen = ScreenOption_Menu; + } + } else if (current_screen == ScreenOption_Menu) { bool wantsToChangeScreen = menu.updateAndDraw(); if (wantsToChangeScreen) { @@ -99,45 +104,62 @@ lineThree.x = 2; lineThree.y = screen_height; // Starting outside the screen limits on the botto - the screen's height + the sprite's height. + int start_game_text_counter = 0; + + updateAndDrawIntroPartOne(); + updateAndDrawIntroPartTwo(); + + //Stop just a few pixels above the bottom screen border. + while (!gamepad.check_event(gamepad.START_PRESSED)){ + //DOES NOT WORK. + if (start_game_text_counter == 1){ + lcd.printString("Press START",0,0); + start_game_text_counter = 0; + + } + start_game_text_counter += 1; + } + +} + + +void updateAndDrawIntroPartOne(){ // the width of the line one + 2. for (int i = 0; i < 65; i++){ lcd.clear(); lineOne.x +=1; - if (lineOneStars.x > 70){ - lineOneStars.x -= 1; - } + if (lineOneStars.x > 70){ lineOneStars.x -= 1; } // to stop moving at the position of its width. - if (lineTwo.x > screen_width - 30){// - lineTwo.x -=1; - } - if ( lineTwoShips.x < 0){ - lineTwoShips.x += 1; - } + if (lineTwo.x > screen_width - 30){ lineTwo.x -=1; } + if ( lineTwoShips.x < 0){ lineTwoShips.x += 1; } - lcd.drawSprite(lineOne.x, lineOne.y, 11, 63, (int*)introLineOne); - lcd.drawSprite(lineOneStars.x, lineOneStars.y, 13, 12, (int*)introLineOneStars); - lcd.drawSprite(lineTwo.x, lineTwo.y, 11, 30, (int*)introLineTwo); - lcd.drawSprite(lineTwoShips.x, lineTwoShips.y, 10, 46, (int*)introLineTwoShips); + introPartOneText(); lcd.refresh(); wait(0.01); } - - //Stop just a few pixels above the bottom screen border. +} + +void updateAndDrawIntroPartTwo(){ for (int i = 0; i < 19 + 3; i++){ lcd.clear(); - lcd.drawSprite(lineOne.x, lineOne.y, 11, 63, (int*)introLineOne); - lcd.drawSprite(lineOneStars.x, lineOneStars.y, 13, 12, (int*)introLineOneStars); - lcd.drawSprite(lineTwo.x, lineTwo.y, 11, 30, (int*)introLineTwo); - lcd.drawSprite(lineTwoShips.x, lineTwoShips.y, 10, 46, (int*)introLineTwoShips); - + introPartOneText(); lcd.drawSprite(lineThree.x, lineThree.y - i, 19, 78, (int*)introLineThree); lcd.refresh(); wait(0.1); } - while (!gamepad.check_event(gamepad.START_PRESSED)){ - } + +} +/**@brief + * I have put the upper part of the intro into a separate function because it + * it is being called several times in this file + */ +void introPartOneText(){ + lcd.drawSprite(lineOne.x, lineOne.y, 11, 63, (int*)introLineOne); + lcd.drawSprite(lineOneStars.x, lineOneStars.y, 13, 12, (int*)introLineOneStars); + lcd.drawSprite(lineTwo.x, lineTwo.y, 11, 30, (int*)introLineTwo); + lcd.drawSprite(lineTwoShips.x, lineTwoShips.y, 10, 46, (int*)introLineTwoShips); } \ No newline at end of file