Yunting Zou 201199716
Dependencies: mbed MotionSensor
story/story.h
- Committer:
- zhouyun123
- Date:
- 2020-05-14
- Revision:
- 1:9a8033d80067
- Parent:
- 0:047e14f53977
- Child:
- 2:a2f88b2d5da4
File content as of revision 1:9a8033d80067:
#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); }