mirror of
https://github.com/raysan5/raylib.git
synced 2026-02-20 20:49:17 -05:00
Update textures_screen_buffer.c
This commit is contained in:
@ -52,6 +52,7 @@ int main(void)
|
|||||||
float hue = t*t;
|
float hue = t*t;
|
||||||
float saturation = t;
|
float saturation = t;
|
||||||
float value = t;
|
float value = t;
|
||||||
|
|
||||||
palette[i] = ColorFromHSV(250.0f + 150.0f*hue, saturation, value);
|
palette[i] = ColorFromHSV(250.0f + 150.0f*hue, saturation, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +69,7 @@ int main(void)
|
|||||||
{
|
{
|
||||||
int flame = (int)flameRootBuffer[x];
|
int flame = (int)flameRootBuffer[x];
|
||||||
flame += GetRandomValue(0, 2);
|
flame += GetRandomValue(0, 2);
|
||||||
flameRootBuffer[x] = (flameInc > 255)? 255: (unsigned char)flame;
|
flameRootBuffer[x] = (flame > 255)? 255: (unsigned char)flame;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transfer flameRoot to indexBuffer
|
// Transfer flameRoot to indexBuffer
|
||||||
@ -81,8 +82,7 @@ int main(void)
|
|||||||
// Clear top row, because it can't move any higher
|
// Clear top row, because it can't move any higher
|
||||||
for (int x = 0; x < imageWidth; x++)
|
for (int x = 0; x < imageWidth; x++)
|
||||||
{
|
{
|
||||||
if (indexBuffer[x] == 0) continue;
|
if (indexBuffer[x] != 0) indexBuffer[x] = 0;
|
||||||
indexBuffer[x] = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip top row, it is already cleared
|
// Skip top row, it is already cleared
|
||||||
@ -92,18 +92,22 @@ int main(void)
|
|||||||
{
|
{
|
||||||
unsigned int i = x + y*imageWidth;
|
unsigned int i = x + y*imageWidth;
|
||||||
unsigned char colorIndex = indexBuffer[i];
|
unsigned char colorIndex = indexBuffer[i];
|
||||||
if (colorIndex == 0) continue;
|
|
||||||
|
if (colorIndex != 0)
|
||||||
// Move pixel a row above
|
{
|
||||||
indexBuffer[i] = 0;
|
// Move pixel a row above
|
||||||
int moveX = GetRandomValue(0, 2) - 1;
|
indexBuffer[i] = 0;
|
||||||
int newX = x + moveX;
|
int moveX = GetRandomValue(0, 2) - 1;
|
||||||
if (newX < 0 || newX >= imageWidth) continue;
|
int newX = x + moveX;
|
||||||
|
|
||||||
unsigned int iabove = i - imageWidth + moveX;
|
if ((newX > 0) && (newX < imageWidth))
|
||||||
int decay = GetRandomValue(0, 3);
|
{
|
||||||
colorIndex -= (decay < colorIndex)? decay : colorIndex;
|
unsigned int iabove = i - imageWidth + moveX;
|
||||||
indexBuffer[iabove] = colorIndex;
|
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 int i = x + y*imageWidth;
|
||||||
unsigned char colorIndex = indexBuffer[i];
|
unsigned char colorIndex = indexBuffer[i];
|
||||||
Color col = palette[colorIndex];
|
Color col = palette[colorIndex];
|
||||||
|
|
||||||
ImageDrawPixel(&screenImage, x, y, col);
|
ImageDrawPixel(&screenImage, x, y, col);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user