Skip to content

Commit 6fdc89d

Browse files
committed
Adding sparks
1 parent e74d69a commit 6fdc89d

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/main.cpp

+12-6
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,18 @@ void loop() {
100100
for(int y = 0; y < FIRE_HEIGHT - 1; y++)
101101
for(int x = 0; x < FIRE_WIDTH; x++)
102102
{
103-
fire[y][x] =
104-
((fire[(y + 1) % FIRE_HEIGHT][(x - 1 + FIRE_WIDTH) % FIRE_WIDTH]
105-
+ fire[(y + 1) % FIRE_HEIGHT][(x) % FIRE_WIDTH]
106-
+ fire[(y + 1) % FIRE_HEIGHT][(x + 1) % FIRE_WIDTH]
107-
+ fire[(y + 2) % FIRE_HEIGHT][(x) % FIRE_WIDTH])
108-
* 32) / 132;
103+
// Once in a great while, add in a white spot.
104+
if (random(100000000) < y * y) { // Desperate attempt to bias then to the bottom.
105+
fire[y][x] = 255;
106+
}
107+
else {
108+
fire[y][x] =
109+
((fire[(y + 1) % FIRE_HEIGHT][(x - 1 + FIRE_WIDTH) % FIRE_WIDTH]
110+
+ fire[(y + 1) % FIRE_HEIGHT][(x) % FIRE_WIDTH]
111+
+ fire[(y + 1) % FIRE_HEIGHT][(x + 1) % FIRE_WIDTH]
112+
+ fire[(y + 2) % FIRE_HEIGHT][(x) % FIRE_WIDTH])
113+
* 32) / 132;
114+
}
109115
}
110116

111117
// Draw fire

0 commit comments

Comments
 (0)