Fix MSVC compilation

This commit is contained in:
Jopestpe 2025-10-17 15:08:07 -03:00 committed by GitHub
parent 865ccba021
commit 156f5048c6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -22,6 +22,9 @@
#define RAYGUI_IMPLEMENTATION
#include "raygui.h" // Required for GUI controls
// Wave points for sine/cosine visualization
#define WAVE_POINTS 36
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
@ -35,18 +38,17 @@ int main(void)
SetConfigFlags(FLAG_MSAA_4X_HINT);
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - math sine cosine");
const int wavePoints = 36;
Vector2 sinePoints[wavePoints];
Vector2 cosPoints[wavePoints];
Vector2 sinePoints[WAVE_POINTS];
Vector2 cosPoints[WAVE_POINTS];
Vector2 center = { (screenWidth/2.0f) - 30.f, screenHeight/2.0f };
Rectangle start = { 20.f, screenHeight - 120.f , 200.0f, 100.0f};
float radius = 130.0f;
float angle = 0.0f;
bool pause = false;
for (int i = 0; i < wavePoints; i++)
for (int i = 0; i < WAVE_POINTS; i++)
{
float t = i/(float)(wavePoints - 1);
float t = i/(float)(WAVE_POINTS - 1);
float currentAngle = t*360.0f*DEG2RAD;
sinePoints[i] = (Vector2){ start.x + t*start.width, start.y + start.height/2.0f - sinf(currentAngle)*(start.height/2.0f) };
cosPoints[i] = (Vector2){ start.x + t*start.width, start.y + start.height/2.0f - cosf(currentAngle)*(start.height/2.0f) };
@ -115,14 +117,14 @@ int main(void)
DrawLineDashed((Vector2){ point.x, center.y }, (Vector2){ point.x, point.y }, 10.0f, 4.0f, RED);
DrawText(TextFormat("Sine %.2f", sinRad), 640, 190, 6, RED);
DrawCircleV((Vector2){ start.x + (angle/360.0f)*start.width, start.y + ((-sinRad + 1)*start.height/2.0f) }, 4.0f, RED);
DrawSplineLinear(sinePoints, wavePoints, 1.0f, RED);
DrawSplineLinear(sinePoints, WAVE_POINTS, 1.0f, RED);
// Cosine (blue - horizontal)
DrawLineEx((Vector2){ center.x, center.y }, (Vector2){ point.x, center.y }, 2.0f, BLUE);
DrawLineDashed((Vector2){ center.x , point.y }, (Vector2){ point.x, point.y }, 10.0f, 4.0f, BLUE);
DrawText(TextFormat("Cosine %.2f", cosRad), 640, 210, 6, BLUE);
DrawCircleV((Vector2){ start.x + (angle/360.0f)*start.width, start.y + ((-cosRad + 1)*start.height/2.0f) }, 4.0f, BLUE);
DrawSplineLinear(cosPoints, wavePoints, 1.0f, BLUE);
DrawSplineLinear(cosPoints, WAVE_POINTS, 1.0f, BLUE);
// Tangent (purple)
DrawLineEx((Vector2){ limitMax.x , center.y }, (Vector2){ limitMax.x, tangentPoint.y }, 2.0f, PURPLE);