This project is a simple 3D raycaster implemented using Pygame, inspired by classic first-person shooters. It renders a basic 3D environment from a 2D map, allowing the player to move and rotate within the generated world.
- 3D Raycasting: Renders a 3D environment from a 2D map.
- Player Movement: Allows the player to move forward, backward, left, and right, as well as rotate.
- Collision Detection: Prevents the player from moving through walls.
- Minimap: Displays a small minimap in the corner of the screen.
- FPS Display: Shows the current frames per second.
- Movement Instructions: Displays movement instructions on screen.
- Normalized Diagonal Movement: Ensures consistent movement speed regardless of direction.
- Light Sources: Yellow dots on the mini-map show the sources of light.
- Python 3.x
- Pygame (
pip install pygame
)
-
Clone the repository:
git clone [https://github.com/joshgilstrap/pygame-raycaster.git](https://www.google.com/search?q=https://github.com/joshgilstrap/pygame-raycaster.git) cd pygame-raycaster
-
Run the game:
python raycaster.py
W
: Move forwardS
: Move backwardA
: Move leftD
: Move rightLeft Arrow
: Rotate leftRight Arrow
: Rotate right
raycaster.py
: Contains the main game logic and rendering code.
is_wall(x, y)
: Checks if a given coordinate is a wall in the game map.handle_player_input(elapsed_time)
: Handles player movement and rotation based on key presses.perform_raycasting()
: Performs the raycasting algorithm to render the 3D environment.draw_mini_map()
: Draws the minimap in the corner of the screen.draw_info(fps)
: Displays the FPS and movement instructions.
Contributions are welcome! Please feel free to submit a pull request with any improvements or bug fixes.
This project is licensed under the MIT License.