proper placement of the obstacles

This commit is contained in:
Priec
2025-11-18 00:19:17 +01:00
parent cf30946c0d
commit 967b377e76
5 changed files with 40 additions and 29 deletions

View File

@@ -115,12 +115,23 @@ void render_loop(int speed) {
draw_character(draw_pos.x, draw_pos.y, frame.movement, frame.frame_index);
for (int i = 0; i < MAX_OBSTACLES; i++) {
if (!obstacle_pool[i].active) continue;
draw_obstacle(obstacle_pool[i].data.x, obstacle_pool[i].data.y, obstacle_pool[i].type);
if (!obstacle_pool[i].active)
continue;
draw_obstacle(obstacle_pool[i].data.x,
obstacle_pool[i].data.y,
obstacle_pool[i].type);
if (check_collision(draw_pos, frame.movement, obstacle_pool[i].data)) {
printf("\033[2J\033[H"); // clear screen & home cursor
printf("GAME OVER\r\n");
game_over = true;
break;
}
}
if (game_over)
break;
break;
ThisThread::sleep_for(50ms);
}