pitrix/include/effects/firework.h

58 lines
1.2 KiB
C
Raw Normal View History

#pragma once
#include "prototypes.h"
#include "functions.h"
#include "Effect.h"
enum FireworkDotType { FIREWORK_DOT_NONE, FIREWORK_DOT_SHELL, FIREWORK_DOT_SPARK };
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);
};
class FireworkEffect : public Effect {
private:
Window* window = &Window::window_with_clock;
bool _skyburst = 0;
accum88 _burst_x;
accum88 _burst_y;
saccum78 _burst_xv;
saccum78 _burst_yv;
CRGB _burst_color;
FireworkEffectDot* _dot;
FireworkEffectDot** _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(uint16_t ms);
String get_name() override { return "firework"; }
};