Skip to content

Commit

Permalink
Adding sparks
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveVdE committed Jan 17, 2021
1 parent e74d69a commit 6fdc89d
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,18 @@ void loop() {
for(int y = 0; y < FIRE_HEIGHT - 1; y++)
for(int x = 0; x < FIRE_WIDTH; x++)
{
fire[y][x] =
((fire[(y + 1) % FIRE_HEIGHT][(x - 1 + FIRE_WIDTH) % FIRE_WIDTH]
+ fire[(y + 1) % FIRE_HEIGHT][(x) % FIRE_WIDTH]
+ fire[(y + 1) % FIRE_HEIGHT][(x + 1) % FIRE_WIDTH]
+ fire[(y + 2) % FIRE_HEIGHT][(x) % FIRE_WIDTH])
* 32) / 132;
// Once in a great while, add in a white spot.
if (random(100000000) < y * y) { // Desperate attempt to bias then to the bottom.
fire[y][x] = 255;
}
else {
fire[y][x] =
((fire[(y + 1) % FIRE_HEIGHT][(x - 1 + FIRE_WIDTH) % FIRE_WIDTH]
+ fire[(y + 1) % FIRE_HEIGHT][(x) % FIRE_WIDTH]
+ fire[(y + 1) % FIRE_HEIGHT][(x + 1) % FIRE_WIDTH]
+ fire[(y + 2) % FIRE_HEIGHT][(x) % FIRE_WIDTH])
* 32) / 132;
}
}

// Draw fire
Expand Down

0 comments on commit 6fdc89d

Please sign in to comment.