A retro 3D survival horror engine built from scratch with Python and OpenGL.
The Mansion Riddle is not just a game; it is a deep technical exploration of how classic survival horror games (like Resident Evil or Silent Hill) worked. This project implements a custom 3D engine that combines the versatility of PyGame for window and input management, with the low-level power of PyOpenGL for rendering.
- Native 3D Rendering: Graphics pipeline implemented manually using OpenGL in Immediate Mode.
- Fixed Camera System: Mathematical implementation of cinematic perspective changes based on invisible triggers.
- Tank Controls: Faithful recreation of the classic control scheme that defines the genre.
- Scalable Architecture: Modular design based on State Machines and Design Patterns.
This project demonstrates proficiency in software engineering and computer graphics:
- Language: Python 3
- Core Loop & I/O: PyGame (Window handling, delta time, keyboard/mouse inputs).
- 3D Graphics: PyOpenGL (Primitive rendering, projection and model-view matrix management).
- Mathematics: Extensive use of linear algebra for 3D transformations and camera calculations.
The code follows SOLID principles and design patterns to ensure maintainability:
classDiagram
class GameEngine {
+state_stack
+push_state()
+pop_state()
+update()
+draw()
}
class BaseState {
<<Abstract>>
+update()
+draw()
}
class PlayState {
+player
+camera_manager
}
class MenuState
GameEngine o-- BaseState : Manages
BaseState <|-- PlayState
BaseState <|-- MenuState
- State Pattern:
GameEnginemanages a stack of states (PlayState,MenuState,PauseState), allowing fluid transitions and encapsulated logic. - Singleton: Used in
InputManagerandDataManagerto provide controlled global access to shared resources. - Observer (Event System): Decouples game trigger logic (like puzzles) from their effects (opening doors), allowing a flexible reactive system.
- Component/Object: Game entities (
Player,Puzzle) encapsulate their own logic and data.
| Key | Action |
|---|---|
| W | Move Forward |
| S | Move Backward |
| A | Turn Left |
| D | Turn Right |
| E | Interact (Examine/Open) |
| ESC | Pause / Menu |
Follow these steps to run the project locally.
- Python 3.8 or higher installed.
- Git to clone the repository.
-
Clone the repository
git clone https://github.com/TheJulianAlva/project-rxj.git cd project-rxj -
Create virtual environment (Recommended)
python -m venv venv # On Windows: .\venv\Scripts\activate # On Mac/Linux: source venv/bin/activate
-
Install dependencies
pip install -r requirements.txt
-
Run the game
python main.py
project-rxj/
โโโ main.py # Entry Point
โโโ engine.py # Engine Core (State Machines)
โโโ assets/ # Resources (Models, Textures, Sounds)
โโโ data/ # Configuration and levels (JSON)
โโโ game_objects/ # Entities (Player, Puzzles, Cameras)
โโโ state/ # Game State Logic
โโโ systems/ # Global Systems (Audio, Input, Triggers)
โโโ utilities/ # Math tools and helpers
Contributions are welcome under the Feature Branch workflow!
- Fork the project.
- Create a branch for your feature (
git checkout -b feature/AmazingFeature). - Commit your changes (
git commit -m 'Add: AmazingFeature'). - Push to the branch (
git push origin feature/AmazingFeature). - Open a Pull Request.
This project was developed by a team:
- TheJulianAlva - Juliรกn Alva
- Rogelios100 - Rodrigo Del รngel
- Ximenakdsk - Ximena Hernรกndez
This project is licensed under the MIT License - see the LICENSE file for details.
Developed as a final project for the Computer Graphics course.
