Update textures_screen_buffer.c

This commit is contained in:
Ray
2026-02-20 16:06:59 +01:00
parent f33823cefe
commit d996bf2bbd

View File

@ -52,6 +52,7 @@ int main(void)
float hue = t*t;
float saturation = t;
float value = t;
palette[i] = ColorFromHSV(250.0f + 150.0f*hue, saturation, value);
}
@ -68,7 +69,7 @@ int main(void)
{
int flame = (int)flameRootBuffer[x];
flame += GetRandomValue(0, 2);
flameRootBuffer[x] = (flameInc > 255)? 255: (unsigned char)flame;
flameRootBuffer[x] = (flame > 255)? 255: (unsigned char)flame;
}
// Transfer flameRoot to indexBuffer
@ -81,8 +82,7 @@ int main(void)
// Clear top row, because it can't move any higher
for (int x = 0; x < imageWidth; x++)
{
if (indexBuffer[x] == 0) continue;
indexBuffer[x] = 0;
if (indexBuffer[x] != 0) indexBuffer[x] = 0;
}
// Skip top row, it is already cleared
@ -92,18 +92,22 @@ int main(void)
{
unsigned int i = x + y*imageWidth;
unsigned char colorIndex = indexBuffer[i];
if (colorIndex == 0) continue;
// Move pixel a row above
indexBuffer[i] = 0;
int moveX = GetRandomValue(0, 2) - 1;
int newX = x + moveX;
if (newX < 0 || newX >= imageWidth) continue;
unsigned int iabove = i - imageWidth + moveX;
int decay = GetRandomValue(0, 3);
colorIndex -= (decay < colorIndex)? decay : colorIndex;
indexBuffer[iabove] = colorIndex;
if (colorIndex != 0)
{
// Move pixel a row above
indexBuffer[i] = 0;
int moveX = GetRandomValue(0, 2) - 1;
int newX = x + moveX;
if ((newX > 0) && (newX < imageWidth))
{
unsigned int iabove = i - imageWidth + moveX;
int decay = GetRandomValue(0, 3);
colorIndex -= (decay < colorIndex)? decay : colorIndex;
indexBuffer[iabove] = colorIndex;
}
}
}
}
@ -115,6 +119,7 @@ int main(void)
unsigned int i = x + y*imageWidth;
unsigned char colorIndex = indexBuffer[i];
Color col = palette[colorIndex];
ImageDrawPixel(&screenImage, x, y, col);
}
}