Skip to content

C++ Game Engine. Features include physics, collision detection, sound, scene / camera, text, and more.

License

Notifications You must be signed in to change notification settings

martinstarkov/protegon

Repository files navigation

protegon

2D game engine using OpenGL for rendering and SDL2 (image, mixer, ttf) for user input, audio, and fonts.

Prerequisites

This project requires C++17 or newer and CMake 3.20+. You will also need a build system and a C++ compiler (see CMake Build Instructions).

Features

  • Custom batch renderer
  • Shader support
  • Scene manager (with camera)
  • Resource managers
  • Entity component system
  • Event system
  • UI (buttons)
  • Timers
  • Fractal noise and RNG
  • Tweens
  • Math library (Vector2-4, Matrix4, Quaternions)
  • Collision detection and resolution
  • Mouse and keyboard input handling
  • Music and sound playback
  • Function profiling
  • Other useful debugging utilities

Adding to a CMake project

  1. Clone the repository to a directory on your local machine (referred to as <repository_directory>). Alternatively, you can add it as a git submodule.

  2. Add the following lines in your CMakeLists.txt file after creating your target (referred to as <target_name>):

add_subdirectory(<repository_directory> binary_dir)
add_protegon_to(<target_name>)
create_resource_symlink(<target_name> <source_parent_dir> <destination_parent_dir> <directory_name>) // (optional for creating a symlink for the resources folder)

CMake Build Instructions

  1. cd <replace_with_repository_directory> to navigate into the cloned repository.
  2. mkdir build to create a build directory.
  3. cd build to enter the created build directory.
  4. Depending on your build system, follow the appropriate next steps:

Microsoft Visual Studio

  1. cmake .. -G "Visual Studio 17 2022" to generate build files.
  2. Open the generated <your_project_name>.sln file.
  3. Set <your_project_name> as the startup project.
  4. Build and run.

Ninja

  1. cmake .. -G Ninja to generate build files.
  2. ninja to build the project.
  3. ./your_project_name.exe to run your executable.

Linux

  1. /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" (Installs Homebrew for Linux).
  2. (required if brew not in PATH) (echo; echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"') >> /home/<your_username>/.bashrc
  3. (required if brew not in PATH) eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
  4. cmake .. -G "Unix Makefiles" to generate build files.
  5. make to build the project.
  6. ./your_project_name.exe to run your executable.

macOS

  1. cmake .. -G Xcode to generate build files.
  2. make to build the project.
  3. ./your_project_name.exe to run your executable.

Emscripten (WebGL)

Additional Dependencies:

  • Emscripten SDK: Check that Emscripten is added to PATH by running emcc --version
  • Ninja or MinGW: Check that Ninja/MinGW is added to PATH by running ninja --version or gcc --version respectively

Emscripten Building

Navigate to the scripts directory:

cd scripts

Run any of the following script commands:

Command Description
./build-emscripten.sh Generates emscripten build files (index.html, etc) in the build directory
./run-emscripten.sh Runs the generate build files locally using emrun
./build-run-emscripten.sh Combines the two above scripts
./zip-for-itch.sh Zips the generated build files and places the zip in the build directory
./build-itch.sh Combines the above build and zip scripts

Misc Information

  • If you get the error A required privilege is not held by the client when creating a symlink using create_resource_symlink on Windows, turn on Developer mode.

About

C++ Game Engine. Features include physics, collision detection, sound, scene / camera, text, and more.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages