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
Spikes/Spikes.cpp
- Committer:
- el18jgb
- Date:
- 2020-05-18
- Revision:
- 13:cfdfe60a2327
- Parent:
- Spikes.cpp@ 10:6c574b8524df
- Child:
- 17:18ae81180853
File content as of revision 13:cfdfe60a2327:
#include "Spikes.h" const int spike [5][5] = { {0,0,1,0,0}, {0,0,1,0,0}, {1,1,1,1,1}, {0,1,1,1,0}, {0,0,1,0,0}, }; Spikes::Spikes() { } Spikes::~Spikes() { } void Spikes::init(){ _x = 0; _y = 0; _height = 5; _width = 5; _speed = 3; } void Spikes::draw(N5110 &lcd) { // draw spike lcd.drawSprite(_x,_y,5,5,(int*)spike); } void Spikes::position(int x) { if (x == 1){ _x = rand() % 37 + 1; _y = 1; } if (x == 2){ _x = rand() % 37 + 42; _y = 1; } } void Spikes::update() { _y = _y + 3; } Vector2D Spikes::get_pos() { Vector2D p = {_x,_y}; return p; } void Spikes::hit(Gamepad &pad) { pad.led(1,1); pad.led(4,1); }