summaryrefslogtreecommitdiff
path: root/sdl3_main.c
diff options
context:
space:
mode:
authoresquizo <esquizo+noreply@esquizo.net>2026-04-22 14:23:46 -0300
committeresquizo <esquizo+noreply@esquizo.net>2026-04-22 14:24:26 -0300
commitd2b4066cab63fb51ad17c90baadcfa6fa1f82d07 (patch)
treed21433b28f123c65ec59cb527b360789539e3a7d /sdl3_main.c
parent83d040a27fee8b0cd9933c08e9a6bcaecb17a2db (diff)
constantes de tamanho de entidade
Diffstat (limited to 'sdl3_main.c')
-rw-r--r--sdl3_main.c37
1 files changed, 21 insertions, 16 deletions
diff --git a/sdl3_main.c b/sdl3_main.c
index 83be4ab..7ecca2b 100644
--- a/sdl3_main.c
+++ b/sdl3_main.c
@@ -5,6 +5,9 @@
#include <SDL3/SDL.h>
+#define BULLET_SIZE 2
+#define ENTITY_SIZE 16
+
static void render(void);
static void update(float delta);
static void process_events(void);
@@ -111,10 +114,10 @@ render(void)
SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF);
SDL_RenderRect(renderer, &(SDL_FRect){
- .x = player.x - 15 - camera_x,
- .y = player.y - 15 - camera_y,
- .w = 30,
- .h = 30
+ .x = player.x - ENTITY_SIZE - camera_x,
+ .y = player.y - ENTITY_SIZE - camera_y,
+ .w = ENTITY_SIZE * 2.0,
+ .h = ENTITY_SIZE * 2.0
});
for(int i = 0; i < 1024; i++) {
@@ -123,10 +126,10 @@ render(void)
SDL_SetRenderDrawColor(renderer, 0xAA, 0xAA, 0xAA, 0xFF);
SDL_RenderRect(renderer, &(SDL_FRect){
- .x = ghosts[i].x - 15 - camera_x,
- .y = ghosts[i].y - 15 - camera_y,
- .w = 30,
- .h = 30
+ .x = ghosts[i].x - ENTITY_SIZE - camera_x,
+ .y = ghosts[i].y - ENTITY_SIZE - camera_y,
+ .w = ENTITY_SIZE * 2.0,
+ .h = ENTITY_SIZE * 2.0
});
}
@@ -136,10 +139,10 @@ render(void)
SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0x00, 0xFF);
SDL_RenderRect(renderer, &(SDL_FRect){
- .x = bullet[i].x - 2 - camera_x,
- .y = bullet[i].y - 2 - camera_y,
- .w = 4,
- .h = 4
+ .x = bullet[i].x - BULLET_SIZE - camera_x,
+ .y = bullet[i].y - BULLET_SIZE - camera_y,
+ .w = BULLET_SIZE * 2.0,
+ .h = BULLET_SIZE * 2.0
});
}
}
@@ -194,10 +197,12 @@ update(float delta)
float dx = bullet[i].x - ghosts[j].x;
float dy = bullet[i].y - ghosts[j].y;
- float minx = dx - 17;
- float miny = dy - 17;
- float maxx = dx + 17;
- float maxy = dy + 17;
+ float hs = (ENTITY_SIZE + BULLET_SIZE);
+
+ float minx = dx - hs;
+ float miny = dy - hs;
+ float maxx = dx + hs;
+ float maxy = dy + hs;
bool contains_x = minx < 0 && maxx > 0;
bool contains_y = miny < 0 && maxy > 0;