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:
Chris 2019-10-21 20:17:48 +01:00
commit b4d8f0b5d1
5 changed files with 475 additions and 359 deletions

View file

@ -30,14 +30,14 @@ int main(void)
for (int i = 0; i < MAX_BUILDINGS; i++)
{
buildings[i].width = GetRandomValue(50, 200);
buildings[i].height = GetRandomValue(100, 800);
buildings[i].width = GetRandomInt(50, 200);
buildings[i].height = GetRandomInt(100, 800);
buildings[i].y = screenHeight - 130 - buildings[i].height;
buildings[i].x = -6000 + spacing;
spacing += buildings[i].width;
buildColors[i] = (Color){ GetRandomValue(200, 240), GetRandomValue(200, 240), GetRandomValue(200, 250), 255 };
buildColors[i] = (Color){ GetRandomValue(.8, .95), GetRandomValue(.8, .95), GetRandomValue(.8, .95), 1 };
}
Camera2D camera = { 0 };

View file

@ -37,9 +37,9 @@ int main(void)
for (int i = 0; i < MAX_COLUMNS; i++)
{
heights[i] = (float)GetRandomValue(1, 12);
positions[i] = (Vector3){ GetRandomValue(-15, 15), heights[i]/2, GetRandomValue(-15, 15) };
colors[i] = (Color){ GetRandomValue(20, 255), GetRandomValue(10, 55), 30, 255 };
heights[i] = (float)GetRandomInt(1, 12);
positions[i] = (Vector3){ GetRandomInt(-15, 15), heights[i]/2, GetRandomInt(-15, 15) };
colors[i] = (Color){ GetRandomValue(.1, 1), GetRandomValue(.1, .3), .1, 1 };
}
SetCameraMode(camera, CAMERA_FIRST_PERSON); // Set a first person camera mode
@ -94,4 +94,4 @@ int main(void)
//--------------------------------------------------------------------------------------
return 0;
}
}

View file

@ -22,7 +22,7 @@ int main(void)
int framesCounter = 0; // Variable used to count frames
int randValue = GetRandomValue(-8, 5); // Get a random integer number between -8 and 5 (both included)
int randValue = GetRandomInt(-8, 5); // Get a random integer number between -8 and 5 (both included)
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
@ -37,7 +37,7 @@ int main(void)
// Every two seconds (120 frames) a new random value is generated
if (((framesCounter/120)%2) == 1)
{
randValue = GetRandomValue(-8, 5);
randValue = GetRandomInt(-8, 5);
framesCounter = 0;
}
//----------------------------------------------------------------------------------
@ -62,4 +62,4 @@ int main(void)
//--------------------------------------------------------------------------------------
return 0;
}
}

View file

@ -37,8 +37,8 @@ int main(void)
//----------------------------------------------------------------------------------
if (IsKeyPressed(KEY_R))
{
score = GetRandomValue(1000, 2000);
hiscore = GetRandomValue(2000, 4000);
score = GetRandomInt(1000, 2000);
hiscore = GetRandomInt(2000, 4000);
}
if (IsKeyPressed(KEY_ENTER))
@ -81,4 +81,4 @@ int main(void)
//--------------------------------------------------------------------------------------
return 0;
}
}

View file

@ -34,7 +34,7 @@ int main(void)
SetTextureFilter(target.texture, FILTER_BILINEAR); // Texture scale filter to use
Color colors[10] = { 0 };
for (int i = 0; i < 10; i++) colors[i] = (Color){ GetRandomValue(100, 250), GetRandomValue(50, 150), GetRandomValue(10, 100), 255 };
for (int i = 0; i < 10; i++) colors[i] = (Color){ GetRandomValue(.5, .95), GetRandomValue(.2, .6), GetRandomValue(.05, .4), 1 };
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
@ -50,7 +50,7 @@ int main(void)
if (IsKeyPressed(KEY_SPACE))
{
// Recalculate random colors for the bars
for (int i = 0; i < 10; i++) colors[i] = (Color){ GetRandomValue(100, 250), GetRandomValue(50, 150), GetRandomValue(10, 100), 255 };
for (int i = 0; i < 10; i++) colors[i] = (Color){ GetRandomValue(.5, .95), GetRandomValue(.2, .6), GetRandomValue(.05, .4), 1 };
}
//----------------------------------------------------------------------------------