A collection of my personal projects

2D Game Engine

·

The 2D Game Engine is built around a flexible Entity Component System (ECS) architecture, which divides game objects into entities, components, and systems. This design promotes modularity, scalability, and efficient management of game elements. Key features include dynamic physics, network communication, input handling, and scripting, all integrated seamlessly to provide a comprehensive game development environment.

This 2D Game Engine showcases a comprehensive integration of advanced game development techniques and external libraries. By leveraging SDL2, Box2D, JSON, and other technologies, the engine provides a robust platform for creating interactive and dynamic 2D games.

Core Architecture: Entity Component System (ECS)

Entity Component System (ECS): The ECS architecture is at the heart of the engine, enabling a clean separation between data and behavior. This architecture ensures that the engine can handle complex interactions and large numbers of entities efficiently.

  • Components: Define various attributes and behaviors of entities. Examples include TransformComponent for position and rotation, and SpriteComponent for rendering.
  • Entities: Unique game objects that are composed of multiple components. Each entity is identified by a unique ID.
  • Systems: Manage the logic and behavior of entities with specific components. Examples include rendering, physics updates, and input handling.

Registry: The registry manages the lifecycle of entities and components, facilitating the creation, destruction, and updating of game objects. It ensures that systems can efficiently access and manipulate the components they require.

Core Components

Game Class: The Game class serves as the central hub, managing the main game loop, initialization, input processing, updates, and rendering. It utilizes SDL2 for window management, rendering, and handling user input, ensuring smooth and responsive gameplay.

Asset Manager: The Asset Manager is responsible for loading, storing, and retrieving various game assets such as textures, fonts, and sounds. It leverages SDL2 for image and sound management and SDL_ttf for font handling, ensuring efficient resource management and access.

Event Manager: The Event Manager provides a flexible system for handling events within the game. It allows for the subscription to and emission of various events, improving decoupling and modularity. Examples of events include KeyPressedEvent for keyboard inputs and SoundEffectPlayEvent for playing sound effects.

Integrated Systems

Box2D Physics System: The Box2DSystem integrates the Box2D library to handle physics simulation. It manages the creation and updating of physics bodies, ensuring realistic movement and collision detection. This system updates the physics world every frame, applying forces and handling collisions.

Keyboard Control System: The KeyboardControlSystem processes keyboard inputs to control game entities. It uses SDL2 to capture key presses and releases, updating the movement and actions of entities based on user input. This system ensures responsive and intuitive controls for the player.

Network System: The NetworkSystem uses the ENet library to handle network communications. It manages client-server connections, processes network events, and handles data packets for multiplayer functionality. This system ensures real-time synchronization of game state across networked players.

Save System: The SaveSystem utilizes JSON for saving and loading game state. It serializes the state of entities and their components to JSON files, allowing for persistent gameplay and easy debugging. This system ensures that game progress can be saved and restored accurately.

Script System: The ScriptSystem integrates Lua scripting, allowing for dynamic and flexible game behavior. It binds C++ types and functions to Lua, enabling scripts to control game entities and respond to game events. This system facilitates rapid prototyping and customization of game logic.

Key Technologies and Libraries

SDL2: SDL2 is the core library used for window management, rendering, and input handling. It provides a robust foundation for building cross-platform applications, ensuring smooth graphics and responsive input processing.

Box2D: Box2D is a physics engine used for simulating rigid body dynamics. It enables realistic physics interactions and collision detection, enhancing the gameplay experience with believable movement and interactions.

JSON: JSON is used for data serialization in the SaveSystem. It provides a flexible and lightweight format for storing game state, making it easy to save and load complex data structures.

ImGUI: ImGUI is a library for creating graphical user interfaces. It is used to develop in-game editors and debugging tools, providing a powerful interface for interacting with the game engine.

ENet: ENet is a library for reliable network communication. It supports real-time multiplayer gameplay by handling network connections and data transmission efficiently.

Lua: Lua is a lightweight scripting language integrated into the engine for dynamic behavior. It allows developers to write game logic in scripts, facilitating rapid development and iteration.

¶¶¶¶¶

¶¶¶¶¶

¶¶¶¶¶

Leave a Reply

Your email address will not be published. Required fields are marked *