XJEL2645 (19/20)
/
el17ll
Liu Liting 201199465
Revision 13:a57a48e5e256, committed 2020-05-14
- Comitter:
- Ting12138
- Date:
- Thu May 14 15:42:14 2020 +0000
- Parent:
- 12:3b7811c3502c
- Commit message:
- the 2645 project
Changed in this revision
diff -r 3b7811c3502c -r a57a48e5e256 Engine/Engine.cpp --- a/Engine/Engine.cpp Thu May 14 14:10:49 2020 +0000 +++ b/Engine/Engine.cpp Thu May 14 15:42:14 2020 +0000 @@ -12,14 +12,14 @@ void Engine::init(int wall_width,int wall_gap,int foods_bulk,int velocity) { - // initialise the game parameters + // initialise for the game parameters _wall_width = wall_width; - _wall_gap = wall_gap; // wall gap presents the distance between the top wall and the bottom wall, which is licked to difficulty + _wall_gap = wall_gap; // the wall gap presents and the distance between the top wall and the bottom wall, which is licked to difficulty _foods_bulk = foods_bulk; // larger foods means it will have larger area to trigger it "_rocket.add_score();" _velocity = velocity; - // x position on screen - WIDTH is defined in N5110.h - _w0x = WIDTH; // there is total 5 types of wall in the game, all are placed in distributed positions + // x locations on screen - WIDTH is defined in N5110.h + _w0x = WIDTH; // there is total 5 types of wall in the game, all are placed in distributed locationss _w1x = WIDTH + 30; _w2x = WIDTH + 60; _w3x = WIDTH + 90; @@ -32,11 +32,11 @@ _w2.init(_w2x,_wall_gap,_wall_width,_velocity); _w3.init(_w3x,_wall_gap,_wall_width,_velocity); _w4.init(_w4x,_wall_gap,_wall_width,_velocity); - _rocket.init(_rocketx); // set the rocket in the middle - _foods.init(_foodsx,_foods_bulk,_velocity); // initiate foods bulk and a random y position + _rocket.init(_rocketx); // seting the rocket in the middle location + _foods.init(_foodsx,_foods_bulk,_velocity); // initiate foods bulk and a random locations of the y } -void Engine::read_input(Gamepad &pad) { // get joystick reading +void Engine::read_input(Gamepad &pad) { // reading the joystick finction _d = pad.get_direction(); _mag = pad.get_mag(); @@ -44,10 +44,10 @@ } void Engine::draw(N5110 &lcd) { - // draw the elements in the LCD buffer - // pitch + // draw all elements on the LCD buffer + // the pitch lcd.drawRect(0,0,WIDTH,HEIGHT,FILL_TRANSPARENT); - // walls + // all walls _w0.draw1(lcd); _w0.draw2(lcd); _w1.draw1(lcd); @@ -60,18 +60,18 @@ _w4.draw2(lcd); // the rocket _rocket.draw(lcd); - // foods + // all foods _foods.draw(lcd); } -void Engine::check_score(Gamepad &pad) { //check the score to trigger how many leds should be turned on +void Engine::check_score(Gamepad &pad) { //checking the score to trigger and how many leds should be turned on - int rocket_score = _rocket.get_final_score(); // get score + int rocket_score = _rocket.get_final_score(); // get the final score - if (rocket_score == 0) { // 7 if statements represents 7 conditions + if (rocket_score == 0) { // 7 if statements to the represents 7 conditions pad.leds_off(); } - if (rocket_score == 1) { // getting one food turns on 1 led + if (rocket_score == 1) { // when getting one food,you can turn on 1 led pad.led(1,1.0f); pad.led(2,0.0f); pad.led(2,0.0f); @@ -79,7 +79,7 @@ pad.led(2,0.0f); pad.led(2,0.0f); } - if (rocket_score == 2) { // two foodds, two led + if (rocket_score == 2) { // when you get two foods, you will light lcd1 and lcd6 pad.led(1,1.0f); pad.led(2,0.0f); pad.led(3,0.0f); @@ -87,7 +87,7 @@ pad.led(5,0.0f); pad.led(6,1.0f); } - if (rocket_score == 3) { + if (rocket_score == 3) {// when you get two foods, you will light lcd1, lcd6 and lcd2 pad.led(1,1.0f); pad.led(2,1.0f); pad.led(3,0.0f); @@ -95,7 +95,7 @@ pad.led(5,0.0f); pad.led(6,1.0f); } - if (rocket_score == 4) { + if (rocket_score == 4) {// when you get two foods, you will light led1, led6,led5 and led2 pad.led(1,1.0f); pad.led(2,1.0f); pad.led(3,0.0f); @@ -103,7 +103,7 @@ pad.led(5,1.0f); pad.led(6,1.0f); } - if (rocket_score == 5) { + if (rocket_score == 5) {// when you get two foods, you will light leds except led4 pad.led(1,1.0f); pad.led(2,1.0f); pad.led(3,1.0f); @@ -111,7 +111,7 @@ pad.led(5,1.0f); pad.led(6,1.0f); } - if (rocket_score == 6) { + if (rocket_score == 6) {// when you get two foods, you will light all led pad.led(1,1.0f); pad.led(2,1.0f); pad.led(3,1.0f); @@ -120,9 +120,9 @@ pad.led(6,1.0f); } - 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 + Vector2D rocket_pos = _rocket.get_locations(); // the goal of this section is checking the contact between the rocket and the food, where the current locations of the rocket and the food is obtained - Vector2D foods_pos = _foods.get_pos(); + Vector2D foods_pos = _foods.get_locations(); 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 _foods.replace(); @@ -130,10 +130,10 @@ if ( (rocket_pos.y + 4 >= foods_pos.y - _foods_bulk) && (rocket_pos.y + 2 <= foods_pos.y + _foods_bulk) // check if rrocket and the foods are overlap - && //bottom + && //aat the bottom (rocket_pos.x + 10 >= foods_pos.x) && (rocket_pos.x + 10 <= foods_pos.x + 1) //right ) { - // if it has, fix position and reflect x velocity + // if it happen this situation , fixing locations and reflecting x velocity _rocket.add_score(); pad.tone(550.0,0.25); wait(0.25); @@ -159,17 +159,17 @@ void Engine::collision(Gamepad &pad) { - // read the position of rocket - Vector2D rocket_pos = _rocket.get_pos(); + // reading the right locations of rocket + Vector2D rocket_pos = _rocket.get_locations(); - //read all of these positions of the FIVE wall + //read all of these locationss of the FIVE wall int w0_x = _w0.get_x(); int w1_x = _w1.get_x(); int w2_x = _w2.get_x(); int w3_x = _w3.get_x(); int w4_x = _w4.get_x(); - if (w0_x <= 1) { // When the rocket passes behind the wall, it will reset to its original position to continue the game + if (w0_x <= 1) { // When the rocket passes behind the wall, it will reset to its original locations to continue the game _w0.reset(); } if (w1_x <= 1) { @@ -256,6 +256,6 @@ -int Engine::get_final_score() { // get score for the main function to determine the ending +int Engine::get_final_score() { // get thefinal score for the main function to determine the ending return _rocket.get_final_score(); } \ No newline at end of file
diff -r 3b7811c3502c -r a57a48e5e256 Gamepad.lib --- a/Gamepad.lib Thu May 14 14:10:49 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://os.mbed.com/users/eencae/code/Gamepad/#c0959710291b
diff -r 3b7811c3502c -r a57a48e5e256 Gamepad/Gamepad.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Gamepad/Gamepad.cpp Thu May 14 15:42:14 2020 +0000 @@ -0,0 +1,341 @@ +#include "Gamepad.h" + +#include "mbed.h" + +//////////// constructor/destructor //////////// +Gamepad::Gamepad() + : + _led1(new PwmOut(PTA1)), + _led2(new PwmOut(PTA2)), + _led3(new PwmOut(PTC2)), + _led4(new PwmOut(PTC3)), + _led5(new PwmOut(PTC4)), + _led6(new PwmOut(PTD3)), + + _button_A(new InterruptIn(PTB9)), + _button_B(new InterruptIn(PTD0)), + _button_X(new InterruptIn(PTC17)), + _button_Y(new InterruptIn(PTC12)), + _button_L(new InterruptIn(PTB18)), + _button_R(new InterruptIn(PTB3)), + _button_back(new InterruptIn(PTB19)), + _button_start(new InterruptIn(PTC5)), + _button_joystick(new InterruptIn(PTC16)), + + _vert(new AnalogIn(PTB10)), + _horiz(new AnalogIn(PTB11)), + + _buzzer(new PwmOut(PTC10)), + _pot(new AnalogIn(PTB2)), + + _timeout(new Timeout()), + + _event_state(0), + + _x0(0), + _y0(0) +{} + +Gamepad::~Gamepad() +{ + delete _led1,_led2,_led3,_led4,_led5,_led6; + delete _button_A,_button_B,_button_joystick,_vert,_horiz; + delete _button_X,_button_Y,_button_back,_button_start; + delete _button_L,_button_R, _buzzer, _pot, _timeout; +} + +///////////////// public methods ///////////////// + +void Gamepad::init() +{ + leds_off(); + init_buttons(); + + // read centred values of joystick + _x0 = _horiz->read(); + _y0 = _vert->read(); + + // clear all flags + _event_state = 0; +} + +void Gamepad::leds_off() +{ + leds(0.0); +} + +void Gamepad::leds_on() +{ + leds(1.0); +} + +void Gamepad::leds(float val) const +{ + if (val < 0.0f) { + val = 0.0f; + } + if (val > 1.0f) { + val = 1.0f; + } + + // leds are active-low, so subtract from 1.0 + // 0.0 corresponds to fully-off, 1.0 to fully-on + val = 1.0f - val; + + _led1->write(val); + _led2->write(val); + _led3->write(val); + _led4->write(val); + _led5->write(val); + _led6->write(val); +} + +void Gamepad::led(int n,float val) const +{ + // ensure they are within vlaid range + if (val < 0.0f) { + val = 0.0f; + } + if (val > 1.0f) { + val = 1.0f; + } + + switch (n) { + + // check for valid LED number and set value + + case 1: + _led1->write(1.0f-val); // active-low so subtract from 1 + break; + case 2: + _led2->write(1.0f-val); // active-low so subtract from 1 + break; + case 3: + _led3->write(1.0f-val); // active-low so subtract from 1 + break; + case 4: + _led4->write(1.0f-val); // active-low so subtract from 1 + break; + case 5: + _led5->write(1.0f-val); // active-low so subtract from 1 + break; + case 6: + _led6->write(1.0f-val); // active-low so subtract from 1 + break; + + } +} + +float Gamepad::read_pot() const +{ + return _pot->read(); +} + +void Gamepad::tone(float frequency, float duration) +{ + _buzzer->period(1.0f/frequency); + _buzzer->write(0.5); // 50% duty cycle - square wave + _timeout->attach(callback(this, &Gamepad::tone_off), duration ); +} + +bool Gamepad::check_event(GamepadEvent const id) +{ + // Check whether event flag is set + if (_event_state[id]) { + _event_state.reset(id); // clear flag + return true; + } else { + return false; + } +} + +// this method gets the magnitude of the joystick movement +float Gamepad::get_mag() +{ + Polar p = get_polar(); + return p.mag; +} + +// this method gets the angle of joystick movement (0 to 360, 0 North) +float Gamepad::get_angle() +{ + Polar p = get_polar(); + return p.angle; +} + +Direction Gamepad::get_direction() +{ + float angle = get_angle(); // 0 to 360, -1 for centred + + Direction d; + // partition 360 into segments and check which segment the angle is in + if (angle < 0.0f) { + d = CENTRE; // check for -1.0 angle + } else if (angle < 22.5f) { // then keep going in 45 degree increments + d = N; + } else if (angle < 67.5f) { + d = NE; + } else if (angle < 112.5f) { + d = E; + } else if (angle < 157.5f) { + d = SE; + } else if (angle < 202.5f) { + d = S; + } else if (angle < 247.5f) { + d = SW; + } else if (angle < 292.5f) { + d = W; + } else if (angle < 337.5f) { + d = NW; + } else { + d = N; + } + + return d; +} + +///////////////////// private methods //////////////////////// + +void Gamepad::tone_off() +{ + // called after timeout + _buzzer->write(0.0); +} + +void Gamepad::init_buttons() +{ + // turn on pull-downs as other side of button is connected to 3V3 + // button is 0 when not pressed and 1 when pressed + _button_A->mode(PullDown); + _button_B->mode(PullDown); + _button_X->mode(PullDown); + _button_Y->mode(PullDown); + _button_back->mode(PullDown); + _button_start->mode(PullDown); + _button_L->mode(PullDown); + _button_R->mode(PullDown); + _button_joystick->mode(PullDown); + // therefore setup rising edge interrupts + _button_A->rise(callback(this,&Gamepad::a_isr)); + _button_B->rise(callback(this,&Gamepad::b_isr)); + _button_X->rise(callback(this,&Gamepad::x_isr)); + _button_Y->rise(callback(this,&Gamepad::y_isr)); + _button_L->rise(callback(this,&Gamepad::l_isr)); + _button_R->rise(callback(this,&Gamepad::r_isr)); + _button_start->rise(callback(this,&Gamepad::start_isr)); + _button_back->rise(callback(this,&Gamepad::back_isr)); + _button_joystick->rise(callback(this,&Gamepad::joy_isr)); +} + +// button interrupts ISRs +// Each of these simply sets the appropriate event bit in the _event_state +// variable +void Gamepad::a_isr() +{ + _event_state.set(A_PRESSED); +} +void Gamepad::b_isr() +{ + _event_state.set(B_PRESSED); +} +void Gamepad::x_isr() +{ + _event_state.set(X_PRESSED); +} +void Gamepad::y_isr() +{ + _event_state.set(Y_PRESSED); +} +void Gamepad::l_isr() +{ + _event_state.set(L_PRESSED); +} +void Gamepad::r_isr() +{ + _event_state.set(R_PRESSED); +} +void Gamepad::back_isr() +{ + _event_state.set(BACK_PRESSED); +} +void Gamepad::start_isr() +{ + _event_state.set(START_PRESSED); +} +void Gamepad::joy_isr() +{ + _event_state.set(JOY_PRESSED); +} + +// get raw joystick coordinate in range -1 to 1 +// Direction (x,y) +// North (0,1) +// East (1,0) +// South (0,-1) +// West (-1,0) +Vector2D Gamepad::get_coord() +{ + // read() returns value in range 0.0 to 1.0 so is scaled and centre value + // substracted to get values in the range -1.0 to 1.0 + float x = 2.0f*( _horiz->read() - _x0 ); + float y = 2.0f*( _vert->read() - _y0 ); + + // Note: the x value here is inverted to ensure the positive x is to the + // right. This is simply due to how the potentiometer on the joystick + // I was using was connected up. It could have been corrected in hardware + // by swapping the power supply pins. Instead it is done in software so may + // need to be changed depending on your wiring setup + + Vector2D coord = {-x,y}; + return coord; +} + +// This maps the raw x,y coord onto a circular grid. +// See: http://mathproofs.blogspot.co.uk/2005/07/mapping-square-to-circle.html +Vector2D Gamepad::get_mapped_coord() +{ + Vector2D coord = get_coord(); + + // do the transformation + float x = coord.x*sqrt(1.0f-pow(coord.y,2.0f)/2.0f); + float y = coord.y*sqrt(1.0f-pow(coord.x,2.0f)/2.0f); + + Vector2D mapped_coord = {x,y}; + return mapped_coord; +} + +// this function converts the mapped coordinates into polar form +Polar Gamepad::get_polar() +{ + // get the mapped coordinate + Vector2D coord = get_mapped_coord(); + + // at this point, 0 degrees (i.e. x-axis) will be defined to the East. + // We want 0 degrees to correspond to North and increase clockwise to 359 + // like a compass heading, so we need to swap the axis and invert y + float x = coord.y; + float y = coord.x; + + float mag = sqrt(x*x+y*y); // pythagoras + float angle = RAD2DEG*atan2(y,x); + // angle will be in range -180 to 180, so add 360 to negative angles to + // move to 0 to 360 range + if (angle < 0.0f) { + angle+=360.0f; + } + + // the noise on the ADC causes the values of x and y to fluctuate slightly + // around the centred values. This causes the random angle values to get + // calculated when the joystick is centred and untouched. This is also when + // the magnitude is very small, so we can check for a small magnitude and then + // set the angle to -1. This will inform us when the angle is invalid and the + // joystick is centred + + if (mag < TOL) { + mag = 0.0f; + angle = -1.0f; + } + + Polar p = {mag,angle}; + return p; +} \ No newline at end of file
diff -r 3b7811c3502c -r a57a48e5e256 Gamepad/Gamepad.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Gamepad/Gamepad.h Thu May 14 15:42:14 2020 +0000 @@ -0,0 +1,205 @@ +#ifndef GAMEPAD_H +#define GAMEPAD_H + +#include <bitset> + +// Forward declaration of the classes that we use from the mbed library +// This avoids the need for us to include the huge mbed.h header inside our +// own library API +namespace mbed +{ +class AnalogIn; +class InterruptIn; +class PwmOut; +class Timeout; +} + +#define TOL 0.1f +#define RAD2DEG 57.2957795131f + +/** Enum for direction */ +enum Direction { + CENTRE, /**< joystick centred */ + N, /**< pushed North (0)*/ + NE, /**< pushed North-East (45) */ + E, /**< pushed East (90) */ + SE, /**< pushed South-East (135) */ + S, /**< pushed South (180) */ + SW, /**< pushed South-West (225) */ + W, /**< pushed West (270) */ + NW /**< pushed North-West (315) */ +}; + +/** Vector 2D struct */ +struct Vector2D { + float x; /**< float for x value */ + float y; /**< float for y value */ +}; + +/** Polar coordinate struct */ +struct Polar { + float mag; /**< float for magnitude */ + float angle; /**< float for angle (in degrees) */ +}; + +/** Gamepad Class + * @brief Library for interfacing with ELEC2645 Gamepad PCB, University of Leeds + * @author Dr Craig A. Evans + * @author Dr Alex Valavanis + */ +class Gamepad +{ +public: +/** Gamepad events + * @brief List of events that can be registered on the gamepad + */ +enum GamepadEvent { + A_PRESSED, ///< Button A has been pressed + B_PRESSED, ///< Button B has been pressed + X_PRESSED, ///< Button X has been pressed + Y_PRESSED, ///< Button Y has been pressed + L_PRESSED, ///< Button L has been pressed + R_PRESSED, ///< Button R has been pressed + BACK_PRESSED, ///< Button "Back" has been pressed + START_PRESSED, ///< Button "Start" has been pressed + JOY_PRESSED, ///< Joystick button has been pressed + N_EVENTS ///< A dummy flag that marks the end of the list +}; + +private: + mbed::PwmOut *_led1; + mbed::PwmOut *_led2; + mbed::PwmOut *_led3; + mbed::PwmOut *_led4; + mbed::PwmOut *_led5; + mbed::PwmOut *_led6; + + mbed::InterruptIn *_button_A; + mbed::InterruptIn *_button_B; + mbed::InterruptIn *_button_X; + mbed::InterruptIn *_button_Y; + mbed::InterruptIn *_button_L; + mbed::InterruptIn *_button_R; + mbed::InterruptIn *_button_back; + mbed::InterruptIn *_button_start; + mbed::InterruptIn *_button_joystick; + + mbed::AnalogIn *_vert; + mbed::AnalogIn *_horiz; + + mbed::PwmOut *_buzzer; + mbed::AnalogIn *_pot; + + mbed::Timeout *_timeout; + + std::bitset<N_EVENTS> _event_state; ///< A binary list of buttons that has been pressed + + // centred x,y values + float _x0; + float _y0; + +public: + /** Constructor */ + Gamepad(); + + /** Destructor */ + ~Gamepad(); + + /** Initialise all peripherals and configure interrupts */ + void init(); + + /** Turn all LEDs on */ + void leds_on(); + + /** Turn all LEDs off */ + void leds_off(); + + /** Set all LEDs to duty-cycle + *@param value in range 0.0 to 1.0 + */ + void leds(float val) const; + + /** Set LED to duty-cycle + *@param led number (0 to 5) + *@param value in range 0.0 to 1.0 + */ + void led(int n,float val) const; + + /** Read potentiometer + *@returns potentiometer value in range 0.0 to 1.0 + */ + float read_pot() const; + + /** Play tone on piezo + * @param frequency in Hz + * @param duration of tone in seconds + */ + void tone(float frequency, float duration); + + /** + * @brief Check whether an event flag has been set and clear it + * @param id[in] The ID of the event to test + * @return true if the event occurred + */ + bool check_event(GamepadEvent const id); + + /** + * @brief Get the raw binary event state + * @return The event state as a binary code + * @details The check_event() function is likely to be more useful than + * this, for testing whether a given event has occurred. It can be + * useful for debugging via the terminal, however, for example: + * @code + * std::cout << gamepad.get_raw_event_state() << std::endl; + * @endcode + */ + inline std::bitset<N_EVENTS> get_raw_event_state() const { + return _event_state; + } + + /** Get magnitude of joystick movement + * @returns value in range 0.0 to 1.0 + */ + float get_mag(); + + /** Get angle of joystick movement + * @returns value in range 0.0 to 359.9. 0.0 corresponds to N, 180.0 to S. -1.0 is central + */ + float get_angle(); + + /** Gets joystick direction + * @returns an enum: CENTRE, N, NE, E, SE, S, SW, W, NW, + */ + Direction get_direction(); // N,NE,E,SE etc. + + /** Gets raw cartesian co-ordinates of joystick + * @returns a struct with x,y members, each in the range 0.0 to 1.0 + */ + Vector2D get_coord(); // cartesian co-ordinates x,y + + /** Gets cartesian coordinates mapped to circular grid + * @returns a struct with x,y members, each in the range 0.0 to 1.0 + */ + Vector2D get_mapped_coord(); // x,y mapped to circle + + /** Gets polar coordinates of the joystick + * @returns a struct contains mag and angle + */ + Polar get_polar(); // mag and angle in struct form + +private: + void init_buttons(); + void tone_off(); + + void a_isr(); + void b_isr(); + void x_isr(); + void y_isr(); + void l_isr(); + void r_isr(); + void back_isr(); + void start_isr(); + void joy_isr(); +}; + +#endif \ No newline at end of file
diff -r 3b7811c3502c -r a57a48e5e256 foods/foods.cpp --- a/foods/foods.cpp Thu May 14 14:10:49 2020 +0000 +++ b/foods/foods.cpp Thu May 14 15:42:14 2020 +0000 @@ -10,28 +10,28 @@ } void foods::draw(N5110 &lcd) { - lcd.drawCircle(_x,_y,_bulk,FILL_TRANSPARENT); // draw THE SHAPE OF foods on lcd + lcd.drawCircle(_x,_y,_bulk,FILL_TRANSPARENT); // drawing THE SHAPE OF these foods on the lcd screen } void foods::init(int x,int bulk,int velocity) { - _x = x; // foods x beginning postion and updating position + _x = x; // foods at the beginning postion on the x direction and updating the new location _bulk = bulk; // the food's bulk - int uncertainty = rand() % (48 - _bulk * 2); - _y = _bulk + uncertainty; // the starting vertical position - _velocity = velocity; // sliding velocity + int nondeterminacy = rand() % (48 - _bulk * 2); + _y = _bulk + nondeterminacy; // at the starting vertical locations + _velocity = velocity; // velocity of slide } void foods::update() { - _x -= _velocity; // the foods is moving leftward from the right screen + _x -= _velocity; // the foods the right screen move to leftward } void foods::replace() { - _x = 146; // replace to the right side when the stone exits to the left side of the screen - int uncertainty = rand() % (47 - (_bulk * 2)); - _y = 2 + _bulk + uncertainty; // regenerate the vertical position for the stone + _x = 146; // replaceing to the right side when the stone exits to the left side of the screen + int nondeterminacy = rand() % (47 - (_bulk * 2)); + _y = 2 + _bulk + nondeterminacy; // regenerating the vertical locations for the stone } -Vector2D foods::get_pos() { // get position for collision logic function +Vector2D foods::get_locations() { // get the location when the collision logic function Vector2D p = {_x,_y}; return p; } \ No newline at end of file
diff -r 3b7811c3502c -r a57a48e5e256 foods/foods.h --- a/foods/foods.h Thu May 14 14:10:49 2020 +0000 +++ b/foods/foods.h Thu May 14 15:42:14 2020 +0000 @@ -20,24 +20,24 @@ void draw(N5110 &lcd); // accessors and mutators /** - * @returns The new coordinate of foods - * @brief Updates the position of foods + * returns The new coordinate of foods + * brief Updates the locations of foods */ void update(); /** - * @returns The new coordinate of foods - * @brief Resets the position of foods + * returns The new coordinate of foods + * brief Resets the locations of foods */ void replace(); /** - * @returns The coordinate of foods - * @brief Retrieves the position of foods + * returns The coordinate of foods + * brief Retrieves the locations of foods */ - Vector2D get_pos(); + Vector2D get_locations(); private: - int _bulk; // the radius of the foods + int _bulk; // the foods'raions int _x; int _y; int _velocity;
diff -r 3b7811c3502c -r a57a48e5e256 rocket/rocket.cpp --- a/rocket/rocket.cpp Thu May 14 14:10:49 2020 +0000 +++ b/rocket/rocket.cpp Thu May 14 15:42:14 2020 +0000 @@ -72,7 +72,7 @@ return _score; } -Vector2D rocket::get_pos() { +Vector2D rocket::get_locations() { Vector2D p = {_x,_y}; return p; } \ No newline at end of file
diff -r 3b7811c3502c -r a57a48e5e256 rocket/rocket.h --- a/rocket/rocket.h Thu May 14 14:10:49 2020 +0000 +++ b/rocket/rocket.h Thu May 14 15:42:14 2020 +0000 @@ -33,7 +33,7 @@ * @returns The new coordinate of foods * @brief Updates the position of foods */ - Vector2D get_pos(); + Vector2D get_locations(); void replace(Direction d,float mag,Vector2D mapped_coord); void add_score();
diff -r 3b7811c3502c -r a57a48e5e256 the_wall/the_wall.cpp --- a/the_wall/the_wall.cpp Thu May 14 14:10:49 2020 +0000 +++ b/the_wall/the_wall.cpp Thu May 14 15:42:14 2020 +0000 @@ -13,8 +13,8 @@ void the_wall::init(int x,int gap,int width,int speed) { _x = x; // wall x starting postion and updating position _gap = gap; // gap represents the distance between the wall - int uncertainty = rand() % (47 - _gap); - _height = uncertainty; // get random height for the wall + int nondeterminacy = rand() % (47 - _gap); + _height = nondeterminacy; // get random height for the wall _width = width; // fixed width _speed = speed; // adjuctable speed } @@ -34,8 +34,8 @@ void the_wall::reset() { // when the wall is off from the left screen, replace it back to the right side and continue the game _x = 149; - int uncertainty = rand() % (47 - _gap); - _height = uncertainty; + int nondeterminacy = rand() % (47 - _gap); + _height = nondeterminacy; } int the_wall::get_x() { // get x position and wall height for collision logic function