2D Game Engine - SP-31
A downloadable tool
CS-4850
Section 02
Fall 2023
Instructor Sharon Perry.
Kosi Chima - Programmer
Nick Tsakir - Programmer
A game engine is a software framework that provides the tools and infrastructure for developers to create video games. It handles many of the low-level tasks of game development, such as graphics rendering, input handling, and physics simulation, allowing developers to focus on the higher-level creative aspects of game design.
There are many different types of game engines, but they all share some common features. A typical game engine includes the following:
- Renderer: The renderer is responsible for drawing the game world to the screen. It takes care of things like applying textures, lighting, and shadows.
- Input handler: The input handler handles user input from devices such as keyboards, mice, and gamepads. It translates this input into events that the game can understand.
- Physics engine: The physics engine simulates the physical world of the game. It takes care of things like collisions, gravity, and movement.
- Audio engine: The audio engine plays sounds and music in the game. It can be used to create a variety of sound effects, such as explosions, footsteps, and music.
- Scripting engine: The scripting engine allows developers to write scripts to control the behavior of the game. This can be used to create things like AI, cutscenes, and gameplay mechanics.
The Entity-Component-System (ECS) Design Pattern
The Entity-Component-System (ECS) is a popular design pattern for game development. It is a way of organizing game data that is efficient and scalable.
In an ECS, game objects are represented as entities. Each entity has a set of components that define its properties and behavior. For example, a player entity might have a position component, a health component, and a movement component.
Components are stored separately from entities. This makes it easy to add or remove components from entities, and it also makes it easy to reuse components across different entities.
Systems are responsible for updating the game state. They do this by iterating over entities and components. For example, a movement system might iterate over all player entities and update their positions based on their input.
How to Use SDL to Create a Window, Render Graphics, and Handle Input
SDL (Simple DirectMedia Layer) is a cross-platform library that provides low-level access to the graphics, sound, and input subsystems of the operating system. It is a popular choice for developing 2D games.
To use SDL to create a window, render graphics, and handle input, you will need to do the following:
- Initialize SDL
- Create a window
- Create a renderer
- Load images
- Render graphics
- Handle input
- Quit SDL
How to Use Lua to Embed Scripting in Your Game Engine
Lua is a lightweight scripting language that is often used in game development. It is easy to embed Lua in a C++ application, and it can be used to extend the functionality of your game engine.
To embed Lua in your game engine, you will need to do the following:
- Include the Lua header file
- Create a Lua state
- Load Lua scripts
- Call Lua functions
- Close the Lua state
How to Design and Implement a Game Loop
The game loop is the main loop of your game. It is responsible for updating the game state, rendering graphics, and handling input.
To design and implement a game loop, you will need to do the following:
- Initialize the game
- Enter the game loop
- Update the game state
- Render graphics
- Handle input
- Repeat steps 3-5 until the game is over
- Quit the game
Leave a comment
Log in with itch.io to leave a comment.