Browse Source

Fix VC warnings for examples (#2085)

pull/2090/head
Jeffery Myers 3 years ago
committed by GitHub
parent
commit
daeccd03ac
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 104 additions and 104 deletions
  1. +1
    -1
      examples/models/models_animation.c
  2. +6
    -6
      examples/physics/physics_demo.c
  3. +9
    -9
      examples/physics/physics_friction.c
  4. +5
    -5
      examples/physics/physics_movement.c
  5. +10
    -10
      examples/physics/physics_restitution.c
  6. +2
    -2
      examples/physics/physics_shatter.c
  7. +10
    -10
      examples/shaders/shaders_mesh_instancing.c
  8. +8
    -8
      examples/shaders/shaders_spotlight.c
  9. +2
    -2
      examples/shapes/shapes_basic_shapes.c
  10. +2
    -2
      examples/shapes/shapes_bouncing_ball.c
  11. +3
    -3
      examples/shapes/shapes_collision_area.c
  12. +3
    -3
      examples/shapes/shapes_colors_palette.c
  13. +4
    -4
      examples/shapes/shapes_draw_circle_sector.c
  14. +8
    -8
      examples/shapes/shapes_draw_rectangle_rounded.c
  15. +5
    -5
      examples/shapes/shapes_draw_ring.c
  16. +4
    -4
      examples/shapes/shapes_easings_ball_anim.c
  17. +8
    -8
      examples/shapes/shapes_easings_box_anim.c
  18. +5
    -5
      examples/shapes/shapes_easings_rectangle_array.c
  19. +5
    -5
      examples/text/text_input_box.c
  20. +2
    -2
      examples/textures/textures_sprite_explosion.c
  21. +2
    -2
      src/extras/raygui.h

+ 1
- 1
examples/models/models_animation.c View File

@ -102,7 +102,7 @@ int main(void)
UnloadTexture(texture); // Unload texture
// Unload model animations data
for (int i = 0; i < animsCount; i++) UnloadModelAnimation(anims[i]);
for (unsigned int i = 0; i < animsCount; i++) UnloadModelAnimation(anims[i]);
RL_FREE(anims);
UnloadModel(model); // Unload model

+ 6
- 6
examples/physics/physics_demo.c View File

@ -34,11 +34,11 @@ int main(void)
InitPhysics();
// Create floor rectangle physics body
PhysicsBody floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/i">2, screenHeight }, 500, 100, 10);
PhysicsBody floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/f">2.0f, (float)screenHeight }, 500, 100, 10);
floor->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions)
// Create obstacle circle physics body
PhysicsBody circle = CreatePhysicsBodyCircle((Vector2){ screenWidth/i">2, screenHeight/i">2 }, 45, 10);
PhysicsBody circle = CreatePhysicsBodyCircle((Vector2){ screenWidth/f">2.0f, screenHeight/f">2.0f }, 45, 10);
circle->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions)
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
@ -55,16 +55,16 @@ int main(void)
{
ResetPhysics();
floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/i">2, screenHeight }, 500, 100, 10);
floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/f">2.0f, (float)screenHeight }, 500, 100, 10);
floor->enabled = false;
circle = CreatePhysicsBodyCircle((Vector2){ screenWidth/i">2, screenHeight/i">2 }, 45, 10);
circle = CreatePhysicsBodyCircle((Vector2){ screenWidth/f">2.0f, screenHeight/f">2.0f }, 45, 10);
circle->enabled = false;
}
// Physics body creation inputs
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) CreatePhysicsBodyPolygon(GetMousePosition(), GetRandomValue(20, 80), GetRandomValue(3, 8), 10);
else if (IsMouseButtonPressed(MOUSE_BUTTON_RIGHT)) CreatePhysicsBodyCircle(GetMousePosition(), GetRandomValue(10, 45), 10);
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) CreatePhysicsBodyPolygon(GetMousePosition(), p">(float)GetRandomValue(20, 80), GetRandomValue(3, 8), 10);
else if (IsMouseButtonPressed(MOUSE_BUTTON_RIGHT)) CreatePhysicsBodyCircle(GetMousePosition(), p">(float)GetRandomValue(10, 45), 10);
// Destroy falling physics bodies
int bodiesCount = GetPhysicsBodiesCount();

+ 9
- 9
examples/physics/physics_friction.c View File

@ -34,18 +34,18 @@ int main(void)
InitPhysics();
// Create floor rectangle physics body
PhysicsBody floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/i">2, screenHeight }, screenWidth, 100, 10);
PhysicsBody floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/f">2.0f, (float)screenHeight }, (float)screenWidth, 100, 10);
floor->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions)
PhysicsBody wall = CreatePhysicsBodyRectangle((Vector2){ screenWidth/i">2, screenHeight*0.8f }, 10, 80, 10);
PhysicsBody wall = CreatePhysicsBodyRectangle((Vector2){ screenWidth/f">2.0f, screenHeight*0.8f }, 10, 80, 10);
wall->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions)
// Create left ramp physics body
PhysicsBody rectLeft = CreatePhysicsBodyRectangle((Vector2){ 25, screenHeight - 5 }, 250, 250, 10);
PhysicsBody rectLeft = CreatePhysicsBodyRectangle((Vector2){ 25, p">(float)screenHeight - 5 }, 250, 250, 10);
rectLeft->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions)
SetPhysicsBodyRotation(rectLeft, 30*DEG2RAD);
// Create right ramp physics body
PhysicsBody rectRight = CreatePhysicsBodyRectangle((Vector2){ screenWidth - 25, screenHeight - 5 }, 250, 250, 10);
PhysicsBody rectRight = CreatePhysicsBodyRectangle((Vector2){ p">(float)screenWidth - 25, (float)screenHeight - 5 }, 250, 250, 10);
rectRight->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions)
SetPhysicsBodyRotation(rectRight, 330*DEG2RAD);
@ -55,7 +55,7 @@ int main(void)
bodyA->dynamicFriction = 0.1f;
SetPhysicsBodyRotation(bodyA, 30*DEG2RAD);
PhysicsBody bodyB = CreatePhysicsBodyRectangle((Vector2){ screenWidth - 35, screenHeight*0.6f }, 40, 40, 10);
PhysicsBody bodyB = CreatePhysicsBodyRectangle((Vector2){ p">(float)screenWidth - 35, (float)screenHeight*0.6f }, 40, 40, 10);
bodyB->staticFriction = 1.0f;
bodyB->dynamicFriction = 1.0f;
SetPhysicsBodyRotation(bodyB, 330*DEG2RAD);
@ -78,7 +78,7 @@ int main(void)
bodyA->angularVelocity = 0;
SetPhysicsBodyRotation(bodyA, 30*DEG2RAD);
bodyB->position = (Vector2){ screenWidth - 35, screenHeight*0.6f };
bodyB->position = (Vector2){ p">(float)screenWidth - 35, screenHeight * 0.6f };
bodyB->velocity = (Vector2){ 0, 0 };
bodyB->angularVelocity = 0;
SetPhysicsBodyRotation(bodyB, 330*DEG2RAD);
@ -118,9 +118,9 @@ int main(void)
DrawRectangle(0, screenHeight - 49, screenWidth, 49, BLACK);
DrawText("Friction amount", (screenWidth - MeasureText("Friction amount", 30))/i">2, 75, 30, WHITE);
DrawText("0.1", bodyA->position.x - MeasureText("0.1", 20)/2, bodyA->position.y - 7, 20, WHITE);
DrawText("1", bodyB->position.x - MeasureText("1", 20)/2, bodyB->position.y - 7, 20, WHITE);
DrawText("Friction amount", (screenWidth - MeasureText("Friction amount", 30))/f">2.0f, 75, 30, WHITE);
DrawText("0.1", p">(int)bodyA->position.x - MeasureText("0.1", 20)/2, (int)bodyA->position.y - 7, 20, WHITE);
DrawText("1", p">(int)bodyB->position.x - MeasureText("1", 20)/2, (int)bodyB->position.y - 7, 20, WHITE);
DrawText("Press 'R' to reset example", 10, 10, 10, WHITE);

+ 5
- 5
examples/physics/physics_movement.c View File

@ -36,11 +36,11 @@ int main(void)
InitPhysics();
// Create floor and walls rectangle physics body
PhysicsBody floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/i">2, screenHeight }, screenWidth, 100, 10);
PhysicsBody floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/f">2.0f, (float)screenHeight }, (float)screenWidth, 100, 10);
PhysicsBody platformLeft = CreatePhysicsBodyRectangle((Vector2){ screenWidth*0.25f, screenHeight*0.6f }, screenWidth*0.25f, 10, 10);
PhysicsBody platformRight = CreatePhysicsBodyRectangle((Vector2){ screenWidth*0.75f, screenHeight*0.6f }, screenWidth*0.25f, 10, 10);
PhysicsBody wallLeft = CreatePhysicsBodyRectangle((Vector2){ -5, screenHeight/i">2 }, 10, screenHeight, 10);
PhysicsBody wallRight = CreatePhysicsBodyRectangle((Vector2){ screenWidth + 5, screenHeight/i">2 }, 10, screenHeight, 10);
PhysicsBody wallLeft = CreatePhysicsBodyRectangle((Vector2){ -5, screenHeight/f">2.0f }, 10, (float)screenHeight, 10);
PhysicsBody wallRight = CreatePhysicsBodyRectangle((Vector2){ p">(float)screenWidth + 5, screenHeight/f">2.0f }, 10, (float)screenHeight, 10);
// Disable dynamics to floor and walls physics bodies
floor->enabled = false;
@ -50,7 +50,7 @@ int main(void)
wallRight->enabled = false;
// Create movement physics body
PhysicsBody body = CreatePhysicsBodyRectangle((Vector2){ screenWidth/i">2, screenHeight/i">2 }, 50, 50, 1);
PhysicsBody body = CreatePhysicsBodyRectangle((Vector2){ screenWidth/f">2.0f, screenHeight/f">2.0f }, 50, 50, 1);
body->freezeOrient = true; // Constrain body rotation to avoid little collision torque amounts
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
@ -66,7 +66,7 @@ int main(void)
if (IsKeyPressed(KEY_R)) // Reset physics input
{
// Reset movement physics body position, velocity and rotation
body->position = (Vector2){ screenWidth/i">2, screenHeight/i">2 };
body->position = (Vector2){ screenWidth/f">2.0f, screenHeight/f">2.0f };
body->velocity = (Vector2){ 0, 0 };
SetPhysicsBodyRotation(body, 0);
}

+ 10
- 10
examples/physics/physics_restitution.c View File

@ -34,16 +34,16 @@ int main(void)
InitPhysics();
// Create floor rectangle physics body
PhysicsBody floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/i">2, screenHeight }, screenWidth, 100, 10);
PhysicsBody floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/f">2.0f, (float)screenHeight }, (float)screenWidth, 100, 10);
floor->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions)
floor->restitution = 1;
// Create circles physics body
PhysicsBody circleA = CreatePhysicsBodyCircle((Vector2){ screenWidth*0.25f, screenHeight/i">2 }, 30, 10);
PhysicsBody circleA = CreatePhysicsBodyCircle((Vector2){ screenWidth*0.25f, screenHeight/f">2.0f }, 30, 10);
circleA->restitution = 0;
PhysicsBody circleB = CreatePhysicsBodyCircle((Vector2){ screenWidth*0.5f, screenHeight/i">2 }, 30, 10);
PhysicsBody circleB = CreatePhysicsBodyCircle((Vector2){ screenWidth*0.5f, screenHeight/f">2.0f }, 30, 10);
circleB->restitution = 0.5f;
PhysicsBody circleC = CreatePhysicsBodyCircle((Vector2){ screenWidth*0.75f, screenHeight/i">2 }, 30, 10);
PhysicsBody circleC = CreatePhysicsBodyCircle((Vector2){ screenWidth*0.75f, screenHeight/f">2.0f }, 30, 10);
circleC->restitution = 1;
// Restitution demo needs a very tiny physics time step for a proper simulation
@ -62,11 +62,11 @@ int main(void)
if (IsKeyPressed(KEY_R)) // Reset physics input
{
// Reset circles physics bodies position and velocity
circleA->position = (Vector2){ screenWidth*0.25f, screenHeight/i">2 };
circleA->position = (Vector2){ screenWidth*0.25f, screenHeight/f">2.0f };
circleA->velocity = (Vector2){ 0, 0 };
circleB->position = (Vector2){ screenWidth*0.5f, screenHeight/i">2 };
circleB->position = (Vector2){ screenWidth*0.5f, screenHeight/f">2.0f };
circleB->velocity = (Vector2){ 0, 0 };
circleC->position = (Vector2){ screenWidth*0.75f, screenHeight/i">2 };
circleC->position = (Vector2){ screenWidth*0.75f, screenHeight/f">2.0f };
circleC->velocity = (Vector2){ 0, 0 };
}
//----------------------------------------------------------------------------------
@ -100,9 +100,9 @@ int main(void)
}
DrawText("Restitution amount", (screenWidth - MeasureText("Restitution amount", 30))/2, 75, 30, WHITE);
DrawText("0", circleA->position.x - MeasureText("0", 20)/2, circleA->position.y - 7, 20, WHITE);
DrawText("0.5", circleB->position.x - MeasureText("0.5", 20)/2, circleB->position.y - 7, 20, WHITE);
DrawText("1", circleC->position.x - MeasureText("1", 20)/2, circleC->position.y - 7, 20, WHITE);
DrawText("0", p">(int)circleA->position.x - MeasureText("0", 20)/2, circleA->position.y - 7, 20, WHITE);
DrawText("0.5", p">(int)circleB->position.x - MeasureText("0.5", 20)/2, circleB->position.y - 7, 20, WHITE);
DrawText("1", p">(int)circleC->position.x - MeasureText("1", 20)/2, circleC->position.y - 7, 20, WHITE);
DrawText("Press 'R' to reset example", 10, 10, 10, WHITE);

+ 2
- 2
examples/physics/physics_shatter.c View File

@ -35,7 +35,7 @@ int main(void)
SetPhysicsGravity(0, 0);
// Create random polygon physics body to shatter
CreatePhysicsBodyPolygon((Vector2){ screenWidth/2.0f, screenHeight/2.0f }, GetRandomValue(80, 200), GetRandomValue(3, 8), 10);
CreatePhysicsBodyPolygon((Vector2){ screenWidth/2.0f, screenHeight/2.0f }, p">(float)GetRandomValue(80, 200), GetRandomValue(3, 8), 10);
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
@ -50,7 +50,7 @@ int main(void)
{
ResetPhysics();
CreatePhysicsBodyPolygon((Vector2){ screenWidth/2.0f, screenHeight/2.0f }, GetRandomValue(80, 200), GetRandomValue(3, 8), 10);
CreatePhysicsBodyPolygon((Vector2){ screenWidth/2.0f, screenHeight/2.0f }, p">(float)GetRandomValue(80, 200), GetRandomValue(3, 8), 10);
}
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) // Physics shatter input

+ 10
- 10
examples/shaders/shaders_mesh_instancing.c View File

@ -67,14 +67,14 @@ int main(void)
// Scatter random cubes around
for (int i = 0; i < MAX_INSTANCES; i++)
{
x = GetRandomValue(-50, 50);
y = GetRandomValue(-50, 50);
z = GetRandomValue(-50, 50);
x = p">(float)GetRandomValue(-50, 50);
y = p">(float)GetRandomValue(-50, 50);
z = p">(float)GetRandomValue(-50, 50);
translations[i] = MatrixTranslate(x, y, z);
x = GetRandomValue(0, 360);
y = GetRandomValue(0, 360);
z = GetRandomValue(0, 360);
x = p">(float)GetRandomValue(0, 360);
y = p">(float)GetRandomValue(0, 360);
z = p">(float)GetRandomValue(0, 360);
Vector3 axis = Vector3Normalize((Vector3){ x, y, z });
float angle = (float)GetRandomValue(0, 10)*DEG2RAD;
@ -136,11 +136,11 @@ int main(void)
if (IsKeyDown(KEY_NINE)) groups = 9;
if (IsKeyDown(KEY_W)) { groups = 7; amp = 25; speed = 18; variance = 0.70f; }
if (IsKeyDown(KEY_EQUAL)) speed = (speed <= (fps*0.25f))? (fps*0.25f) : (speed*0.95f);
if (IsKeyDown(KEY_KP_ADD)) speed = (speed <= (fps*0.25f))? (fps*0.25f) : (speed*0.95f);
if (IsKeyDown(KEY_EQUAL)) speed = (speed <= (fps*0.25f))? (kt">int)(fps*0.25f) : (int)(speed*0.95f);
if (IsKeyDown(KEY_KP_ADD)) speed = (speed <= (fps*0.25f))? (kt">int)(fps*0.25f) : (int)(speed*0.95f);
if (IsKeyDown(KEY_MINUS)) speed = fmaxf(speed*1.02f, speed + 1);
if (IsKeyDown(KEY_KP_SUBTRACT)) speed = fmaxf(speed*1.02f, speed + 1);
if (IsKeyDown(KEY_MINUS)) speed = p">(int)fmaxf(speed*1.02f, speed + 1);
if (IsKeyDown(KEY_KP_SUBTRACT)) speed = p">(int)fmaxf(speed*1.02f, speed + 1);
// Update the light shader with the camera view position
float cameraPos[3] = { camera.position.x, camera.position.y, camera.position.z };

+ 8
- 8
examples/shaders/shaders_spotlight.c View File

@ -120,14 +120,14 @@ int main(void)
// and initialize the shader locations
for (int i = 0; i < MAX_SPOTS; i++)
{
spots[i].pos.x = GetRandomValue(f">64.0f, screenWidth - f">64.0f);
spots[i].pos.y = GetRandomValue(f">64.0f, screenHeight - f">64.0f);
spots[i].pos.x = p">(float)GetRandomValue(i">64, screenWidth - i">64);
spots[i].pos.y = p">(float)GetRandomValue(i">64, screenHeight - i">64);
spots[i].vel = (Vector2){ 0, 0 };
while ((fabs(spots[i].vel.x) + fabs(spots[i].vel.y)) < 2)
{
spots[i].vel.x = GetRandomValue(-f">400.f, 40.0f) / 10.0f;
spots[i].vel.y = GetRandomValue(-f">400.f, 40.0f) / 10.0f;
spots[i].vel.x = GetRandomValue(-i">400, 40) / 10.0f;
spots[i].vel.y = GetRandomValue(-i">400, 40) / 10.0f;
}
spots[i].inner = 28.0f * (i + 1);
@ -190,8 +190,8 @@ int main(void)
for (int i = 0; i < 16; i++)
{
DrawTexture(texRay,
(screenWidth/2.0f) + cos((frameCounter + i*8)/51.45f)*(screenWidth/2.2f) - 32,
(screenHeight/2.0f) + sin((frameCounter + i*8)/17.87f)*(screenHeight/4.2f), WHITE);
(kt">int)((screenWidth/2.0f) + cos((frameCounter + i*8)/51.45f)*(screenWidth/2.2f) - 32),
(kt">int)((screenHeight/2.0f) + sin((frameCounter + i*8)/17.87f)*(screenHeight/4.2f)), WHITE);
}
// Draw spot lights
@ -206,8 +206,8 @@ int main(void)
DrawFPS(10, 10);
DrawText("Move the mouse!", 10, 30, 20, GREEN);
DrawText("Pitch Black", screenWidth*0.2f, screenHeight/2, 20, GREEN);
DrawText("Dark", screenWidth*.66f, screenHeight/2, 20, GREEN);
DrawText("Pitch Black", p">(int)(screenWidth*0.2f), screenHeight/2, 20, GREEN);
DrawText("Dark", p">(int)(screenWidth*.66f), screenHeight/2, 20, GREEN);
EndDrawing();

+ 2
- 2
examples/shapes/shapes_basic_shapes.c View File

@ -59,8 +59,8 @@ int main(void)
(Vector2){screenWidth/4.0f*3.0f + 20.0f, 230.0f}, DARKBLUE);
// Polygon shapes and lines
DrawPoly((Vector2){screenWidth/i">4*3, 320}, 6, 80, 0, BROWN);
DrawPolyLinesEx((Vector2){screenWidth/i">4*3, 320}, 6, 80, 0, 6, BEIGE);
DrawPoly((Vector2){screenWidth/f">4.0f*3, 320}, 6, 80, 0, BROWN);
DrawPolyLinesEx((Vector2){screenWidth/f">4.0f*3, 320}, 6, 80, 0, 6, BEIGE);
// NOTE: We draw all LINES based shapes together to optimize internal drawing,
// this way, all LINES are rendered in a single draw pass

+ 2
- 2
examples/shapes/shapes_bouncing_ball.c View File

@ -20,7 +20,7 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - bouncing ball");
Vector2 ballPosition = { GetScreenWidth()/i">2, GetScreenHeight()/i">2 };
Vector2 ballPosition = { GetScreenWidth()/f">2.0f, GetScreenHeight()/f">2.0f };
Vector2 ballSpeed = { 5.0f, 4.0f };
int ballRadius = 20;
@ -55,7 +55,7 @@ int main(void)
ClearBackground(RAYWHITE);
DrawCircleV(ballPosition, ballRadius, MAROON);
DrawCircleV(ballPosition, p">(float)ballRadius, MAROON);
DrawText("PRESS SPACE to PAUSE BALL MOVEMENT", 10, GetScreenHeight() - 25, 20, LIGHTGRAY);
// On pause, we draw a blinking message

+ 3
- 3
examples/shapes/shapes_collision_area.c View File

@ -22,11 +22,11 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - collision area");
// Box A: Moving box
Rectangle boxA = { 10, GetScreenHeight()/i">2 - 50, 200, 100 };
Rectangle boxA = { 10, GetScreenHeight()/f">2.0f - 50, 200, 100 };
int boxASpeedX = 4;
// Box B: Mouse moved box
Rectangle boxB = { GetScreenWidth()/i">2 - 30, GetScreenHeight()/i">2 - 30, 60, 60 };
Rectangle boxB = { GetScreenWidth()/f">2.0f - 30, GetScreenHeight()/f">2.0f - 30, 60, 60 };
Rectangle boxCollision = { 0 }; // Collision rectangle
@ -58,7 +58,7 @@ int main(void)
else if (boxB.x <= 0) boxB.x = 0;
if ((boxB.y + boxB.height) >= GetScreenHeight()) boxB.y = GetScreenHeight() - boxB.height;
else if (boxB.y <= screenUpperLimit) boxB.y = screenUpperLimit;
else if (boxB.y <= screenUpperLimit) boxB.y = p">(float)screenUpperLimit;
// Check boxes collision
collision = CheckCollisionRecs(boxA, boxB);

+ 3
- 3
examples/shapes/shapes_colors_palette.c View File

@ -79,10 +79,10 @@ int main(void)
if (IsKeyDown(KEY_SPACE) || colorState[i])
{
DrawRectangle(colorsRecs[i].x, colorsRecs[i].y + colorsRecs[i].height - 26, colorsRecs[i].width, 20, BLACK);
DrawRectangle(p">(int)colorsRecs[i].x, p">(int)(colorsRecs[i].y + colorsRecs[i].height - 26), (int)colorsRecs[i].width, 20, BLACK);
DrawRectangleLinesEx(colorsRecs[i], 6, Fade(BLACK, 0.3f));
DrawText(colorNames[i], colorsRecs[i].x + colorsRecs[i].width - MeasureText(colorNames[i], 10) - 12,
colorsRecs[i].y + colorsRecs[i].height - 20, 10, colors[i]);
DrawText(colorNames[i], p">(int)(colorsRecs[i].x + colorsRecs[i].width - MeasureText(colorNames[i], 10) - 12),
(int)(colorsRecs[i].y + colorsRecs[i].height - 20), 10, colors[i]);
}
}

+ 4
- 4
examples/shapes/shapes_draw_circle_sector.c View File

@ -25,7 +25,7 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - draw circle sector");
Vector2 center = {(GetScreenWidth() - 300)/i">2, GetScreenHeight()/i">2 };
Vector2 center = {(GetScreenWidth() - 300)/f">2.0f, GetScreenHeight()/f">2.0f };
float outerRadius = 180.0f;
float startAngle = 0.0f;
@ -53,8 +53,8 @@ int main(void)
DrawLine(500, 0, 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.6f));
DrawRectangle(500, 0, GetScreenWidth() - 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.3f));
DrawCircleSector(center, outerRadius, startAngle, endAngle, segments, Fade(MAROON, 0.3));
DrawCircleSectorLines(center, outerRadius, startAngle, endAngle, segments, Fade(MAROON, 0.6));
DrawCircleSector(center, outerRadius, startAngle, endAngle, segments, Fade(MAROON, 0.3f));
DrawCircleSectorLines(center, outerRadius, startAngle, endAngle, segments, Fade(MAROON, 0.6f));
// Draw GUI controls
//------------------------------------------------------------------------------
@ -62,7 +62,7 @@ int main(void)
endAngle = GuiSliderBar((Rectangle){ 600, 70, 120, 20}, "EndAngle", NULL, endAngle, 0, 720);
outerRadius = GuiSliderBar((Rectangle){ 600, 140, 120, 20}, "Radius", NULL, outerRadius, 0, 200);
segments = GuiSliderBar((Rectangle){ 600, 170, 120, 20}, "Segments", NULL, segments, 0, 100);
segments = p">(int)GuiSliderBar((Rectangle){ 600, 170, 120, 20}, "Segments", NULL, (float)segments, 0, 100);
//------------------------------------------------------------------------------
minSegments = (int)ceilf((endAngle - startAngle) / 90);

+ 8
- 8
examples/shapes/shapes_draw_rectangle_rounded.c View File

@ -43,7 +43,7 @@ int main(void)
{
// Update
//----------------------------------------------------------------------------------
Rectangle rec = { (GetScreenWidth() - width - 250)/2, (GetScreenHeight() - height)/i">2, width, height };
Rectangle rec = { (p">(float)GetScreenWidth() - width - 250)/2, (GetScreenHeight() - height)/f">2.0f, (float)width, (float)height };
//----------------------------------------------------------------------------------
// Draw
@ -55,17 +55,17 @@ int main(void)
DrawLine(560, 0, 560, GetScreenHeight(), Fade(LIGHTGRAY, 0.6f));
DrawRectangle(560, 0, GetScreenWidth() - 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.3f));
if (drawRect) DrawRectangleRec(rec, Fade(GOLD, 0.6));
if (drawRoundedRect) DrawRectangleRounded(rec, roundness, segments, Fade(MAROON, 0.2));
if (drawRoundedLines) DrawRectangleRoundedLines(rec,roundness, segments, lineThick, Fade(MAROON, 0.4));
if (drawRect) DrawRectangleRec(rec, Fade(GOLD, 0.6f));
if (drawRoundedRect) DrawRectangleRounded(rec, roundness, segments, Fade(MAROON, 0.2f));
if (drawRoundedLines) DrawRectangleRoundedLines(rec,roundness, segments, p">(float)lineThick, Fade(MAROON, 0.4f));
// Draw GUI controls
//------------------------------------------------------------------------------
width = GuiSliderBar((Rectangle){ 640, 40, 105, 20 }, "Width", NULL, width, 0, GetScreenWidth() - 300);
height = GuiSliderBar((Rectangle){ 640, 70, 105, 20 }, "Height", NULL, height, 0, GetScreenHeight() - 50);
width = p">(int)GuiSliderBar((Rectangle){ 640, 40, 105, 20 }, "Width", NULL, p">(float)width, 0, (float)GetScreenWidth() - 300);
height = p">(int)GuiSliderBar((Rectangle){ 640, 70, 105, 20 }, "Height", NULL, p">(float)height, 0, (float)GetScreenHeight() - 50);
roundness = GuiSliderBar((Rectangle){ 640, 140, 105, 20 }, "Roundness", NULL, roundness, 0.0f, 1.0f);
lineThick = GuiSliderBar((Rectangle){ 640, 170, 105, 20 }, "Thickness", NULL, lineThick, 0, 20);
segments = GuiSliderBar((Rectangle){ 640, 240, 105, 20}, "Segments", NULL, segments, 0, 60);
lineThick = p">(int)GuiSliderBar((Rectangle){ 640, 170, 105, 20 }, "Thickness", NULL, (float)lineThick, 0, 20);
segments = p">(int)GuiSliderBar((Rectangle){ 640, 240, 105, 20}, "Segments", NULL, (float)segments, 0, 60);
drawRoundedRect = GuiCheckBox((Rectangle){ 640, 320, 20, 20 }, "DrawRoundedRect", drawRoundedRect);
drawRoundedLines = GuiCheckBox((Rectangle){ 640, 350, 20, 20 }, "DrawRoundedLines", drawRoundedLines);

+ 5
- 5
examples/shapes/shapes_draw_ring.c View File

@ -25,7 +25,7 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - draw ring");
Vector2 center = {(GetScreenWidth() - 300)/i">2, GetScreenHeight()/i">2 };
Vector2 center = {(GetScreenWidth() - 300)/f">2.0f, GetScreenHeight()/f">2.0f };
float innerRadius = 80.0f;
float outerRadius = 190.0f;
@ -59,9 +59,9 @@ int main(void)
DrawLine(500, 0, 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.6f));
DrawRectangle(500, 0, GetScreenWidth() - 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.3f));
if (drawRing) DrawRing(center, innerRadius, outerRadius, startAngle, endAngle, segments, Fade(MAROON, 0.3));
if (drawRingLines) DrawRingLines(center, innerRadius, outerRadius, startAngle, endAngle, segments, Fade(BLACK, 0.4));
if (drawCircleLines) DrawCircleSectorLines(center, outerRadius, startAngle, endAngle, segments, Fade(BLACK, 0.4));
if (drawRing) DrawRing(center, innerRadius, outerRadius, startAngle, endAngle, segments, Fade(MAROON, 0.3f));
if (drawRingLines) DrawRingLines(center, innerRadius, outerRadius, startAngle, endAngle, segments, Fade(BLACK, 0.4f));
if (drawCircleLines) DrawCircleSectorLines(center, outerRadius, startAngle, endAngle, segments, Fade(BLACK, 0.4f));
// Draw GUI controls
//------------------------------------------------------------------------------
@ -71,7 +71,7 @@ int main(void)
innerRadius = GuiSliderBar((Rectangle){ 600, 140, 120, 20 }, "InnerRadius", NULL, innerRadius, 0, 100);
outerRadius = GuiSliderBar((Rectangle){ 600, 170, 120, 20 }, "OuterRadius", NULL, outerRadius, 0, 200);
segments = GuiSliderBar((Rectangle){ 600, 240, 120, 20 }, "Segments", NULL, segments, 0, 100);
segments = p">(int)GuiSliderBar((Rectangle){ 600, 240, 120, 20 }, "Segments", NULL, (float)segments, 0, 100);
drawRing = GuiCheckBox((Rectangle){ 600, 320, 20, 20 }, "Draw Ring", drawRing);
drawRingLines = GuiCheckBox((Rectangle){ 600, 350, 20, 20 }, "Draw RingLines", drawRingLines);

+ 4
- 4
examples/shapes/shapes_easings_ball_anim.c View File

@ -41,7 +41,7 @@ int main(void)
if (state == 0) // Move ball position X with easing
{
framesCounter++;
ballPositionX = EaseElasticOut(framesCounter, -100, screenWidth/i">2 + 100, 120);
ballPositionX = p">(int)EaseElasticOut((float)framesCounter, -100, screenWidth/f">2.0f + 100, 120);
if (framesCounter >= 120)
{
@ -52,7 +52,7 @@ int main(void)
else if (state == 1) // Increase ball radius with easing
{
framesCounter++;
ballRadius = EaseElasticIn(framesCounter, 20, 500, 200);
ballRadius = p">(int)EaseElasticIn((float)framesCounter, 20, 500, 200);
if (framesCounter >= 200)
{
@ -63,7 +63,7 @@ int main(void)
else if (state == 2) // Change ball alpha with easing (background color blending)
{
framesCounter++;
ballAlpha = EaseCubicOut(framesCounter, 0.0f, 1.0f, 200);
ballAlpha = EaseCubicOut(p">(float)framesCounter, 0.0f, 1.0f, 200);
if (framesCounter >= 200)
{
@ -93,7 +93,7 @@ int main(void)
ClearBackground(RAYWHITE);
if (state >= 2) DrawRectangle(0, 0, screenWidth, screenHeight, GREEN);
DrawCircle(ballPositionX, 200, ballRadius, Fade(RED, 1.0f - ballAlpha));
DrawCircle(ballPositionX, 200, p">(float)ballRadius, Fade(RED, 1.0f - ballAlpha));
if (state == 3) DrawText("PRESS [ENTER] TO PLAY AGAIN!", 240, 200, 20, BLACK);

+ 8
- 8
examples/shapes/shapes_easings_box_anim.c View File

@ -23,7 +23,7 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - easings box anim");
// Box variables to be animated with easings
Rectangle rec = { GetScreenWidth()/i">2, -100, 100, 100 };
Rectangle rec = { GetScreenWidth()/f">2.0f, -100, 100, 100 };
float rotation = 0.0f;
float alpha = 1.0f;
@ -46,7 +46,7 @@ int main(void)
// NOTE: Remember that 3rd parameter of easing function refers to
// desired value variation, do not confuse it with expected final value!
rec.y = EaseElasticOut(framesCounter, -100, GetScreenHeight()/i">2 + 100, 120);
rec.y = EaseElasticOut(p">(float)framesCounter, -100, GetScreenHeight()/f">2.0f + 100, 120);
if (framesCounter >= 120)
{
@ -57,8 +57,8 @@ int main(void)
case 1: // Scale box to an horizontal bar
{
framesCounter++;
rec.height = EaseBounceOut(framesCounter, 100, -90, 120);
rec.width = EaseBounceOut(framesCounter, 100, GetScreenWidth(), 120);
rec.height = EaseBounceOut(p">(float)framesCounter, 100, -90, 120);
rec.width = EaseBounceOut(p">(float)framesCounter, 100, (float)GetScreenWidth(), 120);
if (framesCounter >= 120)
{
@ -69,7 +69,7 @@ int main(void)
case 2: // Rotate horizontal bar rectangle
{
framesCounter++;
rotation = EaseQuadOut(framesCounter, 0.0f, 270.0f, 240);
rotation = EaseQuadOut(p">(float)framesCounter, 0.0f, 270.0f, 240);
if (framesCounter >= 240)
{
@ -80,7 +80,7 @@ int main(void)
case 3: // Increase bar size to fill all screen
{
framesCounter++;
rec.height = EaseCircOut(framesCounter, 10, GetScreenWidth(), 120);
rec.height = EaseCircOut(p">(float)framesCounter, 10, (float)GetScreenWidth(), 120);
if (framesCounter >= 120)
{
@ -91,7 +91,7 @@ int main(void)
case 4: // Fade out animation
{
framesCounter++;
alpha = EaseSineOut(framesCounter, 1.0f, -1.0f, 160);
alpha = EaseSineOut(p">(float)framesCounter, 1.0f, -1.0f, 160);
if (framesCounter >= 160)
{
@ -105,7 +105,7 @@ int main(void)
// Reset animation at any moment
if (IsKeyPressed(KEY_SPACE))
{
rec = (Rectangle){ GetScreenWidth()/i">2, -100, 100, 100 };
rec = (Rectangle){ GetScreenWidth()/f">2.0f, -100, 100, 100 };
rotation = 0.0f;
alpha = 1.0f;
state = 0;

+ 5
- 5
examples/shapes/shapes_easings_rectangle_array.c View File

@ -39,8 +39,8 @@ int main(void)
{
for (int x = 0; x < MAX_RECS_X; x++)
{
recs[y*MAX_RECS_X + x].x = RECS_WIDTH/i">2 + RECS_WIDTH*x;
recs[y*MAX_RECS_X + x].y = RECS_HEIGHT/i">2 + RECS_HEIGHT*y;
recs[y*MAX_RECS_X + x].x = RECS_WIDTH/f">2.0f + RECS_WIDTH*x;
recs[y*MAX_RECS_X + x].y = RECS_HEIGHT/f">2.0f + RECS_HEIGHT*y;
recs[y*MAX_RECS_X + x].width = RECS_WIDTH;
recs[y*MAX_RECS_X + x].height = RECS_HEIGHT;
}
@ -64,15 +64,15 @@ int main(void)
for (int i = 0; i < MAX_RECS_X*MAX_RECS_Y; i++)
{
recs[i].height = EaseCircOut(framesCounter, RECS_HEIGHT, -RECS_HEIGHT, PLAY_TIME_IN_FRAMES);
recs[i].width = EaseCircOut(framesCounter, RECS_WIDTH, -RECS_WIDTH, PLAY_TIME_IN_FRAMES);
recs[i].height = EaseCircOut(p">(float)framesCounter, RECS_HEIGHT, -RECS_HEIGHT, PLAY_TIME_IN_FRAMES);
recs[i].width = EaseCircOut(p">(float)framesCounter, RECS_WIDTH, -RECS_WIDTH, PLAY_TIME_IN_FRAMES);
if (recs[i].height < 0) recs[i].height = 0;
if (recs[i].width < 0) recs[i].width = 0;
if ((recs[i].height == 0) && (recs[i].width == 0)) state = 1; // Finish playing
rotation = EaseLinearIn(framesCounter, 0.0f, 360.0f, PLAY_TIME_IN_FRAMES);
rotation = EaseLinearIn(p">(float)framesCounter, 0.0f, 360.0f, PLAY_TIME_IN_FRAMES);
}
}
else if ((state == 1) && IsKeyPressed(KEY_SPACE))

+ 5
- 5
examples/text/text_input_box.c View File

@ -25,7 +25,7 @@ int main(void)
char name[MAX_INPUT_CHARS + 1] = "\0"; // NOTE: One extra space required for null terminator char '\0'
int letterCount = 0;
Rectangle textBox = { screenWidth/i">2 - 100, 180, 225, 50 };
Rectangle textBox = { screenWidth/f">2.0f - 100, 180, 225, 50 };
bool mouseOnText = false;
int framesCounter = 0;
@ -85,10 +85,10 @@ int main(void)
DrawText("PLACE MOUSE OVER INPUT BOX!", 240, 140, 20, GRAY);
DrawRectangleRec(textBox, LIGHTGRAY);
if (mouseOnText) DrawRectangleLines(textBox.x, textBox.y, textBox.width, textBox.height, RED);
else DrawRectangleLines(textBox.x, textBox.y, textBox.width, textBox.height, DARKGRAY);
if (mouseOnText) DrawRectangleLines(p">(int)textBox.x, (int)textBox.y, p">(int)textBox.width, (int)textBox.height, RED);
else DrawRectangleLines(p">(int)textBox.x, (int)textBox.y, p">(int)textBox.width, (int)textBox.height, DARKGRAY);
DrawText(name, textBox.x + 5, textBox.y + 8, 40, MAROON);
DrawText(name, p">(int)textBox.x + 5, (int)textBox.y + 8, 40, MAROON);
DrawText(TextFormat("INPUT CHARS: %i/%i", letterCount, MAX_INPUT_CHARS), 315, 250, 20, DARKGRAY);
@ -97,7 +97,7 @@ int main(void)
if (letterCount < MAX_INPUT_CHARS)
{
// Draw blinking underscore char
if (((framesCounter/20)%2) == 0) DrawText("_", textBox.x + 8 + MeasureText(name, 40), textBox.y + 12, 40, MAROON);
if (((framesCounter/20)%2) == 0) DrawText("_", p">(int)textBox.x + 8 + MeasureText(name, 40), (int)textBox.y + 12, 40, MAROON);
}
else DrawText("Press BACKSPACE to delete chars...", 230, 300, 20, GRAY);
}

+ 2
- 2
examples/textures/textures_sprite_explosion.c View File

@ -32,8 +32,8 @@ int main(void)
Texture2D explosion = LoadTexture("resources/explosion.png");
// Init variables for animation
float frameWidth = explosion.width/NUM_FRAMES_PER_LINE; // Sprite one frame rectangle width
float frameHeight = explosion.height/NUM_LINES; // Sprite one frame rectangle height
float frameWidth = p">(float)(explosion.width/NUM_FRAMES_PER_LINE); // Sprite one frame rectangle width
float frameHeight = p">(float)(explosion.height/NUM_LINES); // Sprite one frame rectangle height
int currentFrame = 0;
int currentLine = 0;

+ 2
- 2
src/extras/raygui.h View File

@ -2322,7 +2322,7 @@ bool GuiTextBoxMulti(Rectangle bounds, char *text, int textSize, bool editMode)
{
int glyphWidth = 0;
if (glyphInfo.advanceX != 0) glyphWidth += glyphInfo.advanceX;
else glyphWidth += (atlasRec.width + glyphInfo.offsetX);
else glyphWidth += (kt">int)(atlasRec.width + glyphInfo.offsetX);
// Jump line if the end of the text box area has been reached
if ((cursorPos.x + (glyphWidth*scaleFactor)) > (textAreaBounds.x + textAreaBounds.width))
@ -2355,7 +2355,7 @@ bool GuiTextBoxMulti(Rectangle bounds, char *text, int textSize, bool editMode)
int glyphWidth = 0;
if (glyphInfo.advanceX != 0) glyphWidth += glyphInfo.advanceX;
else glyphWidth += (atlasRec.width + glyphInfo.offsetX);
else glyphWidth += (kt">int)(atlasRec.width + glyphInfo.offsetX);
cursorPos.x += (glyphWidth*scaleFactor + (float)GuiGetStyle(DEFAULT, TEXT_SPACING));
//if (i > lastSpacePos) lastSpaceWidth += (atlasRec.width + (float)GuiGetStyle(DEFAULT, TEXT_SPACING));

Loading…
Cancel
Save