The game is finished
Dependencies: mbed Gamepad N5110 mbed-rtos
Music/Music.cpp@7:574c66ebd8b0, 2019-05-09 (annotated)
- Committer:
- RexRoshan
- Date:
- Thu May 09 09:54:50 2019 +0000
- Revision:
- 7:574c66ebd8b0
- Parent:
- 6:1fcfd331c047
Documentation has been completed and the code has been slightly modified
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
RexRoshan | 0:99fa5a619081 | 1 | #include "Music.h" |
RexRoshan | 0:99fa5a619081 | 2 | |
RexRoshan | 0:99fa5a619081 | 3 | Music::Music() |
RexRoshan | 0:99fa5a619081 | 4 | { |
RexRoshan | 0:99fa5a619081 | 5 | |
RexRoshan | 0:99fa5a619081 | 6 | } |
RexRoshan | 0:99fa5a619081 | 7 | |
RexRoshan | 0:99fa5a619081 | 8 | Music::~Music() |
RexRoshan | 0:99fa5a619081 | 9 | { |
RexRoshan | 0:99fa5a619081 | 10 | |
RexRoshan | 0:99fa5a619081 | 11 | } |
RexRoshan | 0:99fa5a619081 | 12 | |
RexRoshan | 5:016a7315b75d | 13 | void Music::intro_song(Gamepad &pad) // introduction song for the game |
RexRoshan | 0:99fa5a619081 | 14 | { |
RexRoshan | 5:016a7315b75d | 15 | while(pad.check_event(Gamepad::START_PRESSED) == false){ |
RexRoshan | 5:016a7315b75d | 16 | pad.tone(293.665, 2); |
RexRoshan | 7:574c66ebd8b0 | 17 | wait(0.8); // thread wait so that two loops can simulatneously run |
RexRoshan | 5:016a7315b75d | 18 | if(pad.check_event(Gamepad::START_PRESSED) == true){break;} // break if start button has been pressed |
RexRoshan | 0:99fa5a619081 | 19 | pad.tone(311.127, 2); |
RexRoshan | 7:574c66ebd8b0 | 20 | wait(0.8); |
RexRoshan | 0:99fa5a619081 | 21 | if(pad.check_event(Gamepad::START_PRESSED) == true){break;} |
RexRoshan | 0:99fa5a619081 | 22 | pad.tone(329.628, 2); |
RexRoshan | 7:574c66ebd8b0 | 23 | wait(0.8); |
RexRoshan | 0:99fa5a619081 | 24 | if(pad.check_event(Gamepad::START_PRESSED) == true){break;} |
RexRoshan | 0:99fa5a619081 | 25 | pad.tone(349.228, 2); |
RexRoshan | 7:574c66ebd8b0 | 26 | wait(0.8); |
RexRoshan | 0:99fa5a619081 | 27 | if(pad.check_event(Gamepad::START_PRESSED) == true){break;} |
RexRoshan | 0:99fa5a619081 | 28 | } |
RexRoshan | 0:99fa5a619081 | 29 | } |
RexRoshan | 0:99fa5a619081 | 30 | |
RexRoshan | 7:574c66ebd8b0 | 31 | void Music::mission_success(Gamepad &pad) // success song |
RexRoshan | 6:1fcfd331c047 | 32 | { |
RexRoshan | 6:1fcfd331c047 | 33 | //triplets |
RexRoshan | 6:1fcfd331c047 | 34 | pad.tone(207.65,0.18); |
RexRoshan | 6:1fcfd331c047 | 35 | wait(0.2); |
RexRoshan | 6:1fcfd331c047 | 36 | pad.tone(207.65,0.18); |
RexRoshan | 6:1fcfd331c047 | 37 | wait(0.2); |
RexRoshan | 6:1fcfd331c047 | 38 | pad.tone(207.65,0.18); |
RexRoshan | 6:1fcfd331c047 | 39 | wait(0.2); |
RexRoshan | 6:1fcfd331c047 | 40 | // 3 beats |
RexRoshan | 6:1fcfd331c047 | 41 | pad.tone(261.63,0.28); |
RexRoshan | 6:1fcfd331c047 | 42 | wait(0.3); |
RexRoshan | 6:1fcfd331c047 | 43 | pad.tone(207.65,0.28); |
RexRoshan | 6:1fcfd331c047 | 44 | wait(0.3); |
RexRoshan | 6:1fcfd331c047 | 45 | pad.tone(261.63,0.28); |
RexRoshan | 6:1fcfd331c047 | 46 | wait(0.3); |
RexRoshan | 6:1fcfd331c047 | 47 | pad.tone(261.63,0.28); |
RexRoshan | 6:1fcfd331c047 | 48 | wait(0.30); |
RexRoshan | 6:1fcfd331c047 | 49 | pad.tone(207.65,0.28); |
RexRoshan | 6:1fcfd331c047 | 50 | wait(0.30); |
RexRoshan | 6:1fcfd331c047 | 51 | pad.tone(261.63,0.28); |
RexRoshan | 6:1fcfd331c047 | 52 | wait(0.30); |
RexRoshan | 6:1fcfd331c047 | 53 | pad.tone(311.13,1.2); |
RexRoshan | 6:1fcfd331c047 | 54 | wait(1.2); |
RexRoshan | 6:1fcfd331c047 | 55 | wait(2.4); |
RexRoshan | 6:1fcfd331c047 | 56 | }; |
RexRoshan | 6:1fcfd331c047 | 57 | |
RexRoshan | 7:574c66ebd8b0 | 58 | void Music::mission_fail(Gamepad &pad) // failure song |
RexRoshan | 6:1fcfd331c047 | 59 | { |
RexRoshan | 6:1fcfd331c047 | 60 | pad.tone(233.0,0.5); |
RexRoshan | 6:1fcfd331c047 | 61 | wait(0.5); |
RexRoshan | 6:1fcfd331c047 | 62 | pad.tone(184.0,0.5); |
RexRoshan | 6:1fcfd331c047 | 63 | wait(0.5); |
RexRoshan | 6:1fcfd331c047 | 64 | pad.tone(174.0,2.0); |
RexRoshan | 6:1fcfd331c047 | 65 | wait(1.0); |
RexRoshan | 6:1fcfd331c047 | 66 | |
RexRoshan | 6:1fcfd331c047 | 67 | }; |