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: Fire/Fire.cpp
- Revision:
- 21:20478f086bc2
- Parent:
- 18:304700b5d8f8
- Child:
- 26:4253656c0755
--- a/Fire/Fire.cpp Tue Apr 16 19:19:43 2019 +0000 +++ b/Fire/Fire.cpp Sat Apr 20 14:46:50 2019 +0000 @@ -23,21 +23,19 @@ 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; +void Fire::generate_fire() { + _x++; // Keep fire moving from L to R. + _fire_counter = !_fire_counter; // Toggle fire counter to generate different + // sprites each iteration. + if (_x == 90) _x = -10; // If the fire goes off the screen, restart it on the + // other side. } int * Fire::get_fire_sprite() { - // Return a different fire sprite on each iteration. if (_fire_counter) { return *fire_one; } else { @@ -52,3 +50,4 @@ +