diff --git a/main.py b/main.py index ee81ed8..073efeb 100644 --- a/main.py +++ b/main.py @@ -1,13 +1,10 @@ - ---- - -### **Basic Code for `main.py`** -```python import pygame import random # Initialize Pygame pygame.init() +font = pygame.font.SysFont(None, 36) +score = 0 # Game Settings WIDTH, HEIGHT = 600, 400 @@ -32,6 +29,9 @@ running = True while running: screen.fill(BLACK) + score_text = font.render(f"Score: {score}", True, WHITE) + screen.blit(score_text, (10, 10)) + # Event Handling for event in pygame.event.get(): @@ -54,6 +54,7 @@ else: snake.insert(0, new_head) if new_head == food: + score += 1 food = (random.randint(0, WIDTH // GRID_SIZE - 1) * GRID_SIZE, random.randint(0, HEIGHT // GRID_SIZE - 1) * GRID_SIZE) else: