A from-scratch tile-based raycaster game-engine utilizing raylib-cs.
Table of Contents
LibCast is a tile-based raycaster game engine that utilizes a C# implementation of RayLib (raylib-cs). This game engine makes heavy use of object-oriented programming techniques, with developer work-flows and backend logic akin to GameMaker Studio.
Developing games with LibCast currently is a UX-free affair, with tools like map editors and project managers in progress. VSCode is recommended for developing with LibCast.
LibCast utilizes both entity and room-based game loops. The easiest way to understand the game flow is start in _Program.cs and follow the loops into _Game.cs, and then the respective rooms.
The developer work-flow for LibCast is very similar to GameMaker Studio as it relates to map and entity (or "object") construction, step loops, and interrupts. All maps have entities and a main-loop, the main-loop then loops over all of it's entities' loops (see _Room.cs).
See _Screen.cs for all low-level drawing functions and the basics of the graphics functionality and _Raycaster.cs for all raycasting/sprite drawing logic.
Walls/environments are rendered using DDA raycasting techniques, with support for variable-height, transparency, fixed-height floors/ceilings, and 2D scrolling sky-boxes. Entities are rendered as sprites.
All custom graphics functions are ran CPU-side, making use of a screen buffer that gets rendered at a larger scale by RayLib. This allows for easy rendering of both low-resolution and high-resolution images (i.e. text over sprites) without the need for multiple variable-resolution buffers to render individual images to. This requires that games made in LibCast run at a low-resolution, something that is both an aesthetic decision of LibCast as well as a real technical limitation.
There is work-in-progress support for terminal-esque emulation for the purpose of developing ascii-based games that are not limited by actually having to run within a terminal (see _Terminal.cs).
LibCast allows for the easy creation of buttons and UI interactions with use of the MouseCollision class.
- Instantiate and start MouseCollision family
- Draw all relevant items that should react according to the family.
- End MouseCollision family.
This causes all pixels drawn within the start/end of the family, like a button, to detect hovers/clicks and react appropriately depending on their assigned family (see _UI.cs, PauseUIButtons.cs and _Screen.cs).
Menus are handled largely using state-machines (see _UI.cs).
RayLib's default project is a demo of a procedurally-generated open world. A default building or "structure" can be dynamically placed in this demo by pressing b.
See About for technical information to begin game development. Proper and thorough documentation is coming in the future.
Microsoft's .NET is required.
- Clone/download the repo
git clone https://github.com/nTh0rn/libcast-engine.git
- Use
dotnet buildanddotnet runrespectively to run LibCast.
LibCast was developed with little-to-no support from Gen-AI. It is a personal goal to keep as much Gen-AI out of LibCast's source code as possible for the sake of learning. The overwhelming majority of LibCast, including architectural/technical decisions, as well as almost every single line of code, were determined and typed by-hand without any assistance from Gen-AI.
Notable exceptions exist in the following area(s):
- JSON Structure Parsing (unfinished)
Distributed under the MIT License and is subject to the licenses of both raylib and raylib-cs. See LICENSE.txt and THIRD_PARTY_NOTICES.txt for more information.
Nikolas Thornton - nthorn.com
