summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcitrons <citrons@mondecitronne.com>2023-10-12 23:30:33 -0500
committercitrons <citrons@mondecitronne.com>2023-10-12 23:30:33 -0500
commitc06528099e95d07cbd9d359aa773a2c973fbdec0 (patch)
tree3fd90da8d28aea3e8595a4f152e24af02ce9a96d
parent93419ee676afecc3d8647cd27fc9504221d6353d (diff)
remove SDL_round
-rw-r--r--counter.c8
-rw-r--r--world.c6
2 files changed, 7 insertions, 7 deletions
diff --git a/counter.c b/counter.c
index 5a9913c..6f21703 100644
--- a/counter.c
+++ b/counter.c
@@ -44,9 +44,9 @@ int draw_counter(SDL_Renderer *rend,
for (int i = digits - 1; i >= 0; i--) {
int digit = n % DIGIT_BASE;
- int width = SDL_round((double) FONT_WIDTH * scale);
- int height = SDL_round((double) FONT_HEIGHT * scale);
- int offset = SDL_round((double) FONT_WIDTH * scale * (double) i);
+ int width = (double) FONT_WIDTH * scale + 0.5;
+ int height = (double) FONT_HEIGHT * scale + 0.5;
+ int offset = (double) FONT_WIDTH * scale * (double) i + 0.5;
SDL_Rect draw = {screen_pos.x + offset, screen_pos.y, width, height};
SDL_Rect digit_rect = {
0, FONT_HEIGHT * digit, FONT_WIDTH, FONT_HEIGHT,
@@ -56,5 +56,5 @@ int draw_counter(SDL_Renderer *rend,
n /= DIGIT_BASE;
}
- return SDL_round((double) FONT_WIDTH * scale * (double) digits);
+ return (double) FONT_WIDTH * scale * (double) digits + 0.5;
}
diff --git a/world.c b/world.c
index a72d1a7..962d1d3 100644
--- a/world.c
+++ b/world.c
@@ -275,8 +275,8 @@ void draw_world(world *w, SDL_Window *win, SDL_Renderer *rend) {
int draw_y = ((double) world_y - view_y) * view_scale;
SDL_Rect draw_rect = {
draw_x, draw_y,
- SDL_round((double) CHUNK_DIM * view_scale),
- SDL_round((double) CHUNK_DIM * view_scale),
+ (double) CHUNK_DIM * view_scale + 0.5,
+ (double) CHUNK_DIM * view_scale + 0.5,
};
SDL_RenderCopy(rend, tex, NULL, &draw_rect);
}
@@ -285,7 +285,7 @@ void draw_world(world *w, SDL_Window *win, SDL_Renderer *rend) {
int player_x = (w->player.pos.x - view_x) * view_scale;
int player_y = (w->player.pos.y - view_y) * view_scale;
SDL_Rect player_rect = {
- player_x, player_y, SDL_round(view_scale), SDL_round(view_scale),
+ player_x, player_y, view_scale + 0.5, view_scale + 0.5,
};
SDL_SetRenderDrawColor(rend, 0xFF, 0x00, 0xFF, 0xFF);
SDL_RenderFillRect(rend, &player_rect);