{"id":19564280,"url":"https://github.com/ronenness/bonenginesharp","last_synced_at":"2025-04-27T00:32:53.166Z","repository":{"id":82588210,"uuid":"272058597","full_name":"RonenNess/BonEngineSharp","owner":"RonenNess","description":"A simple and fun SDL-based game engine in C#.","archived":false,"fork":false,"pushed_at":"2021-07-30T21:04:36.000Z","size":14040,"stargazers_count":17,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-19T17:27:27.771Z","etag":null,"topics":["game","game-2d","game-engine","gamedev","graphics","sdl","sdl2","sprites"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RonenNess.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-13T17:49:11.000Z","updated_at":"2024-11-09T15:23:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"39ee077e-e18f-419e-ad34-c6a8263e5355","html_url":"https://github.com/RonenNess/BonEngineSharp","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RonenNess%2FBonEngineSharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RonenNess%2FBonEngineSharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RonenNess%2FBonEngineSharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RonenNess%2FBonEngineSharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RonenNess","download_url":"https://codeload.github.com/RonenNess/BonEngineSharp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251073090,"owners_count":21532005,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["game","game-2d","game-engine","gamedev","graphics","sdl","sdl2","sprites"],"created_at":"2024-11-11T05:21:10.504Z","updated_at":"2025-04-27T00:32:53.160Z","avatar_url":"https://github.com/RonenNess.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"![BonEngine Sharp](github_icon.png)\n\n`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.\n\n`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. \n\nTo view the full API you can check out [API docs](https://ronenness.github.io/BonEngineSharp/api/index.html) or the base [BonEngine repo](https://github.com/RonenNess/BonEngine).\n\n## Showcase\n\nA game I made with BonEngineSharp: https://ronenness.itch.io/edge-of-divinity\n\n## Install\n\nTo install use nuget:\n\n```\nInstall-Package BonEngineSharp\n```\n\nOr grab the latest build from releases and add reference manually.\n\n### Important - no `Any CPU`\n\nSince`BonEngineSharp` 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.\n\n### Platforms\n\n`BonEngineSharp` is built for .net core 3.0, and it uses a CPP library compiled for Windows Desktop (x86 or x64) with VS2019 tools.\nIf you want to build projects for different platforms, you need to build the CPP dlls yourself (from [this repo](https://github.com/RonenNess/BonEngine)).\n\nNote 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.\n\n## How To Use\n\n`BonEngine` is very easy to setup:\n\n```cs\nusing BonEngineSharp;\n\n/// \u003csummary\u003e\n/// A basic example scene.\n/// \u003c/summary\u003e\nclass MyScene : Scene\n{\n    // called when scene loads\n    protected override void Load()\n    {\n    }\n\n    // called when scene unloads\n    protected override void Unload()\n    {\n    }\n\n    // called every frame to do updates\n    protected override void Update(double deltaTime)\n    {\n    }\n    \n    // called every frame to draw scene\n    protected override void Draw()\n    {\n    }\n\n    // called every constant interval to update physics related stuff\n    protected override void FixedUpdate(double deltaTime)\n    {\n    }\n}\n\n/// \u003csummary\u003e\n/// Start the application.\n/// \u003c/summary\u003e\nstatic void Main(string[] args)\n{\n    using (var scene = new MyScene()) {\n        BonEngine.Start(scene);\n    }\n}\n```\n\nOnce running, you can change your active scene:\n\n```cs\nGame.ChangeScene(newScene);\n```\n\n### Managers\n\n`BonEngine` is divided into 7 subsystems, called `managers`. These managers implement the vast majority of the engine's APIs, and they are:\n\n#### Game\n\nApplication and global game stuff, like changing scene, exiting game, load config from file, retrieve delta time, ect.\n\n#### Assets\n\nLoad and create assets - images, sound effects, music, config files, ect.\n\n#### Gfx\n\nEverything related to graphics and rendering.\n\n#### Sfx\n\nEverything related to sound effects and music.\n\n#### Input\n\nImplements user input, either by querying keyboard and mouse states or by checking \"actions\" which are bound to different keys.\n\n#### Log\n\nProvide basic logs.\n\n#### UI\n\nProvide UI system.\n\n#### Diagnostics\n\nGet diagnostics and debug data, like FPS, number of draw calls, ect.\n\n\n## Some Examples\n\nLets review some simple examples (note: more examples can be found under the `BonEngineSharpTest` project).\n\n### Drawing Images - Gfx.DrawImage()\n\n```cs\nusing BonEngineSharp;\nusing BonEngineSharp.Assets;\nusing BonEngineSharp.Framework;\n\nclass MyScene : BonEngineSharp.Scene\n{\n    // image to draw\n    private ImageAsset _srcImage;\n    \n    // called when scene loads - load image from file\n    protected override void Load()\n    {\n        _srcImage = Assets.LoadImage(\"my_image.png\");\n    }\n    \n    // called every frame to draw scene - draw image\n    protected override void Draw()\n    {\n        Gfx.DrawImage(_srcImage, new PointI(100, 100));\n    }\n}\n```\n\n### Drawing Shapes - Gfx.DrawRectangle()\n\n```cs\nusing BonEngineSharp;\nusing BonEngineSharp.Framework;\n\nclass MyScene : BonEngineSharp.Scene\n{ \n    // called every frame to draw scene - draws a rectangle\n    protected override void Draw()\n    {\n        Gfx.DrawRectangle(new RectangleI(50, 50, 25, 25), Color.Red, true);\n    }\n}\n```\n\n### Drawing Text - Gfx.DrawText()\n\n```cs\nusing BonEngineSharp;\nusing BonEngineSharp.Assets;\nusing BonEngineSharp.Framework;\n\nclass MyScene : BonEngineSharp.Scene\n{ \n    // font to use\n    private FontAsset _font;\n    \n    // called when scene loads - load font to use\n    protected override void Load()\n    {\n        _font = Assets.LoadFont(\"OpenSans-Regular.ttf\", 32);\n    }\n    \n    // called every frame to draw scene - draw text\n    protected override void Draw()\n    {\n        Gfx.DrawText(_font, \"Hello BonEngine!\", new PointF(50, 50));\n    }\n}\n```\n\n### Drawing Sprites - Gfx.DrawSprite()\n\n```cs\nusing BonEngineSharp;\nusing BonEngineSharp.Assets;\nusing BonEngineSharp.Framework;\n\nclass MyScene : BonEngineSharp.Scene\n{\n    // sprite to draw\n    private Sprite _sprite;\n    \n    // called when scene loads - setup sprite\n    // note: spritesheets and animations exists in the engine, but are not covered in this example\n    protected override void Load()\n    {\n        _sprite = new Sprite()\n        {\n            Position = new PointF(500, 500),\n            Origin = new PointF(0.5f, 1.0f),\n            Image = Assets.LoadImage(\"sprite.png\")\n        };\n    }\n    \n    // called every frame to draw scene - draw sprite\n    protected override void Draw()\n    {\n        Gfx.DrawSprite(_sprite);\n    }\n}\n```\n\n### Playing Music - Sfx.PlayMusic()\n\n```cs\nusing BonEngineSharp;\nusing BonEngineSharp.Assets;\nusing BonEngineSharp.Framework;\n\nclass MyScene : BonEngineSharp.Scene\n{ \n    // music to play\n    private MusicAsset _music;\n    \n    // called when scene loads - load and starts playing music\n    protected override void Load()\n    {\n        _music = Assets.LoadMusic(\"my_song.ogg\");\n        Sfx.PlayMusic(_music);\n    }\n}\n```\n\n### Playing Sounds - Sfx.PlaySound()\n\n```cs\nusing BonEngineSharp;\nusing BonEngineSharp.Assets;\nusing BonEngineSharp.Framework;\n\nclass MyScene : BonEngineSharp.Scene\n{ \n    // music to play\n    private SoundAsset _sound;\n    \n    // called when scene loads - load and plays sound effect once\n    protected override void Load()\n    {\n        _sound = Assets.LoadSound(\"boom.wav\");\n        Sfx.PlaySound(_sound, 100, 0);\n    }\n}\n```\n\n### Getting Input - Input.Down() / Input.CursorPosition\n\n```cs\nusing BonEngineSharp;\nusing BonEngineSharp.Framework;\n\nclass MyScene : BonEngineSharp.Scene\n{ \n    // called every frame to control player\n    protected override void Update(double deltaTime)\n    {\n        // check bound action\n        if (Input.Down(\"left\"))\n        {\n            // move left\n        }\n        \n        // check key directly\n        if (Input.Down(KeyCodes.KeySpace))\n        {\n            // attack\n        }\n        \n        // get mouse position \n        var mouse = Input.CursorPosition;\n    }\n}\n```\n\n## License\n\nThis lib is distributed with the MIT license, so you can do pretty much anything (legal) with it :)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fronenness%2Fbonenginesharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fronenness%2Fbonenginesharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fronenness%2Fbonenginesharp/lists"}