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.
Explosion/Explosion.cpp
- Committer:
- evanso
- Date:
- 2020-05-25
- Revision:
- 82:3211b31e9421
- Parent:
- 36:27aa597db3d2
- Child:
- 85:87bc28b151d8
File content as of revision 82:3211b31e9421:
#include "Explosion.h"
// Defining animation states for explotion FSM
Animation animation_fsm[2] = {
{false, true, FILL_WHITE, FILL_BLACK},
{true, false, FILL_TRANSPARENT, FILL_WHITE},
};
Explosion::Explosion() {
}
Explosion::~Explosion() {
}
void Explosion::init(Vector2D destroyed_position) {
// Assign values to variables
position_x_ = destroyed_position.x + 3;
position_y_ = destroyed_position.y + 3;
fsm_counter_ = 0;
explosion_radius_ = 4;
draw_counter = 0;
}
void Explosion::draw_explosion(N5110 &lcd) {
// Draws each explotion frame depending on state
// Draw circle one
if(animation_fsm[fsm_counter_].draw_circle_one) {
lcd.drawCircle(position_x_, position_y_,explosion_radius_ + 1,
animation_fsm[fsm_counter_].circle_one);
}
// Draw circle two
if(animation_fsm[fsm_counter_].draw_circle_two) {
lcd.drawCircle(position_x_, position_y_,(explosion_radius_ - 2),
animation_fsm[fsm_counter_].circle_two);
}
// Slows down annimation change time, so eplosion animation is longer
if (draw_counter%2 == 0) {
explosion_radius_++;
fsm_counter_ = !fsm_counter_;
}
draw_counter++;
}
int Explosion::get_explosion_radius() {
return explosion_radius_;
}