Skip to content

nTh0rn/libcast-engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LibCast Engine

A from-scratch tile-based raycaster game-engine utilizing raylib-cs.

Example LibCast game

Table of Contents
  1. About
  2. Getting Started
  3. AI Disclaimer
  4. License
  5. Contact

About

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.

(back to top)

Game Flow

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).

(back to top)

Graphics

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).

(back to top)

UI

LibCast allows for the easy creation of buttons and UI interactions with use of the MouseCollision class.

  1. Instantiate and start MouseCollision family
  2. Draw all relevant items that should react according to the family.
  3. 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).

(back to top)

Getting started

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.

Prerequisites

Microsoft's .NET is required.

Installation & Usage

  1. Clone/download the repo
    git clone https://github.com/nTh0rn/libcast-engine.git
  2. Use dotnet build and dotnet run respectively to run LibCast.

(back to top)

AI Disclaimer

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)

(back to top)

License

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.

(back to top)

Contact

Nikolas Thornton - nthorn.com

(back to top)

About

A tile-based raycaster game-engine built from scratch utilizing raylib.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages