Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Maze

A first-person 3D maze game built with Python and OpenGL. Navigate through a hand-crafted 30×30 maze, find the exit, and beat your time.

Python OpenGL License


Features

  • First-person 3D rendering — perspective projection with textured marble walls
  • Smooth movement — wall-sliding collision so you don't get stuck on corners
  • In-game HUD — live timer displayed in the top-left corner
  • Minimap — top-right corner overview with your position (red) and the exit (green)
  • Win screen — centered overlay shows your final time when you reach the exit
  • Dual control scheme — WASD and arrow keys both work out of the box

Requirements

  • Python 3.10+
  • PyOpenGL 3.1.7+
  • Pillow 10.0+

Installation

git clone https://github.com/Turan-Nadir/maze-game.git
cd maze-game

With pip (recommended):

python -m venv venv
source venv/bin/activate        # Windows: venv\Scripts\activate
pip install -r requirements.txt

With conda:

conda create -n maze python=3.11
conda activate maze
pip install -r requirements.txt

Running

python maze.py

Controls

Action Keys
Move forward W or
Move back S or
Turn left A or
Turn right D or
Strafe left ,
Strafe right .
Quit ESC

Project Structure

maze/
├── maze.py              # Entry point — game loop, rendering, input handling
├── requirements.txt
├── texture/
│   └── marble.jpg       # Wall texture
├── map.jpeg             # Reference image of the full maze layout
└── src/
    ├── collision.py     # AABB collision detection with wall-slide
    ├── cube.py          # Textured unit-cube renderer (6 faces)
    ├── input.py         # Keyboard state tracker (WASD + arrow keys)
    ├── movement.py      # Camera movement vector calculation
    └── texture.py       # OpenGL texture loader via Pillow

How It Works

The maze is represented as a 2D integer grid — 1 is a wall, 0 is open space. Each frame, the scene is rendered by iterating the grid and drawing a textured cube at every wall cell via OpenGL immediate mode.

Camera movement uses a simple step-distance vector offset based on the current rotation angle. Before applying a move, the new position is tested against the collision grid; if blocked, the code tries to slide along the unblocked axis so movement feels smooth near walls.

The minimap and HUD are drawn as 2D overlays by temporarily switching to an orthographic projection, rendering the UI elements, then restoring the perspective projection for the next frame.


License

MIT

About

Maze Game with OpenGL and PyOpenGL This is a simple maze game developed for a Computer Graphics class. The game uses OpenGL for rendering and Pillow for texture loading.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages