Skip to content

Commit

Permalink
More type stuff in pong clock sample
Browse files Browse the repository at this point in the history
  • Loading branch information
lpereira committed Jun 20, 2024
1 parent 9982a3f commit a2bc3c6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/samples/clock/pong.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,10 @@ uint64_t pong_draw(struct pong *pong)
if (pong->ball_y.pos >= 30.0 || pong->ball_y.pos <= 0.0)
pong->ball_y.vel = -pong->ball_y.vel;

if (roundf(pong->ball_x.pos) == 40.0 + rand_double(13)) {
if (round(pong->ball_x.pos) == 40.0 + rand_double(13)) {
pong->player_left.target_y = pong->ball_y.pos - 3.0;
clamp(&pong->player_left.target_y, 0.0, 24.0);
} else if (roundf(pong->ball_x.pos) == 8 + rand_double(13)) {
} else if (round(pong->ball_x.pos) == 8 + rand_double(13)) {
pong->player_right.target_y = pong->ball_y.pos - 3.0;
clamp(&pong->player_right.target_y, 0.0, 24.0);
}
Expand All @@ -236,7 +236,7 @@ uint64_t pong_draw(struct pong *pong)

/* If the ball is in the middle, check if we need to lose and calculate
* the endpoint to avoid/hit the ball */
if (roundf(pong->ball_x.pos) == 32.0) {
if (round(pong->ball_x.pos) == 32.0) {
struct pong_time cur_time = {};

pong_time_update(&cur_time);
Expand Down Expand Up @@ -280,8 +280,8 @@ uint64_t pong_draw(struct pong *pong)
memset(pong->gif->frame, 0, 64 * 32);
pong_draw_net(pong);
pong_draw_time(pong);
pong_draw_player(pong, 0, pong->player_left.y);
pong_draw_player(pong, 62, pong->player_right.y);
pong_draw_player(pong, 0, (int)pong->player_left.y);
pong_draw_player(pong, 62, (int)pong->player_right.y);
pong_draw_ball(pong);

return 8;
Expand Down

0 comments on commit a2bc3c6

Please sign in to comment.