Fix VC warnings for examples (#2085)
This commit is contained in:
parent
086f76ba7a
commit
daeccd03ac
@ -102,7 +102,7 @@ int main(void)
|
|||||||
UnloadTexture(texture); // Unload texture
|
UnloadTexture(texture); // Unload texture
|
||||||
|
|
||||||
// Unload model animations data
|
// 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);
|
RL_FREE(anims);
|
||||||
|
|
||||||
UnloadModel(model); // Unload model
|
UnloadModel(model); // Unload model
|
||||||
|
@ -34,11 +34,11 @@ int main(void)
|
|||||||
InitPhysics();
|
InitPhysics();
|
||||||
|
|
||||||
// Create floor rectangle physics body
|
// Create floor rectangle physics body
|
||||||
PhysicsBody floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2, screenHeight }, 500, 100, 10);
|
PhysicsBody floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2.0f, (float)screenHeight }, 500, 100, 10);
|
||||||
floor->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions)
|
floor->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions)
|
||||||
|
|
||||||
// Create obstacle circle physics body
|
// Create obstacle circle physics body
|
||||||
PhysicsBody circle = CreatePhysicsBodyCircle((Vector2){ screenWidth/2, screenHeight/2 }, 45, 10);
|
PhysicsBody circle = CreatePhysicsBodyCircle((Vector2){ screenWidth/2.0f, screenHeight/2.0f }, 45, 10);
|
||||||
circle->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions)
|
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
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
@ -55,16 +55,16 @@ int main(void)
|
|||||||
{
|
{
|
||||||
ResetPhysics();
|
ResetPhysics();
|
||||||
|
|
||||||
floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2, screenHeight }, 500, 100, 10);
|
floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2.0f, (float)screenHeight }, 500, 100, 10);
|
||||||
floor->enabled = false;
|
floor->enabled = false;
|
||||||
|
|
||||||
circle = CreatePhysicsBodyCircle((Vector2){ screenWidth/2, screenHeight/2 }, 45, 10);
|
circle = CreatePhysicsBodyCircle((Vector2){ screenWidth/2.0f, screenHeight/2.0f }, 45, 10);
|
||||||
circle->enabled = false;
|
circle->enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Physics body creation inputs
|
// Physics body creation inputs
|
||||||
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) CreatePhysicsBodyPolygon(GetMousePosition(), GetRandomValue(20, 80), GetRandomValue(3, 8), 10);
|
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) CreatePhysicsBodyPolygon(GetMousePosition(), (float)GetRandomValue(20, 80), GetRandomValue(3, 8), 10);
|
||||||
else if (IsMouseButtonPressed(MOUSE_BUTTON_RIGHT)) CreatePhysicsBodyCircle(GetMousePosition(), GetRandomValue(10, 45), 10);
|
else if (IsMouseButtonPressed(MOUSE_BUTTON_RIGHT)) CreatePhysicsBodyCircle(GetMousePosition(), (float)GetRandomValue(10, 45), 10);
|
||||||
|
|
||||||
// Destroy falling physics bodies
|
// Destroy falling physics bodies
|
||||||
int bodiesCount = GetPhysicsBodiesCount();
|
int bodiesCount = GetPhysicsBodiesCount();
|
||||||
|
@ -34,18 +34,18 @@ int main(void)
|
|||||||
InitPhysics();
|
InitPhysics();
|
||||||
|
|
||||||
// Create floor rectangle physics body
|
// Create floor rectangle physics body
|
||||||
PhysicsBody floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2, screenHeight }, screenWidth, 100, 10);
|
PhysicsBody floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2.0f, (float)screenHeight }, (float)screenWidth, 100, 10);
|
||||||
floor->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions)
|
floor->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions)
|
||||||
PhysicsBody wall = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2, screenHeight*0.8f }, 10, 80, 10);
|
PhysicsBody wall = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2.0f, screenHeight*0.8f }, 10, 80, 10);
|
||||||
wall->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions)
|
wall->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions)
|
||||||
|
|
||||||
// Create left ramp physics body
|
// Create left ramp physics body
|
||||||
PhysicsBody rectLeft = CreatePhysicsBodyRectangle((Vector2){ 25, screenHeight - 5 }, 250, 250, 10);
|
PhysicsBody rectLeft = CreatePhysicsBodyRectangle((Vector2){ 25, (float)screenHeight - 5 }, 250, 250, 10);
|
||||||
rectLeft->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions)
|
rectLeft->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions)
|
||||||
SetPhysicsBodyRotation(rectLeft, 30*DEG2RAD);
|
SetPhysicsBodyRotation(rectLeft, 30*DEG2RAD);
|
||||||
|
|
||||||
// Create right ramp physics body
|
// Create right ramp physics body
|
||||||
PhysicsBody rectRight = CreatePhysicsBodyRectangle((Vector2){ screenWidth - 25, screenHeight - 5 }, 250, 250, 10);
|
PhysicsBody rectRight = CreatePhysicsBodyRectangle((Vector2){ (float)screenWidth - 25, (float)screenHeight - 5 }, 250, 250, 10);
|
||||||
rectRight->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions)
|
rectRight->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions)
|
||||||
SetPhysicsBodyRotation(rectRight, 330*DEG2RAD);
|
SetPhysicsBodyRotation(rectRight, 330*DEG2RAD);
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ int main(void)
|
|||||||
bodyA->dynamicFriction = 0.1f;
|
bodyA->dynamicFriction = 0.1f;
|
||||||
SetPhysicsBodyRotation(bodyA, 30*DEG2RAD);
|
SetPhysicsBodyRotation(bodyA, 30*DEG2RAD);
|
||||||
|
|
||||||
PhysicsBody bodyB = CreatePhysicsBodyRectangle((Vector2){ screenWidth - 35, screenHeight*0.6f }, 40, 40, 10);
|
PhysicsBody bodyB = CreatePhysicsBodyRectangle((Vector2){ (float)screenWidth - 35, (float)screenHeight*0.6f }, 40, 40, 10);
|
||||||
bodyB->staticFriction = 1.0f;
|
bodyB->staticFriction = 1.0f;
|
||||||
bodyB->dynamicFriction = 1.0f;
|
bodyB->dynamicFriction = 1.0f;
|
||||||
SetPhysicsBodyRotation(bodyB, 330*DEG2RAD);
|
SetPhysicsBodyRotation(bodyB, 330*DEG2RAD);
|
||||||
@ -78,7 +78,7 @@ int main(void)
|
|||||||
bodyA->angularVelocity = 0;
|
bodyA->angularVelocity = 0;
|
||||||
SetPhysicsBodyRotation(bodyA, 30*DEG2RAD);
|
SetPhysicsBodyRotation(bodyA, 30*DEG2RAD);
|
||||||
|
|
||||||
bodyB->position = (Vector2){ screenWidth - 35, screenHeight*0.6f };
|
bodyB->position = (Vector2){ (float)screenWidth - 35, screenHeight * 0.6f };
|
||||||
bodyB->velocity = (Vector2){ 0, 0 };
|
bodyB->velocity = (Vector2){ 0, 0 };
|
||||||
bodyB->angularVelocity = 0;
|
bodyB->angularVelocity = 0;
|
||||||
SetPhysicsBodyRotation(bodyB, 330*DEG2RAD);
|
SetPhysicsBodyRotation(bodyB, 330*DEG2RAD);
|
||||||
@ -118,9 +118,9 @@ int main(void)
|
|||||||
|
|
||||||
DrawRectangle(0, screenHeight - 49, screenWidth, 49, BLACK);
|
DrawRectangle(0, screenHeight - 49, screenWidth, 49, BLACK);
|
||||||
|
|
||||||
DrawText("Friction amount", (screenWidth - MeasureText("Friction amount", 30))/2, 75, 30, WHITE);
|
DrawText("Friction amount", (screenWidth - MeasureText("Friction amount", 30))/2.0f, 75, 30, WHITE);
|
||||||
DrawText("0.1", bodyA->position.x - MeasureText("0.1", 20)/2, bodyA->position.y - 7, 20, WHITE);
|
DrawText("0.1", (int)bodyA->position.x - MeasureText("0.1", 20)/2, (int)bodyA->position.y - 7, 20, WHITE);
|
||||||
DrawText("1", bodyB->position.x - MeasureText("1", 20)/2, bodyB->position.y - 7, 20, WHITE);
|
DrawText("1", (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);
|
DrawText("Press 'R' to reset example", 10, 10, 10, WHITE);
|
||||||
|
|
||||||
|
@ -36,11 +36,11 @@ int main(void)
|
|||||||
InitPhysics();
|
InitPhysics();
|
||||||
|
|
||||||
// Create floor and walls rectangle physics body
|
// Create floor and walls rectangle physics body
|
||||||
PhysicsBody floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2, screenHeight }, screenWidth, 100, 10);
|
PhysicsBody floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2.0f, (float)screenHeight }, (float)screenWidth, 100, 10);
|
||||||
PhysicsBody platformLeft = CreatePhysicsBodyRectangle((Vector2){ screenWidth*0.25f, screenHeight*0.6f }, screenWidth*0.25f, 10, 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 platformRight = CreatePhysicsBodyRectangle((Vector2){ screenWidth*0.75f, screenHeight*0.6f }, screenWidth*0.25f, 10, 10);
|
||||||
PhysicsBody wallLeft = CreatePhysicsBodyRectangle((Vector2){ -5, screenHeight/2 }, 10, screenHeight, 10);
|
PhysicsBody wallLeft = CreatePhysicsBodyRectangle((Vector2){ -5, screenHeight/2.0f }, 10, (float)screenHeight, 10);
|
||||||
PhysicsBody wallRight = CreatePhysicsBodyRectangle((Vector2){ screenWidth + 5, screenHeight/2 }, 10, screenHeight, 10);
|
PhysicsBody wallRight = CreatePhysicsBodyRectangle((Vector2){ (float)screenWidth + 5, screenHeight/2.0f }, 10, (float)screenHeight, 10);
|
||||||
|
|
||||||
// Disable dynamics to floor and walls physics bodies
|
// Disable dynamics to floor and walls physics bodies
|
||||||
floor->enabled = false;
|
floor->enabled = false;
|
||||||
@ -50,7 +50,7 @@ int main(void)
|
|||||||
wallRight->enabled = false;
|
wallRight->enabled = false;
|
||||||
|
|
||||||
// Create movement physics body
|
// Create movement physics body
|
||||||
PhysicsBody body = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2, screenHeight/2 }, 50, 50, 1);
|
PhysicsBody body = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2.0f, screenHeight/2.0f }, 50, 50, 1);
|
||||||
body->freezeOrient = true; // Constrain body rotation to avoid little collision torque amounts
|
body->freezeOrient = true; // Constrain body rotation to avoid little collision torque amounts
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
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
|
if (IsKeyPressed(KEY_R)) // Reset physics input
|
||||||
{
|
{
|
||||||
// Reset movement physics body position, velocity and rotation
|
// Reset movement physics body position, velocity and rotation
|
||||||
body->position = (Vector2){ screenWidth/2, screenHeight/2 };
|
body->position = (Vector2){ screenWidth/2.0f, screenHeight/2.0f };
|
||||||
body->velocity = (Vector2){ 0, 0 };
|
body->velocity = (Vector2){ 0, 0 };
|
||||||
SetPhysicsBodyRotation(body, 0);
|
SetPhysicsBodyRotation(body, 0);
|
||||||
}
|
}
|
||||||
|
@ -34,16 +34,16 @@ int main(void)
|
|||||||
InitPhysics();
|
InitPhysics();
|
||||||
|
|
||||||
// Create floor rectangle physics body
|
// Create floor rectangle physics body
|
||||||
PhysicsBody floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2, screenHeight }, screenWidth, 100, 10);
|
PhysicsBody floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2.0f, (float)screenHeight }, (float)screenWidth, 100, 10);
|
||||||
floor->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions)
|
floor->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions)
|
||||||
floor->restitution = 1;
|
floor->restitution = 1;
|
||||||
|
|
||||||
// Create circles physics body
|
// Create circles physics body
|
||||||
PhysicsBody circleA = CreatePhysicsBodyCircle((Vector2){ screenWidth*0.25f, screenHeight/2 }, 30, 10);
|
PhysicsBody circleA = CreatePhysicsBodyCircle((Vector2){ screenWidth*0.25f, screenHeight/2.0f }, 30, 10);
|
||||||
circleA->restitution = 0;
|
circleA->restitution = 0;
|
||||||
PhysicsBody circleB = CreatePhysicsBodyCircle((Vector2){ screenWidth*0.5f, screenHeight/2 }, 30, 10);
|
PhysicsBody circleB = CreatePhysicsBodyCircle((Vector2){ screenWidth*0.5f, screenHeight/2.0f }, 30, 10);
|
||||||
circleB->restitution = 0.5f;
|
circleB->restitution = 0.5f;
|
||||||
PhysicsBody circleC = CreatePhysicsBodyCircle((Vector2){ screenWidth*0.75f, screenHeight/2 }, 30, 10);
|
PhysicsBody circleC = CreatePhysicsBodyCircle((Vector2){ screenWidth*0.75f, screenHeight/2.0f }, 30, 10);
|
||||||
circleC->restitution = 1;
|
circleC->restitution = 1;
|
||||||
|
|
||||||
// Restitution demo needs a very tiny physics time step for a proper simulation
|
// 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
|
if (IsKeyPressed(KEY_R)) // Reset physics input
|
||||||
{
|
{
|
||||||
// Reset circles physics bodies position and velocity
|
// Reset circles physics bodies position and velocity
|
||||||
circleA->position = (Vector2){ screenWidth*0.25f, screenHeight/2 };
|
circleA->position = (Vector2){ screenWidth*0.25f, screenHeight/2.0f };
|
||||||
circleA->velocity = (Vector2){ 0, 0 };
|
circleA->velocity = (Vector2){ 0, 0 };
|
||||||
circleB->position = (Vector2){ screenWidth*0.5f, screenHeight/2 };
|
circleB->position = (Vector2){ screenWidth*0.5f, screenHeight/2.0f };
|
||||||
circleB->velocity = (Vector2){ 0, 0 };
|
circleB->velocity = (Vector2){ 0, 0 };
|
||||||
circleC->position = (Vector2){ screenWidth*0.75f, screenHeight/2 };
|
circleC->position = (Vector2){ screenWidth*0.75f, screenHeight/2.0f };
|
||||||
circleC->velocity = (Vector2){ 0, 0 };
|
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("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", (int)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("0.5", (int)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("1", (int)circleC->position.x - MeasureText("1", 20)/2, circleC->position.y - 7, 20, WHITE);
|
||||||
|
|
||||||
DrawText("Press 'R' to reset example", 10, 10, 10, WHITE);
|
DrawText("Press 'R' to reset example", 10, 10, 10, WHITE);
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ int main(void)
|
|||||||
SetPhysicsGravity(0, 0);
|
SetPhysicsGravity(0, 0);
|
||||||
|
|
||||||
// Create random polygon physics body to shatter
|
// 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 }, (float)GetRandomValue(80, 200), GetRandomValue(3, 8), 10);
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
@ -50,7 +50,7 @@ int main(void)
|
|||||||
{
|
{
|
||||||
ResetPhysics();
|
ResetPhysics();
|
||||||
|
|
||||||
CreatePhysicsBodyPolygon((Vector2){ screenWidth/2.0f, screenHeight/2.0f }, GetRandomValue(80, 200), GetRandomValue(3, 8), 10);
|
CreatePhysicsBodyPolygon((Vector2){ screenWidth/2.0f, screenHeight/2.0f }, (float)GetRandomValue(80, 200), GetRandomValue(3, 8), 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) // Physics shatter input
|
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) // Physics shatter input
|
||||||
|
@ -67,14 +67,14 @@ int main(void)
|
|||||||
// Scatter random cubes around
|
// Scatter random cubes around
|
||||||
for (int i = 0; i < MAX_INSTANCES; i++)
|
for (int i = 0; i < MAX_INSTANCES; i++)
|
||||||
{
|
{
|
||||||
x = GetRandomValue(-50, 50);
|
x = (float)GetRandomValue(-50, 50);
|
||||||
y = GetRandomValue(-50, 50);
|
y = (float)GetRandomValue(-50, 50);
|
||||||
z = GetRandomValue(-50, 50);
|
z = (float)GetRandomValue(-50, 50);
|
||||||
translations[i] = MatrixTranslate(x, y, z);
|
translations[i] = MatrixTranslate(x, y, z);
|
||||||
|
|
||||||
x = GetRandomValue(0, 360);
|
x = (float)GetRandomValue(0, 360);
|
||||||
y = GetRandomValue(0, 360);
|
y = (float)GetRandomValue(0, 360);
|
||||||
z = GetRandomValue(0, 360);
|
z = (float)GetRandomValue(0, 360);
|
||||||
Vector3 axis = Vector3Normalize((Vector3){ x, y, z });
|
Vector3 axis = Vector3Normalize((Vector3){ x, y, z });
|
||||||
float angle = (float)GetRandomValue(0, 10)*DEG2RAD;
|
float angle = (float)GetRandomValue(0, 10)*DEG2RAD;
|
||||||
|
|
||||||
@ -136,11 +136,11 @@ int main(void)
|
|||||||
if (IsKeyDown(KEY_NINE)) groups = 9;
|
if (IsKeyDown(KEY_NINE)) groups = 9;
|
||||||
if (IsKeyDown(KEY_W)) { groups = 7; amp = 25; speed = 18; variance = 0.70f; }
|
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_EQUAL)) speed = (speed <= (fps*0.25f))? (int)(fps*0.25f) : (int)(speed*0.95f);
|
||||||
if (IsKeyDown(KEY_KP_ADD)) speed = (speed <= (fps*0.25f))? (fps*0.25f) : (speed*0.95f);
|
if (IsKeyDown(KEY_KP_ADD)) speed = (speed <= (fps*0.25f))? (int)(fps*0.25f) : (int)(speed*0.95f);
|
||||||
|
|
||||||
if (IsKeyDown(KEY_MINUS)) speed = fmaxf(speed*1.02f, speed + 1);
|
if (IsKeyDown(KEY_MINUS)) speed = (int)fmaxf(speed*1.02f, speed + 1);
|
||||||
if (IsKeyDown(KEY_KP_SUBTRACT)) speed = fmaxf(speed*1.02f, speed + 1);
|
if (IsKeyDown(KEY_KP_SUBTRACT)) speed = (int)fmaxf(speed*1.02f, speed + 1);
|
||||||
|
|
||||||
// Update the light shader with the camera view position
|
// Update the light shader with the camera view position
|
||||||
float cameraPos[3] = { camera.position.x, camera.position.y, camera.position.z };
|
float cameraPos[3] = { camera.position.x, camera.position.y, camera.position.z };
|
||||||
|
@ -120,14 +120,14 @@ int main(void)
|
|||||||
// and initialize the shader locations
|
// and initialize the shader locations
|
||||||
for (int i = 0; i < MAX_SPOTS; i++)
|
for (int i = 0; i < MAX_SPOTS; i++)
|
||||||
{
|
{
|
||||||
spots[i].pos.x = GetRandomValue(64.0f, screenWidth - 64.0f);
|
spots[i].pos.x = (float)GetRandomValue(64, screenWidth - 64);
|
||||||
spots[i].pos.y = GetRandomValue(64.0f, screenHeight - 64.0f);
|
spots[i].pos.y = (float)GetRandomValue(64, screenHeight - 64);
|
||||||
spots[i].vel = (Vector2){ 0, 0 };
|
spots[i].vel = (Vector2){ 0, 0 };
|
||||||
|
|
||||||
while ((fabs(spots[i].vel.x) + fabs(spots[i].vel.y)) < 2)
|
while ((fabs(spots[i].vel.x) + fabs(spots[i].vel.y)) < 2)
|
||||||
{
|
{
|
||||||
spots[i].vel.x = GetRandomValue(-400.f, 40.0f) / 10.0f;
|
spots[i].vel.x = GetRandomValue(-400, 40) / 10.0f;
|
||||||
spots[i].vel.y = GetRandomValue(-400.f, 40.0f) / 10.0f;
|
spots[i].vel.y = GetRandomValue(-400, 40) / 10.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
spots[i].inner = 28.0f * (i + 1);
|
spots[i].inner = 28.0f * (i + 1);
|
||||||
@ -190,8 +190,8 @@ int main(void)
|
|||||||
for (int i = 0; i < 16; i++)
|
for (int i = 0; i < 16; i++)
|
||||||
{
|
{
|
||||||
DrawTexture(texRay,
|
DrawTexture(texRay,
|
||||||
(screenWidth/2.0f) + cos((frameCounter + i*8)/51.45f)*(screenWidth/2.2f) - 32,
|
(int)((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);
|
(int)((screenHeight/2.0f) + sin((frameCounter + i*8)/17.87f)*(screenHeight/4.2f)), WHITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw spot lights
|
// Draw spot lights
|
||||||
@ -206,8 +206,8 @@ int main(void)
|
|||||||
DrawFPS(10, 10);
|
DrawFPS(10, 10);
|
||||||
|
|
||||||
DrawText("Move the mouse!", 10, 30, 20, GREEN);
|
DrawText("Move the mouse!", 10, 30, 20, GREEN);
|
||||||
DrawText("Pitch Black", screenWidth*0.2f, screenHeight/2, 20, GREEN);
|
DrawText("Pitch Black", (int)(screenWidth*0.2f), screenHeight/2, 20, GREEN);
|
||||||
DrawText("Dark", screenWidth*.66f, screenHeight/2, 20, GREEN);
|
DrawText("Dark", (int)(screenWidth*.66f), screenHeight/2, 20, GREEN);
|
||||||
|
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
|
@ -59,8 +59,8 @@ int main(void)
|
|||||||
(Vector2){screenWidth/4.0f*3.0f + 20.0f, 230.0f}, DARKBLUE);
|
(Vector2){screenWidth/4.0f*3.0f + 20.0f, 230.0f}, DARKBLUE);
|
||||||
|
|
||||||
// Polygon shapes and lines
|
// Polygon shapes and lines
|
||||||
DrawPoly((Vector2){screenWidth/4*3, 320}, 6, 80, 0, BROWN);
|
DrawPoly((Vector2){screenWidth/4.0f*3, 320}, 6, 80, 0, BROWN);
|
||||||
DrawPolyLinesEx((Vector2){screenWidth/4*3, 320}, 6, 80, 0, 6, BEIGE);
|
DrawPolyLinesEx((Vector2){screenWidth/4.0f*3, 320}, 6, 80, 0, 6, BEIGE);
|
||||||
|
|
||||||
// NOTE: We draw all LINES based shapes together to optimize internal drawing,
|
// NOTE: We draw all LINES based shapes together to optimize internal drawing,
|
||||||
// this way, all LINES are rendered in a single draw pass
|
// this way, all LINES are rendered in a single draw pass
|
||||||
|
@ -20,7 +20,7 @@ int main(void)
|
|||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - bouncing ball");
|
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - bouncing ball");
|
||||||
|
|
||||||
Vector2 ballPosition = { GetScreenWidth()/2, GetScreenHeight()/2 };
|
Vector2 ballPosition = { GetScreenWidth()/2.0f, GetScreenHeight()/2.0f };
|
||||||
Vector2 ballSpeed = { 5.0f, 4.0f };
|
Vector2 ballSpeed = { 5.0f, 4.0f };
|
||||||
int ballRadius = 20;
|
int ballRadius = 20;
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ int main(void)
|
|||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
DrawCircleV(ballPosition, ballRadius, MAROON);
|
DrawCircleV(ballPosition, (float)ballRadius, MAROON);
|
||||||
DrawText("PRESS SPACE to PAUSE BALL MOVEMENT", 10, GetScreenHeight() - 25, 20, LIGHTGRAY);
|
DrawText("PRESS SPACE to PAUSE BALL MOVEMENT", 10, GetScreenHeight() - 25, 20, LIGHTGRAY);
|
||||||
|
|
||||||
// On pause, we draw a blinking message
|
// On pause, we draw a blinking message
|
||||||
|
@ -22,11 +22,11 @@ int main(void)
|
|||||||
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - collision area");
|
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - collision area");
|
||||||
|
|
||||||
// Box A: Moving box
|
// Box A: Moving box
|
||||||
Rectangle boxA = { 10, GetScreenHeight()/2 - 50, 200, 100 };
|
Rectangle boxA = { 10, GetScreenHeight()/2.0f - 50, 200, 100 };
|
||||||
int boxASpeedX = 4;
|
int boxASpeedX = 4;
|
||||||
|
|
||||||
// Box B: Mouse moved box
|
// Box B: Mouse moved box
|
||||||
Rectangle boxB = { GetScreenWidth()/2 - 30, GetScreenHeight()/2 - 30, 60, 60 };
|
Rectangle boxB = { GetScreenWidth()/2.0f - 30, GetScreenHeight()/2.0f - 30, 60, 60 };
|
||||||
|
|
||||||
Rectangle boxCollision = { 0 }; // Collision rectangle
|
Rectangle boxCollision = { 0 }; // Collision rectangle
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ int main(void)
|
|||||||
else if (boxB.x <= 0) boxB.x = 0;
|
else if (boxB.x <= 0) boxB.x = 0;
|
||||||
|
|
||||||
if ((boxB.y + boxB.height) >= GetScreenHeight()) boxB.y = GetScreenHeight() - boxB.height;
|
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 = (float)screenUpperLimit;
|
||||||
|
|
||||||
// Check boxes collision
|
// Check boxes collision
|
||||||
collision = CheckCollisionRecs(boxA, boxB);
|
collision = CheckCollisionRecs(boxA, boxB);
|
||||||
|
@ -79,10 +79,10 @@ int main(void)
|
|||||||
|
|
||||||
if (IsKeyDown(KEY_SPACE) || colorState[i])
|
if (IsKeyDown(KEY_SPACE) || colorState[i])
|
||||||
{
|
{
|
||||||
DrawRectangle(colorsRecs[i].x, colorsRecs[i].y + colorsRecs[i].height - 26, colorsRecs[i].width, 20, BLACK);
|
DrawRectangle((int)colorsRecs[i].x, (int)(colorsRecs[i].y + colorsRecs[i].height - 26), (int)colorsRecs[i].width, 20, BLACK);
|
||||||
DrawRectangleLinesEx(colorsRecs[i], 6, Fade(BLACK, 0.3f));
|
DrawRectangleLinesEx(colorsRecs[i], 6, Fade(BLACK, 0.3f));
|
||||||
DrawText(colorNames[i], colorsRecs[i].x + colorsRecs[i].width - MeasureText(colorNames[i], 10) - 12,
|
DrawText(colorNames[i], (int)(colorsRecs[i].x + colorsRecs[i].width - MeasureText(colorNames[i], 10) - 12),
|
||||||
colorsRecs[i].y + colorsRecs[i].height - 20, 10, colors[i]);
|
(int)(colorsRecs[i].y + colorsRecs[i].height - 20), 10, colors[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ int main(void)
|
|||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - draw circle sector");
|
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - draw circle sector");
|
||||||
|
|
||||||
Vector2 center = {(GetScreenWidth() - 300)/2, GetScreenHeight()/2 };
|
Vector2 center = {(GetScreenWidth() - 300)/2.0f, GetScreenHeight()/2.0f };
|
||||||
|
|
||||||
float outerRadius = 180.0f;
|
float outerRadius = 180.0f;
|
||||||
float startAngle = 0.0f;
|
float startAngle = 0.0f;
|
||||||
@ -53,8 +53,8 @@ int main(void)
|
|||||||
DrawLine(500, 0, 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.6f));
|
DrawLine(500, 0, 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.6f));
|
||||||
DrawRectangle(500, 0, GetScreenWidth() - 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.3f));
|
DrawRectangle(500, 0, GetScreenWidth() - 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.3f));
|
||||||
|
|
||||||
DrawCircleSector(center, outerRadius, startAngle, endAngle, segments, Fade(MAROON, 0.3));
|
DrawCircleSector(center, outerRadius, startAngle, endAngle, segments, Fade(MAROON, 0.3f));
|
||||||
DrawCircleSectorLines(center, outerRadius, startAngle, endAngle, segments, Fade(MAROON, 0.6));
|
DrawCircleSectorLines(center, outerRadius, startAngle, endAngle, segments, Fade(MAROON, 0.6f));
|
||||||
|
|
||||||
// Draw GUI controls
|
// Draw GUI controls
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
@ -62,7 +62,7 @@ int main(void)
|
|||||||
endAngle = GuiSliderBar((Rectangle){ 600, 70, 120, 20}, "EndAngle", NULL, endAngle, 0, 720);
|
endAngle = GuiSliderBar((Rectangle){ 600, 70, 120, 20}, "EndAngle", NULL, endAngle, 0, 720);
|
||||||
|
|
||||||
outerRadius = GuiSliderBar((Rectangle){ 600, 140, 120, 20}, "Radius", NULL, outerRadius, 0, 200);
|
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 = (int)GuiSliderBar((Rectangle){ 600, 170, 120, 20}, "Segments", NULL, (float)segments, 0, 100);
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
minSegments = (int)ceilf((endAngle - startAngle) / 90);
|
minSegments = (int)ceilf((endAngle - startAngle) / 90);
|
||||||
|
@ -43,7 +43,7 @@ int main(void)
|
|||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
Rectangle rec = { (GetScreenWidth() - width - 250)/2, (GetScreenHeight() - height)/2, width, height };
|
Rectangle rec = { ((float)GetScreenWidth() - width - 250)/2, (GetScreenHeight() - height)/2.0f, (float)width, (float)height };
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
@ -55,17 +55,17 @@ int main(void)
|
|||||||
DrawLine(560, 0, 560, GetScreenHeight(), Fade(LIGHTGRAY, 0.6f));
|
DrawLine(560, 0, 560, GetScreenHeight(), Fade(LIGHTGRAY, 0.6f));
|
||||||
DrawRectangle(560, 0, GetScreenWidth() - 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.3f));
|
DrawRectangle(560, 0, GetScreenWidth() - 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.3f));
|
||||||
|
|
||||||
if (drawRect) DrawRectangleRec(rec, Fade(GOLD, 0.6));
|
if (drawRect) DrawRectangleRec(rec, Fade(GOLD, 0.6f));
|
||||||
if (drawRoundedRect) DrawRectangleRounded(rec, roundness, segments, Fade(MAROON, 0.2));
|
if (drawRoundedRect) DrawRectangleRounded(rec, roundness, segments, Fade(MAROON, 0.2f));
|
||||||
if (drawRoundedLines) DrawRectangleRoundedLines(rec,roundness, segments, lineThick, Fade(MAROON, 0.4));
|
if (drawRoundedLines) DrawRectangleRoundedLines(rec,roundness, segments, (float)lineThick, Fade(MAROON, 0.4f));
|
||||||
|
|
||||||
// Draw GUI controls
|
// Draw GUI controls
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
width = GuiSliderBar((Rectangle){ 640, 40, 105, 20 }, "Width", NULL, width, 0, GetScreenWidth() - 300);
|
width = (int)GuiSliderBar((Rectangle){ 640, 40, 105, 20 }, "Width", NULL, (float)width, 0, (float)GetScreenWidth() - 300);
|
||||||
height = GuiSliderBar((Rectangle){ 640, 70, 105, 20 }, "Height", NULL, height, 0, GetScreenHeight() - 50);
|
height = (int)GuiSliderBar((Rectangle){ 640, 70, 105, 20 }, "Height", NULL, (float)height, 0, (float)GetScreenHeight() - 50);
|
||||||
roundness = GuiSliderBar((Rectangle){ 640, 140, 105, 20 }, "Roundness", NULL, roundness, 0.0f, 1.0f);
|
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);
|
lineThick = (int)GuiSliderBar((Rectangle){ 640, 170, 105, 20 }, "Thickness", NULL, (float)lineThick, 0, 20);
|
||||||
segments = GuiSliderBar((Rectangle){ 640, 240, 105, 20}, "Segments", NULL, segments, 0, 60);
|
segments = (int)GuiSliderBar((Rectangle){ 640, 240, 105, 20}, "Segments", NULL, (float)segments, 0, 60);
|
||||||
|
|
||||||
drawRoundedRect = GuiCheckBox((Rectangle){ 640, 320, 20, 20 }, "DrawRoundedRect", drawRoundedRect);
|
drawRoundedRect = GuiCheckBox((Rectangle){ 640, 320, 20, 20 }, "DrawRoundedRect", drawRoundedRect);
|
||||||
drawRoundedLines = GuiCheckBox((Rectangle){ 640, 350, 20, 20 }, "DrawRoundedLines", drawRoundedLines);
|
drawRoundedLines = GuiCheckBox((Rectangle){ 640, 350, 20, 20 }, "DrawRoundedLines", drawRoundedLines);
|
||||||
|
@ -25,7 +25,7 @@ int main(void)
|
|||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - draw ring");
|
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - draw ring");
|
||||||
|
|
||||||
Vector2 center = {(GetScreenWidth() - 300)/2, GetScreenHeight()/2 };
|
Vector2 center = {(GetScreenWidth() - 300)/2.0f, GetScreenHeight()/2.0f };
|
||||||
|
|
||||||
float innerRadius = 80.0f;
|
float innerRadius = 80.0f;
|
||||||
float outerRadius = 190.0f;
|
float outerRadius = 190.0f;
|
||||||
@ -59,9 +59,9 @@ int main(void)
|
|||||||
DrawLine(500, 0, 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.6f));
|
DrawLine(500, 0, 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.6f));
|
||||||
DrawRectangle(500, 0, GetScreenWidth() - 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.3f));
|
DrawRectangle(500, 0, GetScreenWidth() - 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.3f));
|
||||||
|
|
||||||
if (drawRing) DrawRing(center, innerRadius, outerRadius, startAngle, endAngle, segments, Fade(MAROON, 0.3));
|
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.4));
|
if (drawRingLines) DrawRingLines(center, innerRadius, outerRadius, startAngle, endAngle, segments, Fade(BLACK, 0.4f));
|
||||||
if (drawCircleLines) DrawCircleSectorLines(center, outerRadius, startAngle, endAngle, segments, Fade(BLACK, 0.4));
|
if (drawCircleLines) DrawCircleSectorLines(center, outerRadius, startAngle, endAngle, segments, Fade(BLACK, 0.4f));
|
||||||
|
|
||||||
// Draw GUI controls
|
// Draw GUI controls
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
@ -71,7 +71,7 @@ int main(void)
|
|||||||
innerRadius = GuiSliderBar((Rectangle){ 600, 140, 120, 20 }, "InnerRadius", NULL, innerRadius, 0, 100);
|
innerRadius = GuiSliderBar((Rectangle){ 600, 140, 120, 20 }, "InnerRadius", NULL, innerRadius, 0, 100);
|
||||||
outerRadius = GuiSliderBar((Rectangle){ 600, 170, 120, 20 }, "OuterRadius", NULL, outerRadius, 0, 200);
|
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 = (int)GuiSliderBar((Rectangle){ 600, 240, 120, 20 }, "Segments", NULL, (float)segments, 0, 100);
|
||||||
|
|
||||||
drawRing = GuiCheckBox((Rectangle){ 600, 320, 20, 20 }, "Draw Ring", drawRing);
|
drawRing = GuiCheckBox((Rectangle){ 600, 320, 20, 20 }, "Draw Ring", drawRing);
|
||||||
drawRingLines = GuiCheckBox((Rectangle){ 600, 350, 20, 20 }, "Draw RingLines", drawRingLines);
|
drawRingLines = GuiCheckBox((Rectangle){ 600, 350, 20, 20 }, "Draw RingLines", drawRingLines);
|
||||||
|
@ -41,7 +41,7 @@ int main(void)
|
|||||||
if (state == 0) // Move ball position X with easing
|
if (state == 0) // Move ball position X with easing
|
||||||
{
|
{
|
||||||
framesCounter++;
|
framesCounter++;
|
||||||
ballPositionX = EaseElasticOut(framesCounter, -100, screenWidth/2 + 100, 120);
|
ballPositionX = (int)EaseElasticOut((float)framesCounter, -100, screenWidth/2.0f + 100, 120);
|
||||||
|
|
||||||
if (framesCounter >= 120)
|
if (framesCounter >= 120)
|
||||||
{
|
{
|
||||||
@ -52,7 +52,7 @@ int main(void)
|
|||||||
else if (state == 1) // Increase ball radius with easing
|
else if (state == 1) // Increase ball radius with easing
|
||||||
{
|
{
|
||||||
framesCounter++;
|
framesCounter++;
|
||||||
ballRadius = EaseElasticIn(framesCounter, 20, 500, 200);
|
ballRadius = (int)EaseElasticIn((float)framesCounter, 20, 500, 200);
|
||||||
|
|
||||||
if (framesCounter >= 200)
|
if (framesCounter >= 200)
|
||||||
{
|
{
|
||||||
@ -63,7 +63,7 @@ int main(void)
|
|||||||
else if (state == 2) // Change ball alpha with easing (background color blending)
|
else if (state == 2) // Change ball alpha with easing (background color blending)
|
||||||
{
|
{
|
||||||
framesCounter++;
|
framesCounter++;
|
||||||
ballAlpha = EaseCubicOut(framesCounter, 0.0f, 1.0f, 200);
|
ballAlpha = EaseCubicOut((float)framesCounter, 0.0f, 1.0f, 200);
|
||||||
|
|
||||||
if (framesCounter >= 200)
|
if (framesCounter >= 200)
|
||||||
{
|
{
|
||||||
@ -93,7 +93,7 @@ int main(void)
|
|||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
if (state >= 2) DrawRectangle(0, 0, screenWidth, screenHeight, GREEN);
|
if (state >= 2) DrawRectangle(0, 0, screenWidth, screenHeight, GREEN);
|
||||||
DrawCircle(ballPositionX, 200, ballRadius, Fade(RED, 1.0f - ballAlpha));
|
DrawCircle(ballPositionX, 200, (float)ballRadius, Fade(RED, 1.0f - ballAlpha));
|
||||||
|
|
||||||
if (state == 3) DrawText("PRESS [ENTER] TO PLAY AGAIN!", 240, 200, 20, BLACK);
|
if (state == 3) DrawText("PRESS [ENTER] TO PLAY AGAIN!", 240, 200, 20, BLACK);
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ int main(void)
|
|||||||
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - easings box anim");
|
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - easings box anim");
|
||||||
|
|
||||||
// Box variables to be animated with easings
|
// Box variables to be animated with easings
|
||||||
Rectangle rec = { GetScreenWidth()/2, -100, 100, 100 };
|
Rectangle rec = { GetScreenWidth()/2.0f, -100, 100, 100 };
|
||||||
float rotation = 0.0f;
|
float rotation = 0.0f;
|
||||||
float alpha = 1.0f;
|
float alpha = 1.0f;
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ int main(void)
|
|||||||
|
|
||||||
// NOTE: Remember that 3rd parameter of easing function refers to
|
// NOTE: Remember that 3rd parameter of easing function refers to
|
||||||
// desired value variation, do not confuse it with expected final value!
|
// desired value variation, do not confuse it with expected final value!
|
||||||
rec.y = EaseElasticOut(framesCounter, -100, GetScreenHeight()/2 + 100, 120);
|
rec.y = EaseElasticOut((float)framesCounter, -100, GetScreenHeight()/2.0f + 100, 120);
|
||||||
|
|
||||||
if (framesCounter >= 120)
|
if (framesCounter >= 120)
|
||||||
{
|
{
|
||||||
@ -57,8 +57,8 @@ int main(void)
|
|||||||
case 1: // Scale box to an horizontal bar
|
case 1: // Scale box to an horizontal bar
|
||||||
{
|
{
|
||||||
framesCounter++;
|
framesCounter++;
|
||||||
rec.height = EaseBounceOut(framesCounter, 100, -90, 120);
|
rec.height = EaseBounceOut((float)framesCounter, 100, -90, 120);
|
||||||
rec.width = EaseBounceOut(framesCounter, 100, GetScreenWidth(), 120);
|
rec.width = EaseBounceOut((float)framesCounter, 100, (float)GetScreenWidth(), 120);
|
||||||
|
|
||||||
if (framesCounter >= 120)
|
if (framesCounter >= 120)
|
||||||
{
|
{
|
||||||
@ -69,7 +69,7 @@ int main(void)
|
|||||||
case 2: // Rotate horizontal bar rectangle
|
case 2: // Rotate horizontal bar rectangle
|
||||||
{
|
{
|
||||||
framesCounter++;
|
framesCounter++;
|
||||||
rotation = EaseQuadOut(framesCounter, 0.0f, 270.0f, 240);
|
rotation = EaseQuadOut((float)framesCounter, 0.0f, 270.0f, 240);
|
||||||
|
|
||||||
if (framesCounter >= 240)
|
if (framesCounter >= 240)
|
||||||
{
|
{
|
||||||
@ -80,7 +80,7 @@ int main(void)
|
|||||||
case 3: // Increase bar size to fill all screen
|
case 3: // Increase bar size to fill all screen
|
||||||
{
|
{
|
||||||
framesCounter++;
|
framesCounter++;
|
||||||
rec.height = EaseCircOut(framesCounter, 10, GetScreenWidth(), 120);
|
rec.height = EaseCircOut((float)framesCounter, 10, (float)GetScreenWidth(), 120);
|
||||||
|
|
||||||
if (framesCounter >= 120)
|
if (framesCounter >= 120)
|
||||||
{
|
{
|
||||||
@ -91,7 +91,7 @@ int main(void)
|
|||||||
case 4: // Fade out animation
|
case 4: // Fade out animation
|
||||||
{
|
{
|
||||||
framesCounter++;
|
framesCounter++;
|
||||||
alpha = EaseSineOut(framesCounter, 1.0f, -1.0f, 160);
|
alpha = EaseSineOut((float)framesCounter, 1.0f, -1.0f, 160);
|
||||||
|
|
||||||
if (framesCounter >= 160)
|
if (framesCounter >= 160)
|
||||||
{
|
{
|
||||||
@ -105,7 +105,7 @@ int main(void)
|
|||||||
// Reset animation at any moment
|
// Reset animation at any moment
|
||||||
if (IsKeyPressed(KEY_SPACE))
|
if (IsKeyPressed(KEY_SPACE))
|
||||||
{
|
{
|
||||||
rec = (Rectangle){ GetScreenWidth()/2, -100, 100, 100 };
|
rec = (Rectangle){ GetScreenWidth()/2.0f, -100, 100, 100 };
|
||||||
rotation = 0.0f;
|
rotation = 0.0f;
|
||||||
alpha = 1.0f;
|
alpha = 1.0f;
|
||||||
state = 0;
|
state = 0;
|
||||||
|
@ -39,8 +39,8 @@ int main(void)
|
|||||||
{
|
{
|
||||||
for (int x = 0; x < MAX_RECS_X; x++)
|
for (int x = 0; x < MAX_RECS_X; x++)
|
||||||
{
|
{
|
||||||
recs[y*MAX_RECS_X + x].x = RECS_WIDTH/2 + RECS_WIDTH*x;
|
recs[y*MAX_RECS_X + x].x = RECS_WIDTH/2.0f + RECS_WIDTH*x;
|
||||||
recs[y*MAX_RECS_X + x].y = RECS_HEIGHT/2 + RECS_HEIGHT*y;
|
recs[y*MAX_RECS_X + x].y = RECS_HEIGHT/2.0f + RECS_HEIGHT*y;
|
||||||
recs[y*MAX_RECS_X + x].width = RECS_WIDTH;
|
recs[y*MAX_RECS_X + x].width = RECS_WIDTH;
|
||||||
recs[y*MAX_RECS_X + x].height = RECS_HEIGHT;
|
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++)
|
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].height = EaseCircOut((float)framesCounter, RECS_HEIGHT, -RECS_HEIGHT, PLAY_TIME_IN_FRAMES);
|
||||||
recs[i].width = EaseCircOut(framesCounter, RECS_WIDTH, -RECS_WIDTH, PLAY_TIME_IN_FRAMES);
|
recs[i].width = EaseCircOut((float)framesCounter, RECS_WIDTH, -RECS_WIDTH, PLAY_TIME_IN_FRAMES);
|
||||||
|
|
||||||
if (recs[i].height < 0) recs[i].height = 0;
|
if (recs[i].height < 0) recs[i].height = 0;
|
||||||
if (recs[i].width < 0) recs[i].width = 0;
|
if (recs[i].width < 0) recs[i].width = 0;
|
||||||
|
|
||||||
if ((recs[i].height == 0) && (recs[i].width == 0)) state = 1; // Finish playing
|
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((float)framesCounter, 0.0f, 360.0f, PLAY_TIME_IN_FRAMES);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((state == 1) && IsKeyPressed(KEY_SPACE))
|
else if ((state == 1) && IsKeyPressed(KEY_SPACE))
|
||||||
|
@ -25,7 +25,7 @@ int main(void)
|
|||||||
char name[MAX_INPUT_CHARS + 1] = "\0"; // NOTE: One extra space required for null terminator char '\0'
|
char name[MAX_INPUT_CHARS + 1] = "\0"; // NOTE: One extra space required for null terminator char '\0'
|
||||||
int letterCount = 0;
|
int letterCount = 0;
|
||||||
|
|
||||||
Rectangle textBox = { screenWidth/2 - 100, 180, 225, 50 };
|
Rectangle textBox = { screenWidth/2.0f - 100, 180, 225, 50 };
|
||||||
bool mouseOnText = false;
|
bool mouseOnText = false;
|
||||||
|
|
||||||
int framesCounter = 0;
|
int framesCounter = 0;
|
||||||
@ -85,10 +85,10 @@ int main(void)
|
|||||||
DrawText("PLACE MOUSE OVER INPUT BOX!", 240, 140, 20, GRAY);
|
DrawText("PLACE MOUSE OVER INPUT BOX!", 240, 140, 20, GRAY);
|
||||||
|
|
||||||
DrawRectangleRec(textBox, LIGHTGRAY);
|
DrawRectangleRec(textBox, LIGHTGRAY);
|
||||||
if (mouseOnText) DrawRectangleLines(textBox.x, textBox.y, textBox.width, textBox.height, RED);
|
if (mouseOnText) DrawRectangleLines((int)textBox.x, (int)textBox.y, (int)textBox.width, (int)textBox.height, RED);
|
||||||
else DrawRectangleLines(textBox.x, textBox.y, textBox.width, textBox.height, DARKGRAY);
|
else DrawRectangleLines((int)textBox.x, (int)textBox.y, (int)textBox.width, (int)textBox.height, DARKGRAY);
|
||||||
|
|
||||||
DrawText(name, textBox.x + 5, textBox.y + 8, 40, MAROON);
|
DrawText(name, (int)textBox.x + 5, (int)textBox.y + 8, 40, MAROON);
|
||||||
|
|
||||||
DrawText(TextFormat("INPUT CHARS: %i/%i", letterCount, MAX_INPUT_CHARS), 315, 250, 20, DARKGRAY);
|
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)
|
if (letterCount < MAX_INPUT_CHARS)
|
||||||
{
|
{
|
||||||
// Draw blinking underscore char
|
// 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("_", (int)textBox.x + 8 + MeasureText(name, 40), (int)textBox.y + 12, 40, MAROON);
|
||||||
}
|
}
|
||||||
else DrawText("Press BACKSPACE to delete chars...", 230, 300, 20, GRAY);
|
else DrawText("Press BACKSPACE to delete chars...", 230, 300, 20, GRAY);
|
||||||
}
|
}
|
||||||
|
@ -32,8 +32,8 @@ int main(void)
|
|||||||
Texture2D explosion = LoadTexture("resources/explosion.png");
|
Texture2D explosion = LoadTexture("resources/explosion.png");
|
||||||
|
|
||||||
// Init variables for animation
|
// Init variables for animation
|
||||||
float frameWidth = explosion.width/NUM_FRAMES_PER_LINE; // Sprite one frame rectangle width
|
float frameWidth = (float)(explosion.width/NUM_FRAMES_PER_LINE); // Sprite one frame rectangle width
|
||||||
float frameHeight = explosion.height/NUM_LINES; // Sprite one frame rectangle height
|
float frameHeight = (float)(explosion.height/NUM_LINES); // Sprite one frame rectangle height
|
||||||
int currentFrame = 0;
|
int currentFrame = 0;
|
||||||
int currentLine = 0;
|
int currentLine = 0;
|
||||||
|
|
||||||
|
@ -2322,7 +2322,7 @@ bool GuiTextBoxMulti(Rectangle bounds, char *text, int textSize, bool editMode)
|
|||||||
{
|
{
|
||||||
int glyphWidth = 0;
|
int glyphWidth = 0;
|
||||||
if (glyphInfo.advanceX != 0) glyphWidth += glyphInfo.advanceX;
|
if (glyphInfo.advanceX != 0) glyphWidth += glyphInfo.advanceX;
|
||||||
else glyphWidth += (atlasRec.width + glyphInfo.offsetX);
|
else glyphWidth += (int)(atlasRec.width + glyphInfo.offsetX);
|
||||||
|
|
||||||
// Jump line if the end of the text box area has been reached
|
// Jump line if the end of the text box area has been reached
|
||||||
if ((cursorPos.x + (glyphWidth*scaleFactor)) > (textAreaBounds.x + textAreaBounds.width))
|
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;
|
int glyphWidth = 0;
|
||||||
if (glyphInfo.advanceX != 0) glyphWidth += glyphInfo.advanceX;
|
if (glyphInfo.advanceX != 0) glyphWidth += glyphInfo.advanceX;
|
||||||
else glyphWidth += (atlasRec.width + glyphInfo.offsetX);
|
else glyphWidth += (int)(atlasRec.width + glyphInfo.offsetX);
|
||||||
|
|
||||||
cursorPos.x += (glyphWidth*scaleFactor + (float)GuiGetStyle(DEFAULT, TEXT_SPACING));
|
cursorPos.x += (glyphWidth*scaleFactor + (float)GuiGetStyle(DEFAULT, TEXT_SPACING));
|
||||||
//if (i > lastSpacePos) lastSpaceWidth += (atlasRec.width + (float)GuiGetStyle(DEFAULT, TEXT_SPACING));
|
//if (i > lastSpacePos) lastSpaceWidth += (atlasRec.width + (float)GuiGetStyle(DEFAULT, TEXT_SPACING));
|
||||||
|
Loading…
Reference in New Issue
Block a user