2019-06-05 04:27:55 +00:00
|
|
|
#pragma once
|
|
|
|
|
2019-09-25 04:30:03 +00:00
|
|
|
#include "prototypes.h"
|
|
|
|
#include "functions.h"
|
2019-06-05 04:27:55 +00:00
|
|
|
#include "Effect.h"
|
|
|
|
|
2019-09-25 04:30:03 +00:00
|
|
|
enum FireworkDotType { FIREWORK_DOT_NONE, FIREWORK_DOT_SHELL, FIREWORK_DOT_SPARK };
|
|
|
|
|
|
|
|
#define EFFECT_FIREWORK_DRAG 255
|
|
|
|
#define EFFECT_FIREWORK_BOUNCE 200
|
|
|
|
#define EFFECT_FIREWORK_GRAVITY 10
|
|
|
|
#define EFFECT_FIREWORK_SPARKS 12
|
|
|
|
|
|
|
|
class FireworkEffect;
|
|
|
|
|
|
|
|
class FireworkEffectDot {
|
|
|
|
private:
|
|
|
|
Window* _window;
|
|
|
|
FireworkEffect* _main;
|
|
|
|
accum88 _x;
|
|
|
|
accum88 _y;
|
|
|
|
saccum78 _xv;
|
|
|
|
saccum78 _yv;
|
|
|
|
accum88 _r;
|
|
|
|
CRGB _color;
|
|
|
|
|
|
|
|
void _screenscale(accum88 a, byte n, byte& screen, byte& screenerr);
|
|
|
|
int16_t _scale15by8_local(int16_t i, fract8 scale);
|
|
|
|
public:
|
|
|
|
byte show;
|
|
|
|
FireworkDotType type;
|
|
|
|
|
|
|
|
FireworkEffectDot(Window* w, FireworkEffect* e);
|
|
|
|
void draw();
|
|
|
|
void move();
|
|
|
|
void ground_launch();
|
|
|
|
void sky_burst(accum88 basex, accum88 basey, saccum78 basedv, CRGB& basecolor);
|
|
|
|
};
|
|
|
|
|
2019-06-05 04:27:55 +00:00
|
|
|
class FireworkEffect : public Effect {
|
2019-09-25 04:30:03 +00:00
|
|
|
private:
|
|
|
|
Window* window = new Window(0, 0, LED_WIDTH, LED_HEIGHT-6);
|
|
|
|
bool _skyburst = 0;
|
|
|
|
|
|
|
|
accum88 _burst_x;
|
|
|
|
accum88 _burst_y;
|
|
|
|
saccum78 _burst_xv;
|
|
|
|
saccum78 _burst_yv;
|
|
|
|
CRGB _burst_color;
|
|
|
|
|
|
|
|
FireworkEffectDot* _dot;
|
|
|
|
FireworkEffectDot* _sparks[EFFECT_FIREWORK_SPARKS];
|
|
|
|
public:
|
|
|
|
FireworkEffect();
|
|
|
|
~FireworkEffect();
|
|
|
|
void skyburst(accum88 x, accum88 y, saccum78 xv, saccum78 yv, CRGB c);
|
|
|
|
boolean supports_window = true;
|
|
|
|
boolean can_be_shown_with_clock();
|
|
|
|
void loop();
|
2019-09-25 16:11:03 +00:00
|
|
|
String get_name() override { return "firework"; }
|
2019-06-05 04:27:55 +00:00
|
|
|
};
|
2019-09-25 04:30:03 +00:00
|
|
|
|