A simple game engine for C# using OpenGL (earlier DirectX). Inspired by the olcPixelGameEngine.
This game engine was ported from C++ to C# in the hopes that it will help people develop their ideas faster and not waste their time in creating the same graphics code and game loop again and again.
This engine uses OpenGL and the .NET Framework, so it's quite fast due to OpenGL being hardware accelerated.
- Grab the library from the Libraries folder.
- Create a new C# project.
- Add a reference to the library in your project.
- Subclass the Game class in the engine.
- Add a Main method.
- Instantiate the class.
- Call its Construct method.
- Call its Start method.
- Override the required methods.
- Start the application.
using PixelEngine;
namespace Examples
{
public class RandomPixels : Game
{
static void Main(string[] args)
{
// Create an instance
RandomPixels rp = new RandomPixels();
// Construct the 100x100 game window with 5x5 pixels
rp.Construct(100, 100, 5, 5);
// Start and show a window
rp.Start();
}
// Called once per frame
public override void OnUpdate(float elapsed)
{
// Loop through all the pixels
for (int i = 0; i < ScreenWidth; i++)
for (int j = 0; j < ScreenHeight; j++)
Draw(i, j, Pixel.Random()); // Draw a random pixel
}
}
}
There are no additional dependencies outside the Windows Api, which is present in all windows installations, and some basic .Net Framework libraries which are present with all C# installations.
There are many examples present in the Examples folder, including Javidx9's and my own.
Build your projects with this as a reference and run the generated .exe file.
- Windows Api - The core system to display windows
- OpenGL - The rendering system
Check out the olcPixelGameEngine for C++ and its creator, Javidx9, his website OneLoneCoder, and the OLC-3 License in the original project.