Implementation: This project implements the A* algorithm in Python to create an engaging game where enemies track the player's position intelligently.
A* (A-star) is a pathfinding algorithm that efficiently finds the shortest path between two points. Here's a brief overview:
-
Initialization:
- A* starts with a start node and a target node.
- It creates an open set containing the start node.
-
Main Loop:
- A* evaluates nodes based on the cost to reach them and an estimate of the cost to reach the target (heuristic).
- It selects the node with the lowest total cost from the open set.
- The selected node is removed from the open set and added to the closed set.
- A* expands nodes adjacent to the selected node and adds them to the open set if they haven't been visited before.
- The process continues until the target node is reached or there are no more nodes to explore.
-
Path Reconstruction:
- Once the target node is reached, A* reconstructs the path from the start node to the target node.
Step 1: Initialization | Step 2: Main Loop |
---|---|
missile.png
: Image representing enemy missiles.jet.png
: Image representing the player's jet.cloud.png
: Image representing background/clouds.
- The player controls the jet using arrow keys.
- Enemy missiles spawn from the right side and pursue the player using A* pathfinding.
- The player must dodge the missiles for as long as possible to survive.
- Make sure you have Python and Pygame installed.
- Clone this repository.
- Run
python main.py
to start the game.
Enjoy the game and happy dodging! 🚀🎮