Creeper blink
This commit is contained in:
parent
6b4ed1658c
commit
ad16660716
@ -190,23 +190,45 @@ public:
|
|||||||
return countof(sym[0]);
|
return countof(sym[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool doCreeperBlink() {
|
||||||
|
const auto now = millis();
|
||||||
|
static auto blink = false;
|
||||||
|
static auto last = now;
|
||||||
|
if (!blink) {
|
||||||
|
if (now - last >= 3000) {
|
||||||
|
last = now;
|
||||||
|
if (random(3) == 0) {
|
||||||
|
blink = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (now - last >= 500) {
|
||||||
|
last = now;
|
||||||
|
blink = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return blink;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO REMOVE QUICK & DIRTY
|
// TODO REMOVE QUICK & DIRTY
|
||||||
uint8_t printCreeper(uint8_t xPos, uint8_t yPos) {
|
uint8_t printCreeper(uint8_t xPos, uint8_t yPos) {
|
||||||
Color G = GREEN;
|
const auto creeperBlink = doCreeperBlink();
|
||||||
Color I = {128, 255, 128};
|
|
||||||
Color O = BLACK;
|
|
||||||
Color sym[7][7] = {
|
Color sym[7][7] = {
|
||||||
{G, G, G, G, G, G, G},
|
{X, X, X, X, X, X, X},
|
||||||
{G, I, I, I, I, I, G},
|
{X, _, _, X, _, _, X},
|
||||||
{G, I, O, I, O, I, G},
|
{X, _, _, X, _, _, X},
|
||||||
{G, I, I, I, I, I, G},
|
{X, X, X, X, X, X, X},
|
||||||
{G, I, O, O, O, I, G},
|
{X, X, _, _, _, X, X},
|
||||||
{G, I, O, I, O, I, G},
|
{X, X, _, X, _, X, X},
|
||||||
{G, G, G, G, G, G, G},
|
{X, X, X, X, X, X, X},
|
||||||
};
|
};
|
||||||
for (int y = 0; y < countof(sym); ++y) {
|
for (int y = 0; y < countof(sym); ++y) {
|
||||||
for (int x = 0; x < countof(sym[0]); ++x) {
|
for (int x = 0; x < countof(sym[0]); ++x) {
|
||||||
set(xPos + x, yPos + y, sym[y][x]);
|
if (creeperBlink && ((x == 1 || x == 2) && y == 1)) {
|
||||||
|
set(xPos + x, yPos + y, BLACK);
|
||||||
|
} else {
|
||||||
|
set(xPos + x, yPos + y, sym[y][x] ? GREEN : BLACK);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return countof(sym[0]);
|
return countof(sym[0]);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user