diff options
| author | Jeffery Myers <[email protected]> | 2021-02-20 14:37:32 -0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-02-20 23:37:32 +0100 |
| commit | 48a7cd3c8788799505b4fa9f84cb8f5979397c29 (patch) | |
| tree | f9cbed3827f8855d0e3c27916930b9d82de3e423 /examples/core | |
| parent | 82cdd88ffe6cb9d2f97e34bd0724d791030372bf (diff) | |
| download | raylib-48a7cd3c8788799505b4fa9f84cb8f5979397c29.tar.gz raylib-48a7cd3c8788799505b4fa9f84cb8f5979397c29.zip | |
[Examples] Fix typecast warnings in examples. (#1601)
* Fixing typecast warnings generated by visual studio 2019 in examples.
* Changes to fixes based on feedback
Co-authored-by: Jeffery Myers <[email protected]>
Diffstat (limited to 'examples/core')
| -rw-r--r-- | examples/core/core_2d_camera.c | 18 | ||||
| -rw-r--r-- | examples/core/core_2d_camera_platformer.c | 10 | ||||
| -rw-r--r-- | examples/core/core_3d_camera_first_person.c | 2 | ||||
| -rw-r--r-- | examples/core/core_3d_picking.c | 2 |
4 files changed, 16 insertions, 16 deletions
diff --git a/examples/core/core_2d_camera.c b/examples/core/core_2d_camera.c index d6c85079..0b4754f7 100644 --- a/examples/core/core_2d_camera.c +++ b/examples/core/core_2d_camera.c @@ -30,19 +30,19 @@ int main(void) for (int i = 0; i < MAX_BUILDINGS; i++) { - buildings[i].width = GetRandomValue(50, 200); - buildings[i].height = GetRandomValue(100, 800); - buildings[i].y = screenHeight - 130 - buildings[i].height; - buildings[i].x = -6000 + spacing; + buildings[i].width = (float)GetRandomValue(50, 200); + buildings[i].height = (float)GetRandomValue(100, 800); + buildings[i].y = screenHeight - 130.0f - buildings[i].height; + buildings[i].x = -6000.0f + spacing; - spacing += buildings[i].width; + spacing += (int)buildings[i].width; buildColors[i] = (Color){ GetRandomValue(200, 240), GetRandomValue(200, 240), GetRandomValue(200, 250), 255 }; } Camera2D camera = { 0 }; - camera.target = (Vector2){ player.x + 20, player.y + 20 }; - camera.offset = (Vector2){ screenWidth/2, screenHeight/2 }; + camera.target = (Vector2){ player.x + 20.0f, player.y + 20.0f }; + camera.offset = (Vector2){ screenWidth/2.0f, screenHeight/2.0f }; camera.rotation = 0.0f; camera.zoom = 1.0f; @@ -98,8 +98,8 @@ int main(void) DrawRectangleRec(player, RED); - DrawLine(camera.target.x, -screenHeight*10, camera.target.x, screenHeight*10, GREEN); - DrawLine(-screenWidth*10, camera.target.y, screenWidth*10, camera.target.y, GREEN); + DrawLine((int)camera.target.x, -screenHeight*10, (int)camera.target.x, screenHeight*10, GREEN); + DrawLine(-screenWidth*10, (int)camera.target.y, screenWidth*10, (int)camera.target.y, GREEN); EndMode2D(); diff --git a/examples/core/core_2d_camera_platformer.c b/examples/core/core_2d_camera_platformer.c index 645c317f..db8c9f45 100644 --- a/examples/core/core_2d_camera_platformer.c +++ b/examples/core/core_2d_camera_platformer.c @@ -65,7 +65,7 @@ int main(void) Camera2D camera = { 0 }; camera.target = player.position; - camera.offset = (Vector2){ screenWidth/2, screenHeight/2 }; + camera.offset = (Vector2){ screenWidth/2.0f, screenHeight/2.0f }; camera.rotation = 0.0f; camera.zoom = 1.0f; @@ -191,14 +191,14 @@ void UpdatePlayer(Player *player, EnvItem *envItems, int envItemsLength, float d void UpdateCameraCenter(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height) { - camera->offset = (Vector2){ width/2, height/2 }; + camera->offset = (Vector2){ width/2.0f, height/2.0f }; camera->target = player->position; } void UpdateCameraCenterInsideMap(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height) { camera->target = player->position; - camera->offset = (Vector2){ width/2, height/2 }; + camera->offset = (Vector2){ width/2.0f, height/2.0f }; float minX = 1000, minY = 1000, maxX = -1000, maxY = -1000; for (int i = 0; i < envItemsLength; i++) @@ -225,7 +225,7 @@ void UpdateCameraCenterSmoothFollow(Camera2D *camera, Player *player, EnvItem *e static float minEffectLength = 10; static float fractionSpeed = 0.8f; - camera->offset = (Vector2){ width/2, height/2 }; + camera->offset = (Vector2){ width/2.0f, height/2.0f }; Vector2 diff = Vector2Subtract(player->position, camera->target); float length = Vector2Length(diff); @@ -242,7 +242,7 @@ void UpdateCameraEvenOutOnLanding(Camera2D *camera, Player *player, EnvItem *env static int eveningOut = false; static float evenOutTarget; - camera->offset = (Vector2){ width/2, height/2 }; + camera->offset = (Vector2){ width/2.0f, height/2.0f }; camera->target.x = player->position.x; if (eveningOut) diff --git a/examples/core/core_3d_camera_first_person.c b/examples/core/core_3d_camera_first_person.c index 9225991a..3377aeaf 100644 --- a/examples/core/core_3d_camera_first_person.c +++ b/examples/core/core_3d_camera_first_person.c @@ -38,7 +38,7 @@ int main(void) for (int i = 0; i < MAX_COLUMNS; i++) { heights[i] = (float)GetRandomValue(1, 12); - positions[i] = (Vector3){ GetRandomValue(-15, 15), heights[i]/2, GetRandomValue(-15, 15) }; + positions[i] = (Vector3){ (float)GetRandomValue(-15, 15), heights[i]/2.0f, (float)GetRandomValue(-15, 15) }; colors[i] = (Color){ GetRandomValue(20, 255), GetRandomValue(10, 55), 30, 255 }; } diff --git a/examples/core/core_3d_picking.c b/examples/core/core_3d_picking.c index baf35036..01fe2b55 100644 --- a/examples/core/core_3d_picking.c +++ b/examples/core/core_3d_picking.c @@ -90,7 +90,7 @@ int main(void) DrawText("Try selecting the box with mouse!", 240, 10, 20, DARKGRAY); - if(collision) DrawText("BOX SELECTED", (screenWidth - MeasureText("BOX SELECTED", 30)) / 2, screenHeight * 0.1f, 30, GREEN); + if(collision) DrawText("BOX SELECTED", (screenWidth - MeasureText("BOX SELECTED", 30)) / 2, (int)(screenHeight * 0.1f), 30, GREEN); DrawFPS(10, 10); |
