Yunting Zou 201199716
Dependencies: mbed MotionSensor
story/story.h@0:047e14f53977, 2020-05-14 (annotated)
- Committer:
- zhouyun123
- Date:
- Thu May 14 16:17:30 2020 +0000
- Revision:
- 0:047e14f53977
- Child:
- 1:9a8033d80067
first commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
zhouyun123 | 0:047e14f53977 | 1 | #include <stdio.h> |
zhouyun123 | 0:047e14f53977 | 2 | #include <time.h> |
zhouyun123 | 0:047e14f53977 | 3 | #include "mbed.h" |
zhouyun123 | 0:047e14f53977 | 4 | #include "Gamepad.h" |
zhouyun123 | 0:047e14f53977 | 5 | #include "N5110.h" |
zhouyun123 | 0:047e14f53977 | 6 | /** |
zhouyun123 | 0:047e14f53977 | 7 | this file is used to set the sounds and appearance of the game |
zhouyun123 | 0:047e14f53977 | 8 | **/ |
zhouyun123 | 0:047e14f53977 | 9 | |
zhouyun123 | 0:047e14f53977 | 10 | void firststory(); //@instructions |
zhouyun123 | 0:047e14f53977 | 11 | void graph(); //@A picture of snake |
zhouyun123 | 0:047e14f53977 | 12 | void music(); //@the opening music |
zhouyun123 | 0:047e14f53977 | 13 | void lose(); //@losing music |
zhouyun123 | 0:047e14f53977 | 14 | |
zhouyun123 | 0:047e14f53977 | 15 | |
zhouyun123 | 0:047e14f53977 | 16 | |
zhouyun123 | 0:047e14f53977 | 17 | |
zhouyun123 | 0:047e14f53977 | 18 | void firststory(){ |
zhouyun123 | 0:047e14f53977 | 19 | lcd.clear(); |
zhouyun123 | 0:047e14f53977 | 20 | lcd.printString("instructions",3,0); |
zhouyun123 | 0:047e14f53977 | 21 | lcd.printString("Hold joystick",0,1); |
zhouyun123 | 0:047e14f53977 | 22 | lcd.printString("to control",3,2); |
zhouyun123 | 0:047e14f53977 | 23 | lcd.printString("the snake",3,3); |
zhouyun123 | 0:047e14f53977 | 24 | lcd.printString("press X button",0,5); |
zhouyun123 | 0:047e14f53977 | 25 | |
zhouyun123 | 0:047e14f53977 | 26 | lcd.refresh(); |
zhouyun123 | 0:047e14f53977 | 27 | while ( pad.check_event(Gamepad::X_PRESSED) == false) { |
zhouyun123 | 0:047e14f53977 | 28 | lcd.refresh(); |
zhouyun123 | 0:047e14f53977 | 29 | } |
zhouyun123 | 0:047e14f53977 | 30 | } |
zhouyun123 | 0:047e14f53977 | 31 | |
zhouyun123 | 0:047e14f53977 | 32 | |
zhouyun123 | 0:047e14f53977 | 33 | void graph(){ |
zhouyun123 | 0:047e14f53977 | 34 | |
zhouyun123 | 0:047e14f53977 | 35 | lcd.clear(); |
zhouyun123 | 0:047e14f53977 | 36 | lcd.printString("press Y button",3,0); |
zhouyun123 | 0:047e14f53977 | 37 | lcd.printString("to continue",3,1); |
zhouyun123 | 0:047e14f53977 | 38 | int gra[20][32] = { |
zhouyun123 | 0:047e14f53977 | 39 | {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,1,1,1,1}, |
zhouyun123 | 0:047e14f53977 | 40 | {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,1,1,1,1}, |
zhouyun123 | 0:047e14f53977 | 41 | {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1}, |
zhouyun123 | 0:047e14f53977 | 42 | {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,1,1,1,1}, |
zhouyun123 | 0:047e14f53977 | 43 | {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,1,1,1,1}, |
zhouyun123 | 0:047e14f53977 | 44 | {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,1,1,0}, |
zhouyun123 | 0:047e14f53977 | 45 | {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0}, |
zhouyun123 | 0:047e14f53977 | 46 | {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,0,0}, |
zhouyun123 | 0:047e14f53977 | 47 | {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,1,0,1,0,0,0}, |
zhouyun123 | 0:047e14f53977 | 48 | {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,0,1,0,0}, |
zhouyun123 | 0:047e14f53977 | 49 | {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,1,0}, |
zhouyun123 | 0:047e14f53977 | 50 | {0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1}, |
zhouyun123 | 0:047e14f53977 | 51 | {0,0,1,0,0,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0}, |
zhouyun123 | 0:047e14f53977 | 52 | {0,1,0,0,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1}, |
zhouyun123 | 0:047e14f53977 | 53 | {1,0,0,1,1,0,0,0,1,1,0,1,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,1,1,0}, |
zhouyun123 | 0:047e14f53977 | 54 | {0,0,1,1,0,0,1,0,0,1,1,0,0,0,0,0,1,1,1,1,0,1,0,0,0,0,0,0,1,1,0,0}, |
zhouyun123 | 0:047e14f53977 | 55 | {0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,1,1,0,0,0,1,0,1,0,0,0,0,1,1,0,0,0}, |
zhouyun123 | 0:047e14f53977 | 56 | {0,0,0,0,0,0,1,0,1,0,0,0,0,0,1,1,0,0,0,0,0,1,0,1,0,0,1,1,0,0,0,0}, |
zhouyun123 | 0:047e14f53977 | 57 | {0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,0,0,0,0,0,0,1,0,0,1,1,0,0,0,0,0}, |
zhouyun123 | 0:047e14f53977 | 58 | {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0}, |
zhouyun123 | 0:047e14f53977 | 59 | |
zhouyun123 | 0:047e14f53977 | 60 | }; |
zhouyun123 | 0:047e14f53977 | 61 | |
zhouyun123 | 0:047e14f53977 | 62 | lcd.drawSprite(20,25,20,32,(int*)gra); |
zhouyun123 | 0:047e14f53977 | 63 | while ( pad.check_event(Gamepad::Y_PRESSED) == false) { |
zhouyun123 | 0:047e14f53977 | 64 | lcd.refresh(); |
zhouyun123 | 0:047e14f53977 | 65 | } |
zhouyun123 | 0:047e14f53977 | 66 | } |
zhouyun123 | 0:047e14f53977 | 67 | |
zhouyun123 | 0:047e14f53977 | 68 | |
zhouyun123 | 0:047e14f53977 | 69 | void music(){ |
zhouyun123 | 0:047e14f53977 | 70 | pad.tone(523.25,0.25); |
zhouyun123 | 0:047e14f53977 | 71 | wait(0.15); |
zhouyun123 | 0:047e14f53977 | 72 | pad.tone(783.99,0.25); |
zhouyun123 | 0:047e14f53977 | 73 | wait(0.15); |
zhouyun123 | 0:047e14f53977 | 74 | pad.tone(659.26,0.25); |
zhouyun123 | 0:047e14f53977 | 75 | wait(0.15); |
zhouyun123 | 0:047e14f53977 | 76 | pad.tone(783.99,0.25); |
zhouyun123 | 0:047e14f53977 | 77 | wait(0.15); |
zhouyun123 | 0:047e14f53977 | 78 | pad.tone(698.46,0.25); |
zhouyun123 | 0:047e14f53977 | 79 | wait(0.15); |
zhouyun123 | 0:047e14f53977 | 80 | pad.tone(783.99,0.25); |
zhouyun123 | 0:047e14f53977 | 81 | wait(0.15); |
zhouyun123 | 0:047e14f53977 | 82 | pad.tone(698.46,0.25); |
zhouyun123 | 0:047e14f53977 | 83 | wait(0.15); |
zhouyun123 | 0:047e14f53977 | 84 | pad.tone(659.26,0.25); |
zhouyun123 | 0:047e14f53977 | 85 | wait(0.15); |
zhouyun123 | 0:047e14f53977 | 86 | pad.tone(587.33,0.25); |
zhouyun123 | 0:047e14f53977 | 87 | wait(0.15); |
zhouyun123 | 0:047e14f53977 | 88 | pad.tone(659.26,0.25); |
zhouyun123 | 0:047e14f53977 | 89 | wait(0.15); |
zhouyun123 | 0:047e14f53977 | 90 | pad.tone(698.46,0.25); |
zhouyun123 | 0:047e14f53977 | 91 | wait(0.15); |
zhouyun123 | 0:047e14f53977 | 92 | pad.tone(587.33,0.25); |
zhouyun123 | 0:047e14f53977 | 93 | wait(0.15); |
zhouyun123 | 0:047e14f53977 | 94 | pad.tone(523.25,0.25); |
zhouyun123 | 0:047e14f53977 | 95 | wait(0.15); |
zhouyun123 | 0:047e14f53977 | 96 | } |
zhouyun123 | 0:047e14f53977 | 97 | |
zhouyun123 | 0:047e14f53977 | 98 | void lose(){ |
zhouyun123 | 0:047e14f53977 | 99 | pad.tone(1045.50,0.25); |
zhouyun123 | 0:047e14f53977 | 100 | wait(0.15); |
zhouyun123 | 0:047e14f53977 | 101 | pad.tone(987.77,0.25); |
zhouyun123 | 0:047e14f53977 | 102 | wait(0.15); |
zhouyun123 | 0:047e14f53977 | 103 | pad.tone(880.00,0.25); |
zhouyun123 | 0:047e14f53977 | 104 | wait(0.15); |
zhouyun123 | 0:047e14f53977 | 105 | pad.tone(783.99,0.25); |
zhouyun123 | 0:047e14f53977 | 106 | wait(0.15); |
zhouyun123 | 0:047e14f53977 | 107 | pad.tone(698.46,0.25); |
zhouyun123 | 0:047e14f53977 | 108 | wait(0.15); |
zhouyun123 | 0:047e14f53977 | 109 | pad.tone(1045.50,0.25); |
zhouyun123 | 0:047e14f53977 | 110 | wait(0.15); |
zhouyun123 | 0:047e14f53977 | 111 | pad.tone(987.77,0.25); |
zhouyun123 | 0:047e14f53977 | 112 | wait(0.15); |
zhouyun123 | 0:047e14f53977 | 113 | pad.tone(880.00,0.25); |
zhouyun123 | 0:047e14f53977 | 114 | wait(0.15); |
zhouyun123 | 0:047e14f53977 | 115 | pad.tone(783.99,0.25); |
zhouyun123 | 0:047e14f53977 | 116 | wait(0.15); |
zhouyun123 | 0:047e14f53977 | 117 | pad.tone(698.46,0.25); |
zhouyun123 | 0:047e14f53977 | 118 | wait(0.15); |
zhouyun123 | 0:047e14f53977 | 119 | |
zhouyun123 | 0:047e14f53977 | 120 | } |
zhouyun123 | 0:047e14f53977 | 121 | |
zhouyun123 | 0:047e14f53977 | 122 | |
zhouyun123 | 0:047e14f53977 | 123 | |
zhouyun123 | 0:047e14f53977 | 124 |