If the code hasn't been touched in this long, its probably release-worthy.

This commit is contained in:
2022-06-11 11:02:27 +02:00
parent 0c9eb831dd
commit d14fa7fde1
59 changed files with 1610 additions and 842 deletions

View File

@@ -1,47 +1,33 @@
#pragma once
#include "Flashlight.h"
#include "../Static.h"
#include <Figments.h>
#include "../sprites/Blob.h"
class Flashlight: public Figment {
public:
Flashlight(Task::State initialState) : Figment("Flashlight", initialState) {
m_blobs.forEach([](Blob &blob) {
blob.setHue(random(255));
blob.setSaturation(10);
blob.setPos(random(255));
});
}
void handleEvent(const InputEvent& evt) override {
if (evt.intent == InputEvent::Acceleration) {
if (evt.asInt() > 10) {
m_blobs.forEach([](Blob& blob) {blob.update();});
}
Flashlight::Flashlight() : Figment("Flashlight", Task::Stopped) {
m_blobs.forEach([](Blob &blob) {
blob.setHue(random(255));
blob.setSaturation(10);
blob.setPos(random(255));
if (random(255) >= 128) {
blob.setVelocity(-1);
}
});
}
/*if (evt.intent() == InputEvent::UserInput) {
if (evt.asInt() == 1) {
m_blobs.forEach([](Blob& blob) {blob.setPos(random(255));});
}
if (evt.asInt() == 2) {
m_blobs.forEach([](Blob& chime) {blob.setPos(0);});
}
}*/
}
void loop() override {
m_blobs.update();
}
void render(Display* dpy) const override {
m_blobs.render(dpy);
for(int i = 0; i < dpy->pixelCount();i++) {
dpy->pixelAt(i) |= 100;
void Flashlight::handleEvent(const InputEvent& evt) {
if (evt.intent == InputEvent::Acceleration) {
if (evt.asInt() > 10) {
m_blobs.forEach([](Blob& blob) {blob.update();});
}
}
}
}
private:
static constexpr int blobCount = 30;
SpriteList<Blob, blobCount> m_blobs;
};
void Flashlight::loop() {
m_blobs.update();
}
void Flashlight::render(Display* dpy) const {
m_blobs.render(dpy);
Surface(dpy, {0, 0}, {255, 0}) |= 100;
}
STATIC_ALLOC(Flashlight);
STATIC_TASK(Flashlight);