All Projects → RonenNess → BonEngineSharp

RonenNess / BonEngineSharp

Licence: MIT license
A simple and fun SDL-based game engine in C#.

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to BonEngineSharp

Libsdl2pp
C++11 bindings/wrapper for SDL2
Stars: ✭ 385 (+2306.25%)
Mutual labels:  gamedev, sdl, sdl2
SDL.zig
A shallow wrapper around SDL that provides object API and error handling
Stars: ✭ 102 (+537.5%)
Mutual labels:  gamedev, sdl, sdl2
Pygame
pygame (the library) is a Free and Open Source python programming language library for making multimedia applications like games built on top of the excellent SDL library. C, Python, Native, OpenGL.
Stars: ✭ 4,164 (+25925%)
Mutual labels:  gamedev, sdl, sdl2
Simpleton Engine
What a stupid name for a library
Stars: ✭ 42 (+162.5%)
Mutual labels:  gamedev, sdl2, game-2d
Gf
A C++14 framework for 2D games
Stars: ✭ 154 (+862.5%)
Mutual labels:  gamedev, sdl2, game-2d
sdlpp
C++ wrapper for SDL2
Stars: ✭ 37 (+131.25%)
Mutual labels:  gamedev, sdl, sdl2
Gwork
Skinnable GUI with useful widget collection. Fork of GWEN.
Stars: ✭ 179 (+1018.75%)
Mutual labels:  gamedev, sdl, sdl2
faur
⚒️✨ My personal C games framework. 2D graphics, sound, inputs, states, ECS, and misc utils for data, files, math, memory, strings, time, and more. Builds for Linux, Windows, Web, and embedded devices.
Stars: ✭ 55 (+243.75%)
Mutual labels:  gamedev, sdl, sdl2
gnuboy
latest version of original laguna source, with a handful fixes for modern compilers and systems
Stars: ✭ 70 (+337.5%)
Mutual labels:  sdl, sdl2
sdl stb font
Renders text using STB_Truetype in pure SDL
Stars: ✭ 40 (+150%)
Mutual labels:  sdl, sdl2
Driftwood
Driftwood 2D Tiling Game Engine and Development Suite
Stars: ✭ 23 (+43.75%)
Mutual labels:  sdl, sdl2
nox-decomp
Unofficial Nox (2000) port to Linux using decompiled code from https://playnox.xyz
Stars: ✭ 21 (+31.25%)
Mutual labels:  sdl, sdl2
Dome
A lightweight game development environment where games can be written in Wren
Stars: ✭ 251 (+1468.75%)
Mutual labels:  gamedev, sdl2
ffi-sdl
PHP FFI SDL bindings
Stars: ✭ 23 (+43.75%)
Mutual labels:  sdl, sdl2
Gdevelop
🎮 GDevelop is an open-source, cross-platform game engine designed to be used by everyone.
Stars: ✭ 3,221 (+20031.25%)
Mutual labels:  gamedev, game-2d
guisan
A C++ SDL2 user interface library based on guichan. ~~~~ Nov, 2021 - This project is not abandoned, just not under active development. Pull requests will be accepted and new releases will be generated for new features / bug fixes.
Stars: ✭ 54 (+237.5%)
Mutual labels:  sdl, sdl2
sdl12-compat
An SDL-1.2 compatibility layer that uses SDL 2.0 behind the scenes.
Stars: ✭ 99 (+518.75%)
Mutual labels:  sdl, sdl2
Deadsimple Pixel Perfect Camera
An exceedingly easy-to-use pixel perfect orthographic camera script for 2D scenes in Unity. Punch in a few specs and you've got a working pixel perfect camera. It's that easy.
Stars: ✭ 186 (+1062.5%)
Mutual labels:  gamedev, sprites
Fairtris
Clone of the official classic Tetris® game for the NES console, intended for Windows and Linux systems. It implements the original mechanics and includes many regional versions and several RNGs (all in one executable).
Stars: ✭ 30 (+87.5%)
Mutual labels:  sdl, sdl2
OpenHSP
Hot Soup Processor (HSP3)
Stars: ✭ 120 (+650%)
Mutual labels:  gamedev, sdl2

BonEngine Sharp

BonEngine is a code-based game engine designed to be simple and straightforward, with as little setup as possible. It covers 2d rendering, assets, sound effects, music, input, config files, and more.

BonEngineSharp is a C# bind of BonEngine. The APIs are nearly identical, so in this doc we'll only cover few examples and not the whole API.

To view the full API you can check out API docs or the base BonEngine repo.

Showcase

A game I made with BonEngineSharp: https://ronenness.itch.io/edge-of-divinity

Install

To install use nuget:

Install-Package BonEngineSharp

Or grab the latest build from releases and add reference manually.

Important - no Any CPU

SinceBonEngineSharp is a wrapper around a CPP library, your project needs to be built as either x86 or x64, but it can't be Any CPU. Same code can be used for both platforms, there's no difference in API or how you use the engine.

Platforms

BonEngineSharp is built for .net core 3.0, and it uses a CPP library compiled for Windows Desktop (x86 or x64) with VS2019 tools. If you want to build projects for different platforms, you need to build the CPP dlls yourself (from this repo).

Note that the CPP side is built with SDL and should be cross platform, but it wasn't officially tested or built for non-desktop targets.

How To Use

BonEngine is very easy to setup:

using BonEngineSharp;

/// <summary>
/// A basic example scene.
/// </summary>
class MyScene : Scene
{
    // called when scene loads
    protected override void Load()
    {
    }

    // called when scene unloads
    protected override void Unload()
    {
    }

    // called every frame to do updates
    protected override void Update(double deltaTime)
    {
    }
    
    // called every frame to draw scene
    protected override void Draw()
    {
    }

    // called every constant interval to update physics related stuff
    protected override void FixedUpdate(double deltaTime)
    {
    }
}

/// <summary>
/// Start the application.
/// </summary>
static void Main(string[] args)
{
    using (var scene = new MyScene()) {
        BonEngine.Start(scene);
    }
}

Once running, you can change your active scene:

Game.ChangeScene(newScene);

Managers

BonEngine is divided into 7 subsystems, called managers. These managers implement the vast majority of the engine's APIs, and they are:

Game

Application and global game stuff, like changing scene, exiting game, load config from file, retrieve delta time, ect.

Assets

Load and create assets - images, sound effects, music, config files, ect.

Gfx

Everything related to graphics and rendering.

Sfx

Everything related to sound effects and music.

Input

Implements user input, either by querying keyboard and mouse states or by checking "actions" which are bound to different keys.

Log

Provide basic logs.

UI

Provide UI system.

Diagnostics

Get diagnostics and debug data, like FPS, number of draw calls, ect.

Some Examples

Lets review some simple examples (note: more examples can be found under the BonEngineSharpTest project).

Drawing Images - Gfx.DrawImage()

using BonEngineSharp;
using BonEngineSharp.Assets;
using BonEngineSharp.Framework;

class MyScene : BonEngineSharp.Scene
{
    // image to draw
    private ImageAsset _srcImage;
    
    // called when scene loads - load image from file
    protected override void Load()
    {
        _srcImage = Assets.LoadImage("my_image.png");
    }
    
    // called every frame to draw scene - draw image
    protected override void Draw()
    {
        Gfx.DrawImage(_srcImage, new PointI(100, 100));
    }
}

Drawing Shapes - Gfx.DrawRectangle()

using BonEngineSharp;
using BonEngineSharp.Framework;

class MyScene : BonEngineSharp.Scene
{ 
    // called every frame to draw scene - draws a rectangle
    protected override void Draw()
    {
        Gfx.DrawRectangle(new RectangleI(50, 50, 25, 25), Color.Red, true);
    }
}

Drawing Text - Gfx.DrawText()

using BonEngineSharp;
using BonEngineSharp.Assets;
using BonEngineSharp.Framework;

class MyScene : BonEngineSharp.Scene
{ 
    // font to use
    private FontAsset _font;
    
    // called when scene loads - load font to use
    protected override void Load()
    {
        _font = Assets.LoadFont("OpenSans-Regular.ttf", 32);
    }
    
    // called every frame to draw scene - draw text
    protected override void Draw()
    {
        Gfx.DrawText(_font, "Hello BonEngine!", new PointF(50, 50));
    }
}

Drawing Sprites - Gfx.DrawSprite()

using BonEngineSharp;
using BonEngineSharp.Assets;
using BonEngineSharp.Framework;

class MyScene : BonEngineSharp.Scene
{
    // sprite to draw
    private Sprite _sprite;
    
    // called when scene loads - setup sprite
    // note: spritesheets and animations exists in the engine, but are not covered in this example
    protected override void Load()
    {
        _sprite = new Sprite()
        {
            Position = new PointF(500, 500),
            Origin = new PointF(0.5f, 1.0f),
            Image = Assets.LoadImage("sprite.png")
        };
    }
    
    // called every frame to draw scene - draw sprite
    protected override void Draw()
    {
        Gfx.DrawSprite(_sprite);
    }
}

Playing Music - Sfx.PlayMusic()

using BonEngineSharp;
using BonEngineSharp.Assets;
using BonEngineSharp.Framework;

class MyScene : BonEngineSharp.Scene
{ 
    // music to play
    private MusicAsset _music;
    
    // called when scene loads - load and starts playing music
    protected override void Load()
    {
        _music = Assets.LoadMusic("my_song.ogg");
        Sfx.PlayMusic(_music);
    }
}

Playing Sounds - Sfx.PlaySound()

using BonEngineSharp;
using BonEngineSharp.Assets;
using BonEngineSharp.Framework;

class MyScene : BonEngineSharp.Scene
{ 
    // music to play
    private SoundAsset _sound;
    
    // called when scene loads - load and plays sound effect once
    protected override void Load()
    {
        _sound = Assets.LoadSound("boom.wav");
        Sfx.PlaySound(_sound, 100, 0);
    }
}

Getting Input - Input.Down() / Input.CursorPosition

using BonEngineSharp;
using BonEngineSharp.Framework;

class MyScene : BonEngineSharp.Scene
{ 
    // called every frame to control player
    protected override void Update(double deltaTime)
    {
        // check bound action
        if (Input.Down("left"))
        {
            // move left
        }
        
        // check key directly
        if (Input.Down(KeyCodes.KeySpace))
        {
            // attack
        }
        
        // get mouse position 
        var mouse = Input.CursorPosition;
    }
}

License

This lib is distributed with the MIT license, so you can do pretty much anything (legal) with it :)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].