![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
demo
Dependencies: mbed Gamepad N5110
Engine/Engine.cpp@0:ba32cfe0051e, 2020-05-14 (annotated)
- Committer:
- Ting12138
- Date:
- Thu May 14 12:57:32 2020 +0000
- Revision:
- 0:ba32cfe0051e
demo
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Ting12138 | 0:ba32cfe0051e | 1 | #include "Engine.h" |
Ting12138 | 0:ba32cfe0051e | 2 | |
Ting12138 | 0:ba32cfe0051e | 3 | Engine::Engine() |
Ting12138 | 0:ba32cfe0051e | 4 | { |
Ting12138 | 0:ba32cfe0051e | 5 | |
Ting12138 | 0:ba32cfe0051e | 6 | } |
Ting12138 | 0:ba32cfe0051e | 7 | |
Ting12138 | 0:ba32cfe0051e | 8 | Engine::~Engine() |
Ting12138 | 0:ba32cfe0051e | 9 | { |
Ting12138 | 0:ba32cfe0051e | 10 | |
Ting12138 | 0:ba32cfe0051e | 11 | } |
Ting12138 | 0:ba32cfe0051e | 12 | |
Ting12138 | 0:ba32cfe0051e | 13 | void Engine::init(int wall_width,int wall_gap,int foods_size,int velocity) { |
Ting12138 | 0:ba32cfe0051e | 14 | |
Ting12138 | 0:ba32cfe0051e | 15 | // initialise the game parameters |
Ting12138 | 0:ba32cfe0051e | 16 | _wall_width = wall_width; |
Ting12138 | 0:ba32cfe0051e | 17 | _wall_gap = wall_gap; // wall gap presents the distance between the top wall and the bottom wall, which is licked to difficulty |
Ting12138 | 0:ba32cfe0051e | 18 | _foods_size = foods_size; // larger foods means it will have larger area to trigger it "_rocket.add_score();" |
Ting12138 | 0:ba32cfe0051e | 19 | _velocity = velocity; |
Ting12138 | 0:ba32cfe0051e | 20 | |
Ting12138 | 0:ba32cfe0051e | 21 | // x position on screen - WIDTH is defined in N5110.h |
Ting12138 | 0:ba32cfe0051e | 22 | _w0x = WIDTH; // there is total 5 walls in the game, all are placed in distributed positions |
Ting12138 | 0:ba32cfe0051e | 23 | _w1x = WIDTH + 30; |
Ting12138 | 0:ba32cfe0051e | 24 | _w2x = WIDTH + 60; |
Ting12138 | 0:ba32cfe0051e | 25 | _w3x = WIDTH + 90; |
Ting12138 | 0:ba32cfe0051e | 26 | _w4x = WIDTH + 120; |
Ting12138 | 0:ba32cfe0051e | 27 | _rocketx = 10; |
Ting12138 | 0:ba32cfe0051e | 28 | _foodsx = WIDTH + 105; |
Ting12138 | 0:ba32cfe0051e | 29 | |
Ting12138 | 0:ba32cfe0051e | 30 | _w0.init(_w0x,_wall_gap,_wall_width,_velocity); // initiate all walls with random holes |
Ting12138 | 0:ba32cfe0051e | 31 | _w1.init(_w1x,_wall_gap,_wall_width,_velocity); |
Ting12138 | 0:ba32cfe0051e | 32 | _w2.init(_w2x,_wall_gap,_wall_width,_velocity); |
Ting12138 | 0:ba32cfe0051e | 33 | _w3.init(_w3x,_wall_gap,_wall_width,_velocity); |
Ting12138 | 0:ba32cfe0051e | 34 | _w4.init(_w4x,_wall_gap,_wall_width,_velocity); |
Ting12138 | 0:ba32cfe0051e | 35 | _rocket.init(_rocketx); // set the rocket in the middle |
Ting12138 | 0:ba32cfe0051e | 36 | _foods.init(_foodsx,_foods_size,_velocity); // initiate foods size and a random y position |
Ting12138 | 0:ba32cfe0051e | 37 | } |
Ting12138 | 0:ba32cfe0051e | 38 | |
Ting12138 | 0:ba32cfe0051e | 39 | void Engine::read_input(Gamepad &pad) { // get joystick reading |
Ting12138 | 0:ba32cfe0051e | 40 | |
Ting12138 | 0:ba32cfe0051e | 41 | _d = pad.get_direction(); |
Ting12138 | 0:ba32cfe0051e | 42 | _mag = pad.get_mag(); |
Ting12138 | 0:ba32cfe0051e | 43 | _mapped_coord = pad.get_mapped_coord(); |
Ting12138 | 0:ba32cfe0051e | 44 | } |
Ting12138 | 0:ba32cfe0051e | 45 | |
Ting12138 | 0:ba32cfe0051e | 46 | void Engine::draw(N5110 &lcd) { |
Ting12138 | 0:ba32cfe0051e | 47 | // draw the elements in the LCD buffer |
Ting12138 | 0:ba32cfe0051e | 48 | // pitch |
Ting12138 | 0:ba32cfe0051e | 49 | lcd.drawRect(0,0,WIDTH,HEIGHT,FILL_TRANSPARENT); |
Ting12138 | 0:ba32cfe0051e | 50 | // walls |
Ting12138 | 0:ba32cfe0051e | 51 | _w0.draw1(lcd); |
Ting12138 | 0:ba32cfe0051e | 52 | _w0.draw2(lcd); |
Ting12138 | 0:ba32cfe0051e | 53 | _w1.draw1(lcd); |
Ting12138 | 0:ba32cfe0051e | 54 | _w1.draw2(lcd); |
Ting12138 | 0:ba32cfe0051e | 55 | _w2.draw1(lcd); |
Ting12138 | 0:ba32cfe0051e | 56 | _w2.draw2(lcd); |
Ting12138 | 0:ba32cfe0051e | 57 | _w3.draw1(lcd); |
Ting12138 | 0:ba32cfe0051e | 58 | _w3.draw2(lcd); |
Ting12138 | 0:ba32cfe0051e | 59 | _w4.draw1(lcd); |
Ting12138 | 0:ba32cfe0051e | 60 | _w4.draw2(lcd); |
Ting12138 | 0:ba32cfe0051e | 61 | // the rocket |
Ting12138 | 0:ba32cfe0051e | 62 | _rocket.draw(lcd); |
Ting12138 | 0:ba32cfe0051e | 63 | // foods |
Ting12138 | 0:ba32cfe0051e | 64 | _foods.draw(lcd); |
Ting12138 | 0:ba32cfe0051e | 65 | } |
Ting12138 | 0:ba32cfe0051e | 66 | |
Ting12138 | 0:ba32cfe0051e | 67 | |
Ting12138 | 0:ba32cfe0051e | 68 | void Engine::update(Gamepad &pad) { |
Ting12138 | 0:ba32cfe0051e | 69 | |
Ting12138 | 0:ba32cfe0051e | 70 | //It's important to check that the walls, rockets, and food are updated before the collision, so that it can be fixed before the new food is updated |
Ting12138 | 0:ba32cfe0051e | 71 | _w0.update(); |
Ting12138 | 0:ba32cfe0051e | 72 | _w1.update(); |
Ting12138 | 0:ba32cfe0051e | 73 | _w2.update(); |
Ting12138 | 0:ba32cfe0051e | 74 | _w3.update(); |
Ting12138 | 0:ba32cfe0051e | 75 | _w4.update(); |
Ting12138 | 0:ba32cfe0051e | 76 | _rocket.replace(_d,_mag,_mapped_coord); |
Ting12138 | 0:ba32cfe0051e | 77 | _foods.update(); |
Ting12138 | 0:ba32cfe0051e | 78 | check_wall_collision(pad); |
Ting12138 | 0:ba32cfe0051e | 79 | check_score(pad); |
Ting12138 | 0:ba32cfe0051e | 80 | } |
Ting12138 | 0:ba32cfe0051e | 81 | |
Ting12138 | 0:ba32cfe0051e | 82 | void Engine::check_wall_collision(Gamepad &pad) { |
Ting12138 | 0:ba32cfe0051e | 83 | |
Ting12138 | 0:ba32cfe0051e | 84 | // read the position of rocket |
Ting12138 | 0:ba32cfe0051e | 85 | Vector2D rocket_pos = _rocket.get_pos(); |
Ting12138 | 0:ba32cfe0051e | 86 | |
Ting12138 | 0:ba32cfe0051e | 87 | //read all of these positions of the wall |
Ting12138 | 0:ba32cfe0051e | 88 | int w0_x = _w0.get_x(); |
Ting12138 | 0:ba32cfe0051e | 89 | int w1_x = _w1.get_x(); |
Ting12138 | 0:ba32cfe0051e | 90 | int w2_x = _w2.get_x(); |
Ting12138 | 0:ba32cfe0051e | 91 | int w3_x = _w3.get_x(); |
Ting12138 | 0:ba32cfe0051e | 92 | int w4_x = _w4.get_x(); |
Ting12138 | 0:ba32cfe0051e | 93 | |
Ting12138 | 0:ba32cfe0051e | 94 | if (w0_x <= 1) { // When the rocket passes behind the wall, it will reset to its original position to continue the game |
Ting12138 | 0:ba32cfe0051e | 95 | _w0.reset(); |
Ting12138 | 0:ba32cfe0051e | 96 | } |
Ting12138 | 0:ba32cfe0051e | 97 | if (w1_x <= 1) { |
Ting12138 | 0:ba32cfe0051e | 98 | _w1.reset(); |
Ting12138 | 0:ba32cfe0051e | 99 | } |
Ting12138 | 0:ba32cfe0051e | 100 | if (w2_x <= 1) { |
Ting12138 | 0:ba32cfe0051e | 101 | _w2.reset(); |
Ting12138 | 0:ba32cfe0051e | 102 | } |
Ting12138 | 0:ba32cfe0051e | 103 | if (w3_x <= 1) { |
Ting12138 | 0:ba32cfe0051e | 104 | _w3.reset(); |
Ting12138 | 0:ba32cfe0051e | 105 | } |
Ting12138 | 0:ba32cfe0051e | 106 | if (w4_x <= 1) { |
Ting12138 | 0:ba32cfe0051e | 107 | _w4.reset(); |
Ting12138 | 0:ba32cfe0051e | 108 | } |
Ting12138 | 0:ba32cfe0051e | 109 | |
Ting12138 | 0:ba32cfe0051e | 110 | int w0_height = _w0.get_height(); // get the specific, random height for each of the walls |
Ting12138 | 0:ba32cfe0051e | 111 | int w1_height = _w1.get_height(); |
Ting12138 | 0:ba32cfe0051e | 112 | int w2_height = _w2.get_height(); |
Ting12138 | 0:ba32cfe0051e | 113 | int w3_height = _w3.get_height(); |
Ting12138 | 0:ba32cfe0051e | 114 | int w4_height = _w4.get_height(); |
Ting12138 | 0:ba32cfe0051e | 115 | |
Ting12138 | 0:ba32cfe0051e | 116 | if (( |
Ting12138 | 0:ba32cfe0051e | 117 | (rocket_pos.y + 5 >= 0) && (rocket_pos.y + 1 <= w0_height) && // check all the top wall corner collision and the bottom for all the walls |
Ting12138 | 0:ba32cfe0051e | 118 | (rocket_pos.x + 10 >= _w0.get_x()) && (rocket_pos.x + 10 <= _w0.get_x() + 1) // left and right collisions |
Ting12138 | 0:ba32cfe0051e | 119 | ) || ( |
Ting12138 | 0:ba32cfe0051e | 120 | (rocket_pos.y + 5 >= 0) && (rocket_pos.y + 1 <= w1_height) && |
Ting12138 | 0:ba32cfe0051e | 121 | (rocket_pos.x + 10 >= _w1.get_x()) && (rocket_pos.x + 10 <= _w1.get_x() + 1) |
Ting12138 | 0:ba32cfe0051e | 122 | ) || ( |
Ting12138 | 0:ba32cfe0051e | 123 | (rocket_pos.y + 5 >= 0) && (rocket_pos.x + 1 <= w2_height) && |
Ting12138 | 0:ba32cfe0051e | 124 | (rocket_pos.x + 10 >= _w2.get_x()) && (rocket_pos.x + 10 <= _w2.get_x() + 1) |
Ting12138 | 0:ba32cfe0051e | 125 | ) || ( |
Ting12138 | 0:ba32cfe0051e | 126 | (rocket_pos.y + 5 >= 0) && (rocket_pos.y + 1 <= w3_height) && |
Ting12138 | 0:ba32cfe0051e | 127 | (rocket_pos.x + 10 >= _w3.get_x()) && (rocket_pos.x + 10 <= _w3.get_x() + 1) |
Ting12138 | 0:ba32cfe0051e | 128 | ) || ( |
Ting12138 | 0:ba32cfe0051e | 129 | (rocket_pos.y + 5 >= 0) && (rocket_pos.y + 1 <= w4_height) && |
Ting12138 | 0:ba32cfe0051e | 130 | (rocket_pos.x + 10 >= _w4.get_x()) && (rocket_pos.x + 10 <= _w4.get_x() + 1) |
Ting12138 | 0:ba32cfe0051e | 131 | ) |
Ting12138 | 0:ba32cfe0051e | 132 | ) { |
Ting12138 | 0:ba32cfe0051e | 133 | _rocket.lose_score(); // if collision does happen, foods are lost because of the unnecessary time of interference |
Ting12138 | 0:ba32cfe0051e | 134 | |
Ting12138 | 0:ba32cfe0051e | 135 | pad.tone(130.0,0.1); // sad sound playing |
Ting12138 | 0:ba32cfe0051e | 136 | wait(0.1); |
Ting12138 | 0:ba32cfe0051e | 137 | pad.tone(230.0,0.1); |
Ting12138 | 0:ba32cfe0051e | 138 | wait(0.1); |
Ting12138 | 0:ba32cfe0051e | 139 | pad.tone(330.0,0.1); |
Ting12138 | 0:ba32cfe0051e | 140 | wait(0.1); |
Ting12138 | 0:ba32cfe0051e | 141 | pad.tone(430.0,0.1); |
Ting12138 | 0:ba32cfe0051e | 142 | wait(0.1); |
Ting12138 | 0:ba32cfe0051e | 143 | pad.tone(530.0,0.1); |
Ting12138 | 0:ba32cfe0051e | 144 | wait(0.1); |
Ting12138 | 0:ba32cfe0051e | 145 | } |
Ting12138 | 0:ba32cfe0051e | 146 | |
Ting12138 | 0:ba32cfe0051e | 147 | if (( |
Ting12138 | 0:ba32cfe0051e | 148 | (rocket_pos.y + 5 >= _wall_gap + w0_height) && (rocket_pos.y + 1 <= HEIGHT) && // check collisions for the bottom wall |
Ting12138 | 0:ba32cfe0051e | 149 | (rocket_pos.x + 10 >= _w0.get_x()) && (rocket_pos.x + 10 <= _w0.get_x() + 1) // left and right side |
Ting12138 | 0:ba32cfe0051e | 150 | ) || ( |
Ting12138 | 0:ba32cfe0051e | 151 | (rocket_pos.y + 5 >= _wall_gap + w1_height) && (rocket_pos.y + 1 <= HEIGHT) && |
Ting12138 | 0:ba32cfe0051e | 152 | (rocket_pos.x + 10 >= _w1.get_x()) && (rocket_pos.x + 10 <= _w1.get_x() + 1) |
Ting12138 | 0:ba32cfe0051e | 153 | ) || ( |
Ting12138 | 0:ba32cfe0051e | 154 | (rocket_pos.y + 5 >= _wall_gap + w2_height) && (rocket_pos.y + 1 <= HEIGHT) && |
Ting12138 | 0:ba32cfe0051e | 155 | (rocket_pos.x + 10 >= _w2.get_x()) && (rocket_pos.x + 10 <= _w2.get_x() + 1) |
Ting12138 | 0:ba32cfe0051e | 156 | ) || ( |
Ting12138 | 0:ba32cfe0051e | 157 | (rocket_pos.y + 5 >= _wall_gap + w3_height) && (rocket_pos.y + 1 <= HEIGHT) && |
Ting12138 | 0:ba32cfe0051e | 158 | (rocket_pos.x + 10 >= _w3.get_x()) && (rocket_pos.x + 10 <= _w3.get_x() + 1) |
Ting12138 | 0:ba32cfe0051e | 159 | ) || ( |
Ting12138 | 0:ba32cfe0051e | 160 | (rocket_pos.y + 5 >= _wall_gap + w4_height) && (rocket_pos.y + 1 <= HEIGHT) && |
Ting12138 | 0:ba32cfe0051e | 161 | (rocket_pos.x + 10 >= _w4.get_x()) && (rocket_pos.x + 10 <= _w4.get_x() + 1) |
Ting12138 | 0:ba32cfe0051e | 162 | ) |
Ting12138 | 0:ba32cfe0051e | 163 | ) { |
Ting12138 | 0:ba32cfe0051e | 164 | _rocket.lose_score(); // score lost |
Ting12138 | 0:ba32cfe0051e | 165 | |
Ting12138 | 0:ba32cfe0051e | 166 | pad.tone(100.0,0.1); // sad sound |
Ting12138 | 0:ba32cfe0051e | 167 | wait(0.1); |
Ting12138 | 0:ba32cfe0051e | 168 | pad.tone(200.0,0.1); |
Ting12138 | 0:ba32cfe0051e | 169 | wait(0.1); |
Ting12138 | 0:ba32cfe0051e | 170 | pad.tone(300.0,0.1); |
Ting12138 | 0:ba32cfe0051e | 171 | wait(0.1); |
Ting12138 | 0:ba32cfe0051e | 172 | pad.tone(400.0,0.1); |
Ting12138 | 0:ba32cfe0051e | 173 | wait(0.1); |
Ting12138 | 0:ba32cfe0051e | 174 | pad.tone(500.0,0.1); |
Ting12138 | 0:ba32cfe0051e | 175 | wait(0.1); |
Ting12138 | 0:ba32cfe0051e | 176 | } |
Ting12138 | 0:ba32cfe0051e | 177 | } |
Ting12138 | 0:ba32cfe0051e | 178 | |
Ting12138 | 0:ba32cfe0051e | 179 | void Engine::check_score(Gamepad &pad) { //check the score to trigger how many leds should be turned on |
Ting12138 | 0:ba32cfe0051e | 180 | |
Ting12138 | 0:ba32cfe0051e | 181 | int rocket_score = _rocket.get_final_score(); // get score |
Ting12138 | 0:ba32cfe0051e | 182 | |
Ting12138 | 0:ba32cfe0051e | 183 | if (rocket_score == 0) { // 7 if statements represents 7 conditions |
Ting12138 | 0:ba32cfe0051e | 184 | pad.leds_off(); |
Ting12138 | 0:ba32cfe0051e | 185 | } |
Ting12138 | 0:ba32cfe0051e | 186 | if (rocket_score == 1) { // getting one food turns on 1 led |
Ting12138 | 0:ba32cfe0051e | 187 | pad.led(1,1.0f); |
Ting12138 | 0:ba32cfe0051e | 188 | pad.led(2,0.0f); |
Ting12138 | 0:ba32cfe0051e | 189 | pad.led(2,0.0f); |
Ting12138 | 0:ba32cfe0051e | 190 | pad.led(2,0.0f); |
Ting12138 | 0:ba32cfe0051e | 191 | pad.led(2,0.0f); |
Ting12138 | 0:ba32cfe0051e | 192 | pad.led(2,0.0f); |
Ting12138 | 0:ba32cfe0051e | 193 | } |
Ting12138 | 0:ba32cfe0051e | 194 | if (rocket_score == 2) { // two foodds, two led |
Ting12138 | 0:ba32cfe0051e | 195 | pad.led(1,1.0f); |
Ting12138 | 0:ba32cfe0051e | 196 | pad.led(2,0.0f); |
Ting12138 | 0:ba32cfe0051e | 197 | pad.led(3,0.0f); |
Ting12138 | 0:ba32cfe0051e | 198 | pad.led(4,0.0f); |
Ting12138 | 0:ba32cfe0051e | 199 | pad.led(5,0.0f); |
Ting12138 | 0:ba32cfe0051e | 200 | pad.led(6,1.0f); |
Ting12138 | 0:ba32cfe0051e | 201 | } |
Ting12138 | 0:ba32cfe0051e | 202 | if (rocket_score == 3) { |
Ting12138 | 0:ba32cfe0051e | 203 | pad.led(1,1.0f); |
Ting12138 | 0:ba32cfe0051e | 204 | pad.led(2,1.0f); |
Ting12138 | 0:ba32cfe0051e | 205 | pad.led(3,0.0f); |
Ting12138 | 0:ba32cfe0051e | 206 | pad.led(4,0.0f); |
Ting12138 | 0:ba32cfe0051e | 207 | pad.led(5,0.0f); |
Ting12138 | 0:ba32cfe0051e | 208 | pad.led(6,1.0f); |
Ting12138 | 0:ba32cfe0051e | 209 | } |
Ting12138 | 0:ba32cfe0051e | 210 | if (rocket_score == 4) { |
Ting12138 | 0:ba32cfe0051e | 211 | pad.led(1,1.0f); |
Ting12138 | 0:ba32cfe0051e | 212 | pad.led(2,1.0f); |
Ting12138 | 0:ba32cfe0051e | 213 | pad.led(3,0.0f); |
Ting12138 | 0:ba32cfe0051e | 214 | pad.led(4,0.0f); |
Ting12138 | 0:ba32cfe0051e | 215 | pad.led(5,1.0f); |
Ting12138 | 0:ba32cfe0051e | 216 | pad.led(6,1.0f); |
Ting12138 | 0:ba32cfe0051e | 217 | } |
Ting12138 | 0:ba32cfe0051e | 218 | if (rocket_score == 5) { |
Ting12138 | 0:ba32cfe0051e | 219 | pad.led(1,1.0f); |
Ting12138 | 0:ba32cfe0051e | 220 | pad.led(2,1.0f); |
Ting12138 | 0:ba32cfe0051e | 221 | pad.led(3,1.0f); |
Ting12138 | 0:ba32cfe0051e | 222 | pad.led(4,0.0f); |
Ting12138 | 0:ba32cfe0051e | 223 | pad.led(5,1.0f); |
Ting12138 | 0:ba32cfe0051e | 224 | pad.led(6,1.0f); |
Ting12138 | 0:ba32cfe0051e | 225 | } |
Ting12138 | 0:ba32cfe0051e | 226 | if (rocket_score == 6) { |
Ting12138 | 0:ba32cfe0051e | 227 | pad.led(1,1.0f); |
Ting12138 | 0:ba32cfe0051e | 228 | pad.led(2,1.0f); |
Ting12138 | 0:ba32cfe0051e | 229 | pad.led(3,1.0f); |
Ting12138 | 0:ba32cfe0051e | 230 | pad.led(4,1.0f); |
Ting12138 | 0:ba32cfe0051e | 231 | pad.led(5,1.0f); |
Ting12138 | 0:ba32cfe0051e | 232 | pad.led(6,1.0f); |
Ting12138 | 0:ba32cfe0051e | 233 | } |
Ting12138 | 0:ba32cfe0051e | 234 | |
Ting12138 | 0:ba32cfe0051e | 235 | Vector2D rocket_pos = _rocket.get_pos(); // This section also checks the contact between the rocket and the food, where the current position of the rocket and the food is obtained |
Ting12138 | 0:ba32cfe0051e | 236 | |
Ting12138 | 0:ba32cfe0051e | 237 | Vector2D foods_pos = _foods.get_pos(); |
Ting12138 | 0:ba32cfe0051e | 238 | |
Ting12138 | 0:ba32cfe0051e | 239 | if (foods_pos.x <= 1) { // if the food leaves the left side of the screen, replace it to the right side for the next foods retrieval |
Ting12138 | 0:ba32cfe0051e | 240 | _foods.replace(); |
Ting12138 | 0:ba32cfe0051e | 241 | } |
Ting12138 | 0:ba32cfe0051e | 242 | |
Ting12138 | 0:ba32cfe0051e | 243 | if ( |
Ting12138 | 0:ba32cfe0051e | 244 | (rocket_pos.y + 4 >= foods_pos.y - _foods_size) && (rocket_pos.y + 2 <= foods_pos.y + _foods_size) // check if rrocket and the foods are overlap |
Ting12138 | 0:ba32cfe0051e | 245 | && //bottom |
Ting12138 | 0:ba32cfe0051e | 246 | (rocket_pos.x + 10 >= foods_pos.x) && (rocket_pos.x + 10 <= foods_pos.x + 1) //right |
Ting12138 | 0:ba32cfe0051e | 247 | ) { |
Ting12138 | 0:ba32cfe0051e | 248 | // if it has, fix position and reflect x velocity |
Ting12138 | 0:ba32cfe0051e | 249 | _rocket.add_score(); |
Ting12138 | 0:ba32cfe0051e | 250 | pad.tone(550.0,0.25); |
Ting12138 | 0:ba32cfe0051e | 251 | wait(0.25); |
Ting12138 | 0:ba32cfe0051e | 252 | pad.tone(1500.0,0.25); |
Ting12138 | 0:ba32cfe0051e | 253 | wait(0.25); |
Ting12138 | 0:ba32cfe0051e | 254 | } |
Ting12138 | 0:ba32cfe0051e | 255 | } |
Ting12138 | 0:ba32cfe0051e | 256 | |
Ting12138 | 0:ba32cfe0051e | 257 | int Engine::get_final_score() { // get score for the main function to determine the ending |
Ting12138 | 0:ba32cfe0051e | 258 | return _rocket.get_final_score(); |
Ting12138 | 0:ba32cfe0051e | 259 | } |