Skip to content

Commit 7ec0e3e

Browse files
committed
Update casting
1 parent 3677be2 commit 7ec0e3e

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

examples/core/core_window_letterbox.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ int main(void)
4343

4444
raylib::Color colors[10] = { 0 };
4545
for (int i = 0; i < 10; i++) {
46-
colors[i] = raylib::Color((unsigned int)GetRandomValue(100, 250), (unsigned int)GetRandomValue(50, 150), (unsigned int)GetRandomValue(10, 100), 255);
46+
colors[i] = raylib::Color((unsigned char)GetRandomValue(100, 250), (unsigned char)GetRandomValue(50, 150), (unsigned char)GetRandomValue(10, 100), 255);
4747
}
4848

4949
window.SetTargetFPS(60); // Set our game to run at 60 frames-per-second
@@ -60,7 +60,7 @@ int main(void)
6060
if (IsKeyPressed(KEY_SPACE))
6161
{
6262
// Recalculate random colors for the bars
63-
for (int i = 0; i < 10; i++) colors[i] = (Color){ (unsigned int)GetRandomValue(100, 250), (unsigned int)GetRandomValue(50, 150), (unsigned int)GetRandomValue(10, 100), 255 };
63+
for (int i = 0; i < 10; i++) colors[i] = (Color){ (unsigned char)GetRandomValue(100, 250), (unsigned char)GetRandomValue(50, 150), (unsigned char)GetRandomValue(10, 100), 255 };
6464
}
6565

6666
// Update virtual mouse (clamped mouse value behind game screen)
@@ -69,7 +69,7 @@ int main(void)
6969
(mouse.x - (GetScreenWidth() - (gameScreenWidth*scale))*0.5f)/scale,
7070
(mouse.y - (GetScreenHeight() - (gameScreenHeight*scale))*0.5f)/scale
7171
);
72-
virtualMouse = virtualMouse.Clamp((Vector2){ 0, 0 }, (Vector2){ (float)gameScreenWidth, (float)gameScreenHeight });
72+
virtualMouse = virtualMouse.Clamp(raylib::Vector2::Zero(), raylib::Vector2(gameScreenWidth, gameScreenHeight));
7373

7474
// Apply the same transformation as the virtual mouse to the real mouse (i.e. to work with raygui)
7575
//SetMouseOffset(-(GetScreenWidth() - (gameScreenWidth*scale))*0.5f, -(GetScreenHeight() - (gameScreenHeight*scale))*0.5f);
@@ -93,9 +93,13 @@ int main(void)
9393
ClearBackground(BLACK); // Clear screen background
9494

9595
// Draw render texture to screen, properly scaled
96-
target.GetTexture().Draw((Rectangle){ 0.0f, 0.0f, (float)target.texture.width, (float)-target.texture.height },
97-
(Rectangle){ (GetScreenWidth() - ((float)gameScreenWidth*scale))*0.5f, (GetScreenHeight() - ((float)gameScreenHeight*scale))*0.5f,
98-
(float)gameScreenWidth*scale, (float)gameScreenHeight*scale }, (Vector2){ 0, 0 }, 0.0f, WHITE);
96+
target.GetTexture().Draw(raylib::Rectangle(0.0f, 0.0f, target.texture.width, -target.texture.height),
97+
raylib::Rectangle(
98+
(GetScreenWidth() - (gameScreenWidth*scale))*0.5f,
99+
(GetScreenHeight() - (gameScreenHeight*scale))*0.5f,
100+
gameScreenWidth*scale, gameScreenHeight*scale
101+
),
102+
raylib::Vector2::Zero(), 0.0f, WHITE);
99103
EndDrawing();
100104
//--------------------------------------------------------------------------------------
101105
}

0 commit comments

Comments
 (0)