Yunting Zou 201199716
Dependencies: mbed MotionSensor
Diff: story/story.h
- Revision:
- 0:047e14f53977
- Child:
- 1:9a8033d80067
diff -r 000000000000 -r 047e14f53977 story/story.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/story/story.h Thu May 14 16:17:30 2020 +0000 @@ -0,0 +1,124 @@ +#include <stdio.h> +#include <time.h> +#include "mbed.h" +#include "Gamepad.h" +#include "N5110.h" +/** +this file is used to set the sounds and appearance of the game +**/ + +void firststory(); //@instructions +void graph(); //@A picture of snake +void music(); //@the opening music +void lose(); //@losing music + + + + +void firststory(){ + lcd.clear(); + lcd.printString("instructions",3,0); + lcd.printString("Hold joystick",0,1); + lcd.printString("to control",3,2); + lcd.printString("the snake",3,3); + lcd.printString("press X button",0,5); + + lcd.refresh(); + while ( pad.check_event(Gamepad::X_PRESSED) == false) { + lcd.refresh(); + } +} + + +void graph(){ + +lcd.clear(); +lcd.printString("press Y button",3,0); +lcd.printString("to continue",3,1); + int gra[20][32] = { +{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}, +{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}, +{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}, +{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}, +{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}, +{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}, +{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}, +{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}, +{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}, +{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}, +{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}, +{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}, +{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}, +{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}, +{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}, +{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}, +{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}, +{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}, +{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}, +{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}, + + }; + + lcd.drawSprite(20,25,20,32,(int*)gra); + while ( pad.check_event(Gamepad::Y_PRESSED) == false) { + lcd.refresh(); + } +} + + +void music(){ + pad.tone(523.25,0.25); + wait(0.15); + pad.tone(783.99,0.25); + wait(0.15); + pad.tone(659.26,0.25); + wait(0.15); + pad.tone(783.99,0.25); + wait(0.15); + pad.tone(698.46,0.25); + wait(0.15); + pad.tone(783.99,0.25); + wait(0.15); + pad.tone(698.46,0.25); + wait(0.15); + pad.tone(659.26,0.25); + wait(0.15); + pad.tone(587.33,0.25); + wait(0.15); + pad.tone(659.26,0.25); + wait(0.15); + pad.tone(698.46,0.25); + wait(0.15); + pad.tone(587.33,0.25); + wait(0.15); + pad.tone(523.25,0.25); + wait(0.15); + } + +void lose(){ + pad.tone(1045.50,0.25); + wait(0.15); + pad.tone(987.77,0.25); + wait(0.15); + pad.tone(880.00,0.25); + wait(0.15); + pad.tone(783.99,0.25); + wait(0.15); + pad.tone(698.46,0.25); + wait(0.15); + pad.tone(1045.50,0.25); + wait(0.15); + pad.tone(987.77,0.25); + wait(0.15); + pad.tone(880.00,0.25); + wait(0.15); + pad.tone(783.99,0.25); + wait(0.15); + pad.tone(698.46,0.25); + wait(0.15); + + } + + + +