Skip to content

vorlac/godot-roguelite

Repository files navigation

Godot 4.3 GDExtension C++ Prototype

This project is a rough prototype focusing on understanding how to implementa majority of a game's core logic/scripting in C++ using GDExtension. Everything is done in the code aside from UI/dialog/menu design, and scene file generation.

The current focus is aimed towards learning more about how certain features and funtionality can be implemented in native code leveraging the godot-cpp GDExtension bindings so there isn't much game logic implemented yet. Since the documentation is pretty sparse when it comes to pure native development, most of the functionality implemnted in this project is focused on providing a variety of general examples of misc functionality that others will likely find useful.

Game logic will become a focus when most of the essentials are figured out and implented throughout the project.

Overview

This project is meant to show others working with GDExtension how to:

  • structure a project
  • implement specific features and functionality entirely in C++
  • incorporate 3rd party libraries into their GDExtension code/library
  • use CMake, VCPKG, and submodules to configure the project automatically
  • configure VSCode (linux & windows) / Visual Studio 2022 (windows) for
    • good code navigation for godot engine sources, godot-cpp sources, and the gdextension project sources.
    • good autocomplete / intellisense configuration
    • preconfigured debugger launch profiles to run the project standalone or by launching the editor (both launch settings debuggable)
    • good debugger visualizations for internal godot data structures by leveraging the .natvis file provided with godot-cpp

High Level Project Structure

The project's main scene consists of a single Main node. The Main node is intended to handle all high level game management (level loading, scene swaps, saving, loading, UI, input handling, menus, signal propigation, etc)

The overall node hierarchy:

Main
├── Main Canvas Layer (reference to Canvas Layer in MainDialog)
├── MainDialog
│   ├── RichTextLabel (In-Game Console)
│   └── MainSubViewport (Primary Game Viewport)
│       └── Canvas Layer
├── Level
│    ├── Player (GDCLASS object inheritance example)
│    │   ├── Godot Player Scene
│    │   ├── CharacterController
│    │   ├── Camera
│    │   └── FiringPoint (Marker2D reference from Godot Player Scene)
│    └── Projectile Spawner
│        └── Projectile
Console (Singleton example)
└── RichTextLabel (Reference from MainDialog)

Setup Guide

See the wiki for a detailed guide that will walk you through the steps required to get this project running and debugging on linux or windows. Make sure to thank PixelRain in the Godot discord for his contributions to the wiki.

Using this project as a base for your project

This repo is set up as a template (using the "use this template"->"create a new repository" button on the main landing page of this repo). If you use that option rather than just cloning this repo directly it will create a copy of the repo (not a clone or fork) in your github account with all history stripped. This project should be relatively plug and play when it comes to reusing the parts you want to keep and removing/replacing the parts you don't. If you create a repo from the template you also have the option of making the project private when it creates the repo in your github account.

Once the template project is created you should be able to just swap out the code in src/ and godot project files in project/ with your own C++ source code and godot project files. If everything was replaced correctly/consistently, the cmake build should detect the changes in the src/ directory (file additions/removals/renames) and know to reconfigure the project if/when changes are made.

More information about using this repo as a base for your own project in the templating section of the wiki.

Note about cloning

If you just want to clone/try this project locally, it's important that you truly clone the repo and not just download it as a zip. The repo contains submodules that are required for the build to function properly, which will only be included if the repo is cloned (or templated). The zip download option won't correctly package the repos located in each extern/ directory which will lead to the buildscripts failing.

Contributing

This repo and/or the gdextension developer documentation I recently started working on is open to anyone that wants to contribute. Feel free to submit PRs for any changes that implement new features, fix bugs, or improve upon any existing features, functionality, or design.

Additional Resources

The projects below are also worth checking out for some additional GDExtension examples to use as references

Licensing

Code

  • All code in this project is licensed as MIT

Assets