Lewis Cheadle 201245660
Dependencies: mbed
StartMenu/StartMenu.cpp@13:fd290d2fd917, 2020-05-26 (annotated)
- Committer:
- ll17lrc
- Date:
- Tue May 26 22:41:23 2020 +0000
- Revision:
- 13:fd290d2fd917
- Parent:
- 12:299479b6bb59
Final Submission. I have read and agreed with Statement of Academic Integrity.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ll17lrc | 12:299479b6bb59 | 1 | #include "StartMenu.h" |
ll17lrc | 2:823dea76ff2e | 2 | |
ll17lrc | 2:823dea76ff2e | 3 | StartMenu::StartMenu() |
ll17lrc | 2:823dea76ff2e | 4 | { |
ll17lrc | 2:823dea76ff2e | 5 | |
ll17lrc | 2:823dea76ff2e | 6 | } |
ll17lrc | 2:823dea76ff2e | 7 | |
ll17lrc | 2:823dea76ff2e | 8 | StartMenu::~StartMenu() |
ll17lrc | 2:823dea76ff2e | 9 | { |
ll17lrc | 2:823dea76ff2e | 10 | |
ll17lrc | 2:823dea76ff2e | 11 | } |
ll17lrc | 2:823dea76ff2e | 12 | |
ll17lrc | 13:fd290d2fd917 | 13 | //start menu |
ll17lrc | 4:a9d5fca3b7ba | 14 | void StartMenu::complete(Gamepad &pad,N5110 &lcd) |
ll17lrc | 2:823dea76ff2e | 15 | { |
ll17lrc | 3:4494e6928194 | 16 | |
ll17lrc | 4:a9d5fca3b7ba | 17 | ImpossEngine imposs; |
ll17lrc | 4:a9d5fca3b7ba | 18 | |
ll17lrc | 13:fd290d2fd917 | 19 | //stores position of the pointer |
ll17lrc | 3:4494e6928194 | 20 | int selector = 1; |
ll17lrc | 3:4494e6928194 | 21 | |
ll17lrc | 13:fd290d2fd917 | 22 | //sprite to store the arrow used as an indicator on the menu |
ll17lrc | 3:4494e6928194 | 23 | int arrow[7][5] = { |
ll17lrc | 3:4494e6928194 | 24 | {0,0,0,0,0}, |
ll17lrc | 3:4494e6928194 | 25 | {1,1,0,0,0}, |
ll17lrc | 3:4494e6928194 | 26 | {1,1,1,1,0}, |
ll17lrc | 3:4494e6928194 | 27 | {1,1,1,1,1}, |
ll17lrc | 3:4494e6928194 | 28 | {1,1,1,1,0}, |
ll17lrc | 3:4494e6928194 | 29 | {1,1,0,0,0}, |
ll17lrc | 3:4494e6928194 | 30 | {0,0,0,0,0}, |
ll17lrc | 3:4494e6928194 | 31 | }; |
ll17lrc | 3:4494e6928194 | 32 | |
ll17lrc | 13:fd290d2fd917 | 33 | //displays start menu until A is pressed |
ll17lrc | 2:823dea76ff2e | 34 | while( pad.A_pressed() == false ){ |
ll17lrc | 2:823dea76ff2e | 35 | |
ll17lrc | 13:fd290d2fd917 | 36 | //draws the start menu |
ll17lrc | 2:823dea76ff2e | 37 | lcd.clear(); |
ll17lrc | 12:299479b6bb59 | 38 | lcd.printString(" IMPOSSIBLE ",0,1); |
ll17lrc | 12:299479b6bb59 | 39 | lcd.printString(" Start Game ",0,3); |
ll17lrc | 12:299479b6bb59 | 40 | lcd.printString(" How to play ",0,4); |
ll17lrc | 12:299479b6bb59 | 41 | lcd.drawSprite(5,16 + (selector * 8),7,5,(int *)arrow); |
ll17lrc | 2:823dea76ff2e | 42 | lcd.refresh(); |
ll17lrc | 2:823dea76ff2e | 43 | |
ll17lrc | 2:823dea76ff2e | 44 | wait(0.15); |
ll17lrc | 2:823dea76ff2e | 45 | |
ll17lrc | 13:fd290d2fd917 | 46 | //updates the position of the indicator |
ll17lrc | 2:823dea76ff2e | 47 | if( pad.get_direction() == S ){ |
ll17lrc | 11:7a4abe731f9c | 48 | if( selector < 2 ){ |
ll17lrc | 2:823dea76ff2e | 49 | selector ++; |
ll17lrc | 2:823dea76ff2e | 50 | } |
ll17lrc | 2:823dea76ff2e | 51 | } |
ll17lrc | 13:fd290d2fd917 | 52 | //updates the position of the indicator |
ll17lrc | 2:823dea76ff2e | 53 | if( pad.get_direction() == N ){ |
ll17lrc | 2:823dea76ff2e | 54 | if( selector > 1 ){ |
ll17lrc | 2:823dea76ff2e | 55 | selector --; |
ll17lrc | 2:823dea76ff2e | 56 | } |
ll17lrc | 2:823dea76ff2e | 57 | } |
ll17lrc | 10:df6a496270be | 58 | } |
ll17lrc | 13:fd290d2fd917 | 59 | |
ll17lrc | 13:fd290d2fd917 | 60 | //starts the game |
ll17lrc | 2:823dea76ff2e | 61 | if( selector == 1 ){ |
ll17lrc | 13:fd290d2fd917 | 62 | imposs.set_level_zero(); |
ll17lrc | 2:823dea76ff2e | 63 | } |
ll17lrc | 13:fd290d2fd917 | 64 | |
ll17lrc | 13:fd290d2fd917 | 65 | //explains how the game works, each screen is displayed until A is pressed |
ll17lrc | 2:823dea76ff2e | 66 | if( selector == 2 ){ |
ll17lrc | 11:7a4abe731f9c | 67 | wait(0.15); |
ll17lrc | 11:7a4abe731f9c | 68 | while(pad.A_pressed() == false){ |
ll17lrc | 11:7a4abe731f9c | 69 | lcd.clear(); |
ll17lrc | 11:7a4abe731f9c | 70 | lcd.printString("Use the ",0,0); |
ll17lrc | 11:7a4abe731f9c | 71 | lcd.printString("joystick to ",0,1); |
ll17lrc | 11:7a4abe731f9c | 72 | lcd.printString("move the ball.",0,2); |
ll17lrc | 11:7a4abe731f9c | 73 | lcd.drawSprite(70,40,7,5,(int *)arrow); |
ll17lrc | 11:7a4abe731f9c | 74 | lcd.refresh(); |
ll17lrc | 11:7a4abe731f9c | 75 | } |
ll17lrc | 11:7a4abe731f9c | 76 | while(pad.A_pressed() == false){ |
ll17lrc | 11:7a4abe731f9c | 77 | wait(0.15); |
ll17lrc | 11:7a4abe731f9c | 78 | lcd.clear(); |
ll17lrc | 11:7a4abe731f9c | 79 | lcd.printString("Press A to ",0,0); |
ll17lrc | 11:7a4abe731f9c | 80 | lcd.printString("double your ",0,1); |
ll17lrc | 11:7a4abe731f9c | 81 | lcd.printString("speed! ",0,2); |
ll17lrc | 11:7a4abe731f9c | 82 | lcd.drawSprite(70,40,7,5,(int *)arrow); |
ll17lrc | 11:7a4abe731f9c | 83 | lcd.refresh(); |
ll17lrc | 11:7a4abe731f9c | 84 | } |
ll17lrc | 11:7a4abe731f9c | 85 | while(pad.A_pressed() == false){ |
ll17lrc | 11:7a4abe731f9c | 86 | wait(0.15); |
ll17lrc | 11:7a4abe731f9c | 87 | lcd.clear(); |
ll17lrc | 11:7a4abe731f9c | 88 | lcd.printString("Touch a wall ",0,0); |
ll17lrc | 11:7a4abe731f9c | 89 | lcd.printString("and you fail! ",0,1); |
ll17lrc | 12:299479b6bb59 | 90 | lcd.printString("There are 6 ",0,2); |
ll17lrc | 11:7a4abe731f9c | 91 | lcd.printString("levels. ",0,3); |
ll17lrc | 11:7a4abe731f9c | 92 | lcd.printString("Good luck! ",0,4); |
ll17lrc | 11:7a4abe731f9c | 93 | lcd.drawSprite(70,40,7,5,(int *)arrow); |
ll17lrc | 11:7a4abe731f9c | 94 | lcd.refresh(); |
ll17lrc | 11:7a4abe731f9c | 95 | } |
ll17lrc | 13:fd290d2fd917 | 96 | //Starts the game after each screen has been displayed |
ll17lrc | 4:a9d5fca3b7ba | 97 | imposs.set_level_zero(); |
ll17lrc | 2:823dea76ff2e | 98 | } |
ll17lrc | 2:823dea76ff2e | 99 | |
ll17lrc | 4:a9d5fca3b7ba | 100 | } |