I just learned that unintialized variables in C can lead to lots of unexpected and hard-to-debug behaviour... :-/
This commit is contained in:
@ -139,7 +139,9 @@ bool Animation::advance() {
|
||||
}
|
||||
|
||||
void Animation::drawPixel(Window* win, int index, CRGB* color) {
|
||||
win->setPixel(this->xOffset + (index % this->data->w), this->yOffset + (index / this->data->h), color);
|
||||
uint8_t x = this->xOffset + (index % this->data->w);
|
||||
uint8_t y = this->yOffset + (index / this->data->h);
|
||||
win->setPixel(x, y, color);
|
||||
}
|
||||
|
||||
uint16_t Animation::getFrameDelay(int frame) {
|
||||
@ -149,6 +151,6 @@ uint16_t Animation::getFrameDelay(int frame) {
|
||||
|
||||
CRGB* Animation::getColor(uint8_t index) {
|
||||
if (index==1) return this->bgColor;
|
||||
else if (this->fgColor) return this->fgColor;
|
||||
else return &this->colors[index - 2];
|
||||
else if (this->fgColor != NULL) return this->fgColor;
|
||||
else return &(this->colors[index - 2]);
|
||||
}
|
||||
|
Reference in New Issue
Block a user