Initial publish
Dependencies: mbed
Fork of el17dg by
Diff: main/main.cpp
- Revision:
- 32:5403bb974294
- Parent:
- 31:becb8f6bf7b7
- Child:
- 34:754915ce9de5
--- a/main/main.cpp Tue Apr 23 18:18:57 2019 +0000 +++ b/main/main.cpp Fri Apr 26 13:09:03 2019 +0000 @@ -41,20 +41,13 @@ void setupIntroValues(); void updateAndDrawIntroPartOne(); void updateAndDrawIntroPartTwo(); +void introMusic(int low_frequency_music_counter); void introPartOneText(); void intro(); -void pointer(int x, int y); -void pointer_position(int menu_number); -void ship_movement(); void menuSelection(); -void introMusic(); ScreenOption current_screen = ScreenOption_Menu; -int low_frequency_music_counter = 0; - -void intro(); - int main(){ lcd.init(); gamepad.init(); @@ -71,8 +64,8 @@ } void intro(){ + int start_game_text_counter = 0; setupIntroValues(); - int start_game_text_counter = 0; updateAndDrawIntroPartOne(); updateAndDrawIntroPartTwo(); wait(1); @@ -86,7 +79,6 @@ if (start_game_text_counter == 4){start_game_text_counter = 0;} } start_game_text_counter += 1; - lcd.refresh(); } } @@ -104,8 +96,6 @@ lineThree.pos.x = 2; lineThree.pos.y = screen_height; // Starting outside the screen limits on the botto - the screen's height + the sprite's height. - - } void updateAndDrawIntroPartOne(){ @@ -119,7 +109,6 @@ if (lineTwoShips.pos.x < 0){ lineTwoShips.pos.x += 1; } introPartOneText(); - //introMusic(); gamepad.tone(200,2); lcd.refresh(); @@ -128,6 +117,7 @@ } void updateAndDrawIntroPartTwo(){ + int low_frequency_music_counter = 0; for (int i = 0; i < 19 + 3; i++){ lcd.clear(); lineThree.pos.y -= 1; @@ -135,7 +125,8 @@ drawSprite(lineThree.pos, intro_line_three_sprite); lcd.refresh(); wait(0.1); - introMusic(); + introMusic(low_frequency_music_counter); + low_frequency_music_counter++; } } /**@brief @@ -152,25 +143,19 @@ void menuSelection(){ if (current_screen == ScreenOption_Game) { bool game_is_paused = game.updateAndDraw(); - if (game_is_paused) { - current_screen = ScreenOption_Menu; - } - } - if (current_screen == ScreenOption_Tutorial) { - bool back_to_menu = tutorial.updateAndWriteTutorial(); + if (game_is_paused) { current_screen = ScreenOption_Menu;} + } if (current_screen == ScreenOption_Tutorial) { + bool back_to_menu = tutorial.updateAndWriteTutorial(); if (back_to_menu) { current_screen = ScreenOption_Menu; } - } - if (current_screen == ScreenOption_Settings) { + } if (current_screen == ScreenOption_Settings) { bool back_to_menu = settings.updateAndWriteSettings(); - if (back_to_menu) { current_screen = ScreenOption_Menu; } - } - else if (current_screen == ScreenOption_Menu) { + } else if (current_screen == ScreenOption_Menu) { bool wantsToChangeScreen = menu.updateAndDraw(); if (wantsToChangeScreen) { current_screen = menu.getCurrentScreenSelection(); @@ -178,7 +163,7 @@ } } -void introMusic(){ +void introMusic(int low_frequency_music_counter){ if (low_frequency_music_counter == 0){ gamepad.tone(90,2);} else if (low_frequency_music_counter == 2){gamepad.tone(60,2);} else if (low_frequency_music_counter == 4){gamepad.tone(190,2);} @@ -189,5 +174,4 @@ gamepad.tone(90,1); low_frequency_music_counter = 0; } - low_frequency_music_counter++; } \ No newline at end of file