SnakeEffect now has a shorter tail.

This commit is contained in:
Fabian Schlenz 2019-05-31 23:58:58 +02:00
parent 29e136b8db
commit 12c5bc229d

View File

@ -2,8 +2,7 @@
#include "functions.h" #include "functions.h"
void SnakeEffect::loop() { void SnakeEffect::loop() {
if (run++ % EFFECT_SNAKE_SLOWDOWN) return; if (run++ % EFFECT_SNAKE_SLOWDOWN == 0) { // Change the coordinates only on every n-th run.
uint8_t r = random8(EFFECT_SNAKE_DIRECTION_CHANGE); uint8_t r = random8(EFFECT_SNAKE_DIRECTION_CHANGE);
if (r==0 && valid_position(update_position(this->coords, direction+1))) { if (r==0 && valid_position(update_position(this->coords, direction+1))) {
direction++; direction++;
@ -18,6 +17,7 @@ void SnakeEffect::loop() {
} }
this->coords = update_position(this->coords, direction); this->coords = update_position(this->coords, direction);
}
fadeToBlackBy(leds, LED_COUNT, 2); fadeToBlackBy(leds, LED_COUNT, 2);
setPixel(window, this->coords.x, this->coords.y, CHSV(hue, 200, 255)); setPixel(window, this->coords.x, this->coords.y, CHSV(hue, 200, 255));