proper placement of the obstacles
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user