SnakeEffect now has a shorter tail.
This commit is contained in:
		@@ -2,22 +2,22 @@
 | 
			
		||||
#include "functions.h"
 | 
			
		||||
 | 
			
		||||
void SnakeEffect::loop() {
 | 
			
		||||
	if (run++ % EFFECT_SNAKE_SLOWDOWN) return;
 | 
			
		||||
 | 
			
		||||
	uint8_t r = random8(EFFECT_SNAKE_DIRECTION_CHANGE);
 | 
			
		||||
	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))) {
 | 
			
		||||
	if (run++ % EFFECT_SNAKE_SLOWDOWN == 0) { // Change the coordinates only on every n-th run.
 | 
			
		||||
		uint8_t r = random8(EFFECT_SNAKE_DIRECTION_CHANGE);
 | 
			
		||||
		if (r==0 && valid_position(update_position(this->coords, direction+1))) {
 | 
			
		||||
			direction++;
 | 
			
		||||
		} else if (valid_position(update_position(this->coords, direction-1))) {
 | 
			
		||||
		} 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++;
 | 
			
		||||
			} 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);
 | 
			
		||||
 	setPixel(window, this->coords.x, this->coords.y, CHSV(hue, 200, 255));
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user