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
Fire/Fire.cpp
- Committer:
- lewisgw
- Date:
- 2019-04-12
- Revision:
- 18:304700b5d8f8
- Parent:
- Spikes/Spikes.cpp@ 16:331be5c7ed80
- Child:
- 21:20478f086bc2
File content as of revision 18:304700b5d8f8:
#include "Fire.h" // Define sprite arrays. int fire_one[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 fire_two[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. Fire::Fire() {} Fire::~Fire() {} void Fire::init() { // Initialise the fire ball _x = -10; _fire_counter = false; } void Fire::update_fire() { // On every iteration move the fire horizontally and toggle the fire counter. // If the fire goes off the screen, restart it on the other side. _x++; _fire_counter = !_fire_counter; if (_x == 90) _x = -10; } int * Fire::get_fire_sprite() { // Return a different fire sprite on each iteration. if (_fire_counter) { return *fire_one; } else { return *fire_two; } } int Fire::get_fire_x() { return _x; }