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
Diff: Spikes/Spikes.cpp
- Revision:
- 16:331be5c7ed80
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Spikes/Spikes.cpp Wed Apr 10 13:40:58 2019 +0000 @@ -0,0 +1,51 @@ +#include "Spikes.h" + +// Define sprite arrays. +int spikes_angle[5][8] = { + { 1,0,1,0,0,1,0,0 }, + { 1,0,0,0,1,1,1,0 }, + { 0,0,0,1,1,1,1,1 }, + { 0,1,0,0,1,1,1,0 }, + { 1,0,0,1,0,1,0,0 }, +}; + +int spikes_flat[5][8] = { + { 0,0,1,0,0,1,0,0 }, + { 0,1,0,0,1,1,1,0 }, + { 1,0,1,0,1,1,1,0 }, + { 1,0,0,0,1,1,1,0 }, + { 0,1,0,1,1,0,0,0 }, +}; + +// Constructor and destructor. +Spikes::Spikes() {} + +Spikes::~Spikes() {} + +void Spikes::init() { + _x = -10; + _spikes_counter = 0; +} + +void Spikes::update_spikes() { + _x++; + _spikes_counter++; + if (_spikes_counter == 2) _spikes_counter = 0; + if (_x == 90) _x = -10; +} + +int * Spikes::get_spikes_sprite() { + if (_spikes_counter == 1) { + return *spikes_angle; + } else { + return *spikes_flat; + } +} + +int Spikes::get_spikes_x() { + return _x; +} + + + +