SnakeEffect now has a shorter tail.
This commit is contained in:
parent
29e136b8db
commit
12c5bc229d
@ -2,22 +2,22 @@
|
|||||||
#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++;
|
|
||||||
} else if (r==1 && valid_position(update_position(this->coords, direction-1))) {
|
|
||||||
direction--;
|
|
||||||
} else if (!valid_position(update_position(this->coords, direction))) {
|
|
||||||
if (valid_position(update_position(this->coords, direction+1))) {
|
|
||||||
direction++;
|
direction++;
|
||||||
} else if (valid_position(update_position(this->coords, direction-1))) {
|
} else if (r==1 && valid_position(update_position(this->coords, direction-1))) {
|
||||||
direction--;
|
direction--;
|
||||||
|
} else if (!valid_position(update_position(this->coords, direction))) {
|
||||||
|
if (valid_position(update_position(this->coords, direction+1))) {
|
||||||
|
direction++;
|
||||||
|
} else if (valid_position(update_position(this->coords, direction-1))) {
|
||||||
|
direction--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
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));
|
||||||
|
Loading…
Reference in New Issue
Block a user