Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Imposs/ImpossEngine.cpp
- Committer:
- ll17lrc
- Date:
- 2020-05-16
- Revision:
- 2:823dea76ff2e
- Child:
- 3:4494e6928194
File content as of revision 2:823dea76ff2e:
#include "ImpossEngine.h" #include "Zero.h" ImpossEngine::ImpossEngine() { } ImpossEngine::~ImpossEngine() { } void PongEngine::read_input(Gamepad &pad) { _d = pad.get_direction(); _mag = pad.get_mag(); } void ImpossEngine::draw(N5110 &lcd) { // draw the elements in the LCD buffer // pitch _ball.draw(lcd); if (level == 0){ zero.draw(lcd); } if (level == 1){ one.draw(lcd); } if } void ImpossEngine::update(Gamepad &pad) { _ball.update(_d); check_collision(pad); check_finish(pad); } void ImpossEngine::check_collision(Gamepad &pad) { int _x = 0; int _y = 0; bool collision = false; //check around ball to see if it has made contact with anything while(i = 0;i < 4;i++){ if(lcd.getPixel(ball_x_pos + _x,ball_y_pos + _y) == 1){ collision = true; } _x ++; } while(i = 0;i < 4;i++){ if(lcd.getPixel(ball_x_pos + _x,ball_y_pos + _y) == 1){ collision = true; } _y ++; } while(i = 0;i < 4;i++){ if(lcd.getPixel(ball_x_pos + _x,ball_y_pos + _y) == 1){ collision = true; } _x --; } while(i = 0;i < 4;i++){ if(lcd.getPixel(ball_x_pos + _x,ball_y_pos + _y) == 1){ collision = true; } _y --; if(collision == true){ ball_x_pos = 0; ball_y_pos = 21; } } void ImpossEngine::check_finish(Gamepad &pad) { if(ball_x_pos == 82){ level ++; ball_x_pos = 0; ball_y_pos = 21; } }