50 lines
961 B
C
50 lines
961 B
C
|
// vim: sw=4 ts=4 sts=4 expandtab
|
||
|
|
||
|
#pragma once
|
||
|
|
||
|
#include <random>
|
||
|
#include <vector>
|
||
|
|
||
|
#include "Animation.h"
|
||
|
|
||
|
#include "fasttrigon.h"
|
||
|
|
||
|
class RacerAnimation : public Animation
|
||
|
{
|
||
|
public:
|
||
|
RacerAnimation(Fader *fader, uint32_t racer_count);
|
||
|
|
||
|
void loop(uint64_t frame) override;
|
||
|
|
||
|
void stop(void) override
|
||
|
{
|
||
|
m_stopping = true;
|
||
|
}
|
||
|
|
||
|
void reset(void) override;
|
||
|
|
||
|
private:
|
||
|
class Racer
|
||
|
{
|
||
|
public:
|
||
|
Racer(Fader *fader, int32_t pos, int32_t speed, const Fader::Color &color);
|
||
|
|
||
|
void move(void);
|
||
|
void render(void) const;
|
||
|
|
||
|
private:
|
||
|
Fader *m_fader;
|
||
|
|
||
|
int32_t m_speed; // in 1/256 LEDs
|
||
|
int32_t m_pos; // in 1/256 LEDs
|
||
|
|
||
|
Fader::Color m_color;
|
||
|
};
|
||
|
|
||
|
std::vector<Racer> m_racers;
|
||
|
|
||
|
std::default_random_engine m_gen;
|
||
|
|
||
|
bool m_stopping;
|
||
|
};
|