olcPixelGameEngine is a single file library for game development created in C++.
It is cross-platform, compiling on Windows via Visual Studio, MinGW and Code::Blocks , and in GNU/Linux with a modern g++.
The olcPixelGameEngine
was developed by the legendary programmer C++ and youtuber: javidx9.
On Linux based systems you will need the following dependencies:
Example of installing dependencies on some GNU/Linux distros:
# Debian, Ubuntu, Mint and similar
sudo apt install build-essential libglu1-mesa-dev libpng-dev
# Arch Linux, Manjaro and the like
sudo pacman -S gcc glibc libpng table
# Fedora and similar
sudo dnf groupinstall "Development Tools" "Development Libraries"
sudo dnf install gcc-c++ glew-devel glm-devel libpng-devel
After that just create a basic code (for testing), copy the example code below:
main.cpp
#define OLC_PGE_APPLICATION
#include "olcPixelGameEngine.h"
class Example : public olc::PixelGameEngine {
public:
Example(){
sAppName = "Example";
}
public:
bool OnUserCreate() override {
return true;
}
bool OnUserUpdate(float fElapsedTime) override {
for (int x = 0; x < ScreenWidth(); x++){
for (int y = 0; y < ScreenHeight(); y++){
Draw(x, y, olc::Pixel(rand() % 255, rand() % 255, rand()% 255));
}
}
return true;
}
};
int main() {
Example demo;
if (demo.Construct(100, 100, 4, 4)){
demo.Start();
}
return EXIT_SUCCESS;
}
Now download the file olcPixelGameEngine.h:
wget -q https://raw.githubusercontent.com/OneLoneCoder/olcPixelGameEngine/master/olcPixelGameEngine.h
And compile with the following command:
g++ main.cpp -lX11 -lGL -lpthread -lpng -lstdc++fs -std=c++17
After running ./a.out
if a window appears like “no channel tuning on old TVs” like the image below, everything is fine!
To run on Windows via Visual Studio, watch the video below:
To run on Windows with MinGW:
To run on Windows with Code::Blocks:
cpp gamedev terminal windows macos