changed Color struct to 4 floats
GetRandomValue returns floats added GetRandomInt added Color4ub rgba 0-255 edited examples to work colour palette values could bare a double check!
This commit is contained in:
parent
ea70c47a1a
commit
b4d8f0b5d1
4 changed files with 475 additions and 359 deletions
|
|
@ -57,11 +57,11 @@ int main(void)
|
|||
if (bunniesCount < MAX_BUNNIES)
|
||||
{
|
||||
bunnies[bunniesCount].position = GetMousePosition();
|
||||
bunnies[bunniesCount].speed.x = (float)GetRandomValue(-250, 250)/60.0f;
|
||||
bunnies[bunniesCount].speed.y = (float)GetRandomValue(-250, 250)/60.0f;
|
||||
bunnies[bunniesCount].color = (Color){ GetRandomValue(50, 240),
|
||||
GetRandomValue(80, 240),
|
||||
GetRandomValue(100, 240), 255 };
|
||||
bunnies[bunniesCount].speed.x = (float)GetRandomInt(-250, 250)/60.0f;
|
||||
bunnies[bunniesCount].speed.y = (float)GetRandomInt(-250, 250)/60.0f;
|
||||
bunnies[bunniesCount].color = (Color){ GetRandomValue(0.5, .9),
|
||||
GetRandomValue(.8, .9),
|
||||
GetRandomValue(.5, .9), 1 };
|
||||
bunniesCount++;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ int main(void)
|
|||
default: break;
|
||||
}
|
||||
|
||||
Color *pixels = GetImageData(image); // Get pixel data from image (RGBA 32bit)
|
||||
Color4ub *pixels = GetImageData(image); // Get pixel data from image (RGBA 32bit)
|
||||
UpdateTexture(texture, pixels); // Update texture with new image data
|
||||
free(pixels); // Unload pixels data from RAM
|
||||
|
||||
|
|
@ -142,4 +142,4 @@ int main(void)
|
|||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,10 +39,10 @@ int main(void)
|
|||
for (int i = 0; i < MAX_PARTICLES; i++)
|
||||
{
|
||||
mouseTail[i].position = (Vector2){ 0, 0 };
|
||||
mouseTail[i].color = (Color){ GetRandomValue(0, 255), GetRandomValue(0, 255), GetRandomValue(0, 255), 255 };
|
||||
mouseTail[i].color = (Color){ GetRandomValue(0, 1), GetRandomValue(0, 1), GetRandomValue(0, 1), 1 };
|
||||
mouseTail[i].alpha = 1.0f;
|
||||
mouseTail[i].size = (float)GetRandomValue(1, 30)/20.0f;
|
||||
mouseTail[i].rotation = (float)GetRandomValue(0, 360);
|
||||
mouseTail[i].size = (float)GetRandomInt(1, 30)/20.0f;
|
||||
mouseTail[i].rotation = (float)GetRandomInt(0, 360);
|
||||
mouseTail[i].active = false;
|
||||
}
|
||||
|
||||
|
|
@ -132,4 +132,4 @@ int main(void)
|
|||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,14 +36,14 @@ int main(void)
|
|||
int height = 480;
|
||||
|
||||
// Dynamic memory allocation to store pixels data (Color type)
|
||||
Color *pixels = (Color *)malloc(width*height*sizeof(Color));
|
||||
Color4ub *pixels = (Color4ub *)malloc(width*height*sizeof(Color4ub));
|
||||
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
if (((x/32+y/32)/1)%2 == 0) pixels[y*width + x] = ORANGE;
|
||||
else pixels[y*width + x] = GOLD;
|
||||
if (((x/32+y/32)/1)%2 == 0) pixels[y*width + x] = (Color4ub){ 255, 0.62891*255, 0.0, 255 }; // orange
|
||||
else pixels[y*width + x] = (Color4ub){ 255, 0.79297*255, 0.0, 255 };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -92,4 +92,4 @@ int main(void)
|
|||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue