Skip to content

Interactive Pygame simulation of a ball being chased by a dog, with zone detection logic.

Notifications You must be signed in to change notification settings

khadibd/Ball-and-Dog-Pygame

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🐢 Ball & Dog Pygame Simulation

Diagram

Overview

This project is an interactive Pygame simulation where a ball moves according to user input, and a "dog" (yellow square) chases it across the screen. The simulation demonstrates:

  • Ball movement with slope and direction control
  • Wall collisions and bouncing
  • Dynamic chasing behavior of the dog
  • Real-time detection of ball position across 4 circular sensor zones

This project is perfect for learning Pygame basics, vector math, and simple AI movement in games.


Features

  • 🎯 Interactive Drag & Release: Click, drag, and release the ball to set its trajectory.
  • πŸ• Chasing AI: The dog continuously moves toward the ball using normalized vectors.
  • πŸ“‘ Zone Detection: The screen is divided into 4 zones, and the program prints which zone(s) the ball is in.
  • ⚑ Real-time Simulation: Smooth animation with bouncing and collision detection.
  • πŸ–Ό Visualization: Includes a diagram showing zones and ball movement.

How to Run

  1. Install dependencies:
pip install pygame

πŸ‘©β€πŸ’» Author

Eng. Khadija Bouadi

πŸ“§ Contact

For any queries, reach out to:

GitHub: @khadibd

Email: khadibd00@gmail.com

About

Interactive Pygame simulation of a ball being chased by a dog, with zone detection logic.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages