Skip to content

Commit 3c45d13

Browse files
DevLyasslouken
authored andcommitted
examples: Fix float division
(cherry picked from commit b5ac641)
1 parent afbbfc6 commit 3c45d13

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

examples/demo/02-woodeneye-008/woodeneye-008.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ static void draw(SDL_Renderer *renderer, const float (*edges)[6], const Player p
206206
for (i = 0; i < players_len; i++) {
207207
const Player *player = &players[i];
208208
float mod_x = (float)(i % part_hor);
209-
float mod_y = (float)(i / part_hor);
209+
float mod_y = (float)i / part_hor;
210210
float hor_origin = (mod_x + 0.5f) * size_hor;
211211
float ver_origin = (mod_y + 0.5f) * size_ver;
212212
float cam_origin = (float)(0.5 * SDL_sqrt(size_hor * size_hor + size_ver * size_ver));

examples/renderer/05-rectangles/rectangles.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ SDL_AppResult SDL_AppIterate(void *appstate)
9090

9191
/* ...and also fill a bunch of rectangles at once... */
9292
for (i = 0; i < SDL_arraysize(rects); i++) {
93-
const float w = (float) (WINDOW_WIDTH / SDL_arraysize(rects));
93+
const float w = ((float) WINDOW_WIDTH / SDL_arraysize(rects));
9494
const float h = i * 8.0f;
9595
rects[i].x = i * w;
9696
rects[i].y = WINDOW_HEIGHT - h;

examples/renderer/18-debug-text/debug-text.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ SDL_AppResult SDL_AppIterate(void *appstate)
6666
SDL_SetRenderScale(renderer, 1.0f, 1.0f);
6767
SDL_RenderDebugText(renderer, 64, 350, "This only does ASCII chars. So this laughing emoji won't draw: 🤣");
6868

69-
SDL_RenderDebugTextFormat(renderer, (float) ((WINDOW_WIDTH - (charsize * 46)) / 2), 400, "(This program has been running for %" SDL_PRIu64 " seconds.)", SDL_GetTicks() / 1000);
69+
SDL_RenderDebugTextFormat(renderer, ((float) (WINDOW_WIDTH - (charsize * 46)) / 2), 400, "(This program has been running for %" SDL_PRIu64 " seconds.)", SDL_GetTicks() / 1000);
7070

7171
SDL_RenderPresent(renderer); /* put it all on the screen! */
7272

0 commit comments

Comments
 (0)