summaryrefslogtreecommitdiff
path: root/sdl3_main.c
diff options
context:
space:
mode:
authoresquizo <esquizo+noreply@esquizo.net>2026-04-23 19:32:30 -0300
committeresquizo <esquizo+noreply@esquizo.net>2026-04-23 19:32:30 -0300
commit8e53990f306a5f746a82793b98c9410e3cde8810 (patch)
treeb4165d80fca0f046add812e3edd26d6f8f18a80f /sdl3_main.c
parent216d4a05d3b878741f46cc748794a92faa78aa63 (diff)
adicionado mapa
Diffstat (limited to 'sdl3_main.c')
-rw-r--r--sdl3_main.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/sdl3_main.c b/sdl3_main.c
index 26b447d..1bb4a89 100644
--- a/sdl3_main.c
+++ b/sdl3_main.c
@@ -45,6 +45,9 @@ static float camera_x, camera_y;
static bool shot;
static int shotx, shoty;
+extern char map_data[];
+extern int map_width, map_height;
+
int
main()
{
@@ -114,6 +117,20 @@ render(void)
SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF);
SDL_RenderClear(renderer);
+ SDL_SetRenderDrawColor(renderer, 0xAA, 0xAA, 0xAA, 0xFF);
+ for(int y = 0; y < map_height; y++)
+ for(int x = 0; x < map_width; x++) {
+ if(!map_data[x + map_width * y])
+ continue;
+
+ SDL_RenderFillRect(renderer, &(SDL_FRect) {
+ .x = 2 * ENTITY_SIZE * x - ENTITY_SIZE - camera_x,
+ .y = 2 * ENTITY_SIZE * y - ENTITY_SIZE - camera_y,
+ .w = 2.0 * ENTITY_SIZE,
+ .h = 2.0 * ENTITY_SIZE,
+ });
+ }
+
SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF);
SDL_RenderRect(renderer, &(SDL_FRect){
.x = player.x - ENTITY_SIZE - camera_x,
@@ -188,6 +205,7 @@ update(float delta)
}
}
+
for(int i = 0; i < 1024; i++) {
if(!bullet[i].active)
continue;
@@ -305,3 +323,4 @@ checkcollision(float p1[2], float s1[2], float p2[2], float s2[2])
return minx < 0 && maxx > 0 && miny < 0 && maxy > 0;
}
+