where i was wrong?
#include <stdio.h> #include <stdlib.h> #include <conio.h> #define SCREEN_WIDTH 80 #define SCREEN_HEIGHT 25 struct player { int x; int y; }; struct obstacle { int x; int y; }; int main() { int score = 0; struct player p = {SCREEN_WIDTH / 2, SCREEN_HEIGHT - 1}; struct obstacle o = {rand() % SCREEN_WIDTH, 0}; while (1) { // Update player position based on user input if (kbhit()) { char key = getch(); if (key == 'a') { p.x--; } else if (key == 'd') { p.x++; } } // Update obstacle position o.y++; // Check for collision between player and obstacle if (o.y == p.y && o.x == p.x) { printf("Game over! Final score: %d\n", score); break; } // Spawn new obstacle if necessary if (o.y == SCREEN_HEIGHT) { o.y = 0; o.x = rand() % SCREEN_WIDTH; score++; } // Clear screen and draw player and obstacle system("cls"); printf("Score: %d\n", score); for (int i = 0; i < SCREEN_WIDTH; i++) { if (i == p.x) { printf("P"); } else if (i == o.x && o.y < SCREEN_HEIGHT) { printf("O"); } else { printf(" "); } } } return 0; }