A 2D Game Engine

01 / Context

The Origin

Created as an aspiration to learn the complex systems behind commercial game engines. Originally started as a strictly object-oriented engine, but structural problems immediately arose regarding a lack of modularity.

The Evolution

The solution was to incorporate a hybrid approach. The engine now utilizes a mix of data-driven and object-oriented design, built specifically to ensure ease of use, extensibility, and robust optimizations.

02 / Architecture

  • Hybrid ECS & OOP

    An Entity-Component-System handles dynamic data, while object-oriented design drives the main game logic. This decoupled approach resolves initial modularity bottlenecks.

  • Custom Binary Storage

    Dynamic data within the ECS architecture is serialized and managed using custom binary files, ensuring robust optimization and efficient memory access.

  • Community Mod Integration

    Designed for high extensibility. Features built-in community mod support backed by extensive documentation to maximize user engagement and customization.

03 / Specifications

  • LANGUAGE Python 3.13+
  • GRAPHICS Pygame
  • DATA STORAGE Custom Binary Files
  • DESIGN PATTERN Hybrid ECS / OOP

04 / Roadmap

Integrated GUI Editor

Transitioning from hard-coded scene construction to a visual, inspector-driven GUI to accelerate level design, entity configuration, and workflow efficiency.

OpenGL Rendering Pipeline

Replacing the software-bound Pygame renderer with a hardware-accelerated OpenGL pipeline to support custom shaders, dynamic lighting, and significantly higher entity counts.

05 / Syntax

FILE: core_engine.py FORMAT: UTF-8
class PyBox:
    def __init__(self):
        # Hybrid Architecture: ECS for data, OOP for state
        self.ecs_registry = Registry()
        self.state_manager = StateMachine()

    def load_scene(self, filepath: str):
        # Custom binary serialization for rapid entity loading
        with open(filepath, 'rb') as bin_file:
            magic_number = bin_file.read(4)
            if magic_number != b'PYBX':
                raise CorruptedSceneError("Invalid memory signature")
            
            self.ecs_registry.deserialize_fast(bin_file)

    def execute_loop(self):
        while self.state_manager.is_running():
            dt = self.clock.get_fixed_step()
            self.ecs_registry.update_systems(dt)