Remove trailing spaces

This commit is contained in:
Ray
2026-03-25 16:51:02 +01:00
parent 5dd4036ed0
commit 0f0983c065
23 changed files with 184 additions and 185 deletions

View File

@ -31,7 +31,7 @@ typedef struct Ball {
Vector2 speed;
Vector2 prevPosition;
float radius;
float friction;
float friction;
float elasticity;
Color color;
bool grabbed;
@ -62,7 +62,7 @@ int main(void)
.color = BLUE,
.grabbed = false
};
int ballCount = 1;
Ball *grabbedBall = NULL; // A pointer to the current ball that is grabbed
Vector2 pressOffset = { 0 }; // Mouse press offset relative to the ball that grabbedd
@ -157,10 +157,10 @@ int main(void)
{
ball->position.x = screenWidth - ball->radius; // Ball repositioning
ball->speed.x = -ball->speed.x*ball->elasticity; // Elasticity makes the ball lose 10% of its velocity on hit
}
}
// Does the ball hit the screen left boundary?
else if ((ball->position.x - ball->radius) <= 0)
{
{
ball->position.x = ball->radius;
ball->speed.x = -ball->speed.x*ball->elasticity;
}
@ -170,9 +170,9 @@ int main(void)
{
ball->position.y = screenHeight - ball->radius;
ball->speed.y = -ball->speed.y*ball->elasticity;
}
}
else if ((ball->position.y - ball->radius) <= 0)
{
{
ball->position.y = ball->radius;
ball->speed.y = -ball->speed.y*ball->elasticity;
}

View File

@ -72,7 +72,7 @@ typedef struct EasingFuncs {
// Module Functions Declaration
//------------------------------------------------------------------------------------
// Function used when "no easing" is selected for any axis
static float NoEase(float t, float b, float c, float d);
static float NoEase(float t, float b, float c, float d);
//------------------------------------------------------------------------------------
// Global Variables Definition

View File

@ -46,13 +46,13 @@ int main(void)
float size = (float)GetScreenHeight();
int strokeCount = 0;
Vector2 *hilbertPath = LoadHilbertPath(order, size, &strokeCount);
int prevOrder = order;
int prevSize = (int)size; // NOTE: Size from slider is float but for comparison we use int
int counter = 0;
float thick = 2.0f;
bool animate = true;
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
@ -68,19 +68,19 @@ int main(void)
{
UnloadHilbertPath(hilbertPath);
hilbertPath = LoadHilbertPath(order, size, &strokeCount);
if (animate) counter = 0;
else counter = strokeCount;
prevOrder = order;
prevSize = (int)size;
}
//----------------------------------------------------------------------------------
// Draw
//--------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
if (counter < strokeCount)
@ -90,7 +90,7 @@ int main(void)
{
DrawLineEx(hilbertPath[i], hilbertPath[i - 1], thick, ColorFromHSV(((float)i/strokeCount)*360.0f, 1.0f, 1.0f));
}
counter += 1;
}
else
@ -101,13 +101,13 @@ int main(void)
DrawLineEx(hilbertPath[i], hilbertPath[i - 1], thick, ColorFromHSV(((float)i/strokeCount)*360.0f, 1.0f, 1.0f));
}
}
// Draw UI using raygui
GuiCheckBox((Rectangle){ 450, 50, 20, 20 }, "ANIMATE GENERATION ON CHANGE", &animate);
GuiSpinner((Rectangle){ 585, 100, 180, 30 }, "HILBERT CURVE ORDER: ", &order, 2, 8, false);
GuiSlider((Rectangle){ 524, 150, 240, 24 }, "THICKNESS: ", NULL, &thick, 1.0f, 10.0f);
GuiSlider((Rectangle){ 524, 190, 240, 24 }, "TOTAL SIZE: ", NULL, &size, 10.0f, GetScreenHeight()*1.5f);
EndDrawing();
//--------------------------------------------------------------------------
}
@ -116,7 +116,7 @@ int main(void)
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadHilbertPath(hilbertPath);
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
@ -133,14 +133,14 @@ static Vector2 *LoadHilbertPath(int order, float size, int *strokeCount)
*strokeCount = N*N;
Vector2 *hilbertPath = (Vector2 *)RL_CALLOC(*strokeCount, sizeof(Vector2));
for (int i = 0; i < *strokeCount; i++)
{
hilbertPath[i] = ComputeHilbertStep(order, i);
hilbertPath[i].x = hilbertPath[i].x*len + len/2.0f;
hilbertPath[i].y = hilbertPath[i].y*len + len/2.0f;
}
return hilbertPath;
}
@ -160,7 +160,7 @@ static Vector2 ComputeHilbertStep(int order, int index)
[2] = { .x = 1, .y = 1 },
[3] = { .x = 1, .y = 0 },
};
int hilbertIndex = index&3;
Vector2 vect = hilbertPoints[hilbertIndex];
float temp = 0.0f;
@ -171,7 +171,7 @@ static Vector2 ComputeHilbertStep(int order, int index)
index = index >> 2;
hilbertIndex = index&3;
len = 1 << j;
switch (hilbertIndex)
{
case 0:
@ -191,6 +191,6 @@ static Vector2 ComputeHilbertStep(int order, int index)
default: break;
}
}
return vect;
}

View File

@ -106,7 +106,7 @@ int main(void)
if (generations > 0) rebuild = true;
}
}
if (rebuild)
{
RL_FREE(ls.production); // Free previous production for re-creation
@ -118,15 +118,15 @@ int main(void)
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground( RAYWHITE );
if (generations > 0) DrawPenroseLSystem(&ls);
DrawText("penrose l-system", 10, 10, 20, DARKGRAY);
DrawText("press up or down to change generations", 10, 30, 20, DARKGRAY);
DrawText(TextFormat("generations: %d", generations), 10, 50, 20, DARKGRAY);
EndDrawing();
//----------------------------------------------------------------------------------
}
@ -171,11 +171,11 @@ static PenroseLSystem CreatePenroseLSystem(float drawLength)
.drawLength = drawLength,
.theta = 36.0f // Degrees
};
ls.production = (char *)RL_MALLOC(sizeof(char)*STR_MAX_SIZE);
ls.production[0] = '\0';
strncpy(ls.production, "[X]++[X]++[X]++[X]++[X]", STR_MAX_SIZE);
return ls;
}
@ -211,7 +211,7 @@ static void BuildProductionStep(PenroseLSystem *ls)
ls->drawLength *= 0.5f;
strncpy(ls->production, newProduction, STR_MAX_SIZE);
RL_FREE(newProduction);
}
@ -228,9 +228,9 @@ static void DrawPenroseLSystem(PenroseLSystem *ls)
int repeats = 1;
int productionLength = (int)strnlen(ls->production, STR_MAX_SIZE);
ls->steps += 12;
if (ls->steps > productionLength) ls->steps = productionLength;
for (int i = 0; i < ls->steps; i++)
{
char step = ls->production[i];
@ -244,24 +244,24 @@ static void DrawPenroseLSystem(PenroseLSystem *ls)
turtle.origin.y += ls->drawLength*sinf(radAngle);
Vector2 startPosScreen = { startPosWorld.x + screenCenter.x, startPosWorld.y + screenCenter.y };
Vector2 endPosScreen = { turtle.origin.x + screenCenter.x, turtle.origin.y + screenCenter.y };
DrawLineEx(startPosScreen, endPosScreen, 2, Fade(BLACK, 0.2f));
}
repeats = 1;
}
}
else if (step == '+')
{
for (int j = 0; j < repeats; j++) turtle.angle += ls->theta;
repeats = 1;
}
}
else if (step == '-')
{
for (int j = 0; j < repeats; j++) turtle.angle += -ls->theta;
repeats = 1;
}
}
else if (step == '[') PushTurtleState(turtle);
else if (step == ']') turtle = PopTurtleState();
else if ((step >= 48) && (step <= 57)) repeats = (int) step - 48;