Skip to content

Commit

Permalink
updated godot and godot-cpp submodules to 4.2, prevented invalid asse…
Browse files Browse the repository at this point in the history
…rt in editor, fixed dead links in readme, removed dead code
  • Loading branch information
vorlac committed Dec 1, 2023
1 parent 32b0548 commit 071c1eb
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 77 deletions.
5 changes: 2 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
[submodule "engine"]
path = extern/godot-engine
url = https://github.com/godotengine/godot.git
branch = 4.1
branch = 4.2
[submodule "godot/godot-cpp"]
path = extern/godot-cpp
url = https://github.com/godotengine/godot-cpp.git
branch = 4.1
branch = 4.2
[submodule "extern/vcpkg"]
path = extern/vcpkg
url = https://github.com/microsoft/vcpkg
ignore = dirty
71 changes: 41 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
# Godot 4.1 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.
# Godot 4.2 GDExtension C++ Prototype

The current focus is aimed towards learning more about how certain features and funtionality can be implemented in native code leveraging the [godot-cpp](https://github.com/godotengine/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.
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.

Game logic will become a focus when most of the essentials are figured out and implented throughout the project.
The current focus is aimed towards learning more about how certain features and funtionality can be implemented in native code leveraging the [godot-cpp](https://github.com/godotengine/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

- 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

Expand All @@ -25,40 +28,48 @@ The overall node hierarchy:

<div class="highlight highlight-html"> <pre>
<a href="./src/main.hpp" title="title">Main</a>
├── <a href="./src/ui/main_dialog.hpp" title="title">Main Canvas Layer (reference to Canvas Layer in MainDialog)</a>
├── <a href="./src/ui/main_dialog.hpp" title="title">MainDialog</a>
│ ├── <a href="./project/scenes/ui/main_dialog.tscn" title="title">RichTextLabel (In-Game Console)</a>
│ └── <a href="./project/scenes/ui/main_dialog.tscn" title="title">MainSubViewport (Primary Game Viewport)</a>
│ └── <a href="./project/scenes/ui/main_dialog.tscn" title="title">Canvas Layer</a>
├── <a href="./src/nodes/level.hpp" title="title">Level</a>
│ ├── <a href="./src/nodes/character.cpp" title="title">Character</a>
│ │ ├── <a href="./src/nodes/camera.cpp" title="title">Camera</a>
│ │ ├── <a href="./src/nodes/character.cpp" title="title">Sprite2D</a>
│ │ └── <a href="./src/nodes/character.cpp" title="title">CollisionShape2D</a>
│ └── <a href="./src/nodes/projectile_spawner.hpp" title="title">Projectile Spawner</a>
│ └── <a href="./src/nodes/projectile.cpp" title="title">Projectile</a>
└── <a href="./src/ui/main_dialog.hpp" title="title">Main Canvas Layer (reference to Canvas Layer in MainDialog)</a>
</p>
├── <a href="./src/entity/level.hpp" title="title">Level</a>
│ ├── <a href="./src/entity/character/player.cpp" title="title">Player</a>
│ │ ├── <a href="./project/scenes/characters/player.tscn" title="title">(Scene)</a>
│ │ ├── <a href="./src/entity/controller/character_controller.cpp" title="title">CharacterController</a>
│ │ ├── <a href="./src/entity/camera.cpp" title="title">Camera</a>
│ │ └── <a href="./src/entity/character/character.hpp" title="title">FiringPoint (Marker2D)</a>
│ └── <a href="./src/entity/projectile/projectile_spawner.hpp" title="title">Projectile Spawner</a>
│ └── <a href="./src/entity/projectile/projectile.hpp" title="title">Projectile</a>
<a href="./src/singletons/console.hpp" title="title">Console (Singleton)</a>
└── <a href="./project/scenes/ui/main_dialog.tscn" title="title">RichTextLabel (Reference from MainDialog)</a>
</pre> </div>

# Setup Guide

See the [wiki](https://github.com/vorlac/godot-roguelite/wiki) for a detailed guide that will walk you through the steps required to get this project running and debugging on linux or windows.

# Contributing

This repo and/or the [gdextension developer documentation](https://github.com/vorlac/gdextension-docs/blob/main/main.md) 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
* https://github.com/paddy-exe/GDExtensionSummator
* https://github.com/asmaloney/GDExtensionTemplate
* https://github.com/godotengine/godot-cpp/tree/master/test/src

- https://github.com/paddy-exe/GDExtensionSummator
- https://github.com/asmaloney/GDExtensionTemplate
- https://github.com/godotengine/godot-cpp/tree/master/test/src

# Licensing

#### Code
* All code in this project is licensed as [MIT](./LICENSE)

- All code in this project is licensed as [MIT](./LICENSE)

#### Assets
* All art assets (`project/assets/art/*`) are licensed as [Creative Commons Zero, CC0](./project/assets/art/LICENSE)
* All audio assets (`project/assets/audio/*`) are licensed as [Creative Commons Zero, CC0](./project/assets/audio/LICENSE)
* Art & audio assets credit: [Kenney](www.kenney.nl)
* Asset pack purchase link: [All-in-1 Asset Pack](https://kenney.itch.io/kenney-game-assets)

- All art assets (`project/assets/art/*`) are licensed as [Creative Commons Zero, CC0](./project/assets/art/LICENSE)
- All audio assets (`project/assets/audio/*`) are licensed as [Creative Commons Zero, CC0](./project/assets/audio/LICENSE)
- Art & audio assets credit: [Kenney](www.kenney.nl)
- Asset pack purchase link: [All-in-1 Asset Pack](https://kenney.itch.io/kenney-game-assets)
2 changes: 1 addition & 1 deletion extern/godot-cpp
Submodule godot-cpp updated 40 files
+14 −13 .github/workflows/ci.yml
+4 −0 .gitignore
+3 −4 CMakeLists.txt
+2 −1 README.md
+116 −19 binding_generator.py
+11,674 −2,553 gdextension/extension_api.json
+336 −16 gdextension/gdextension_interface.h
+173 −121 include/godot_cpp/classes/wrapped.hpp
+90 −0 include/godot_cpp/core/binder_common.hpp
+23 −15 include/godot_cpp/core/class_db.hpp
+12 −11 include/godot_cpp/core/memory.hpp
+3 −22 include/godot_cpp/core/object.hpp
+62 −0 include/godot_cpp/core/object_id.hpp
+12 −0 include/godot_cpp/core/property_info.hpp
+34 −9 include/godot_cpp/godot.hpp
+64 −0 include/godot_cpp/variant/callable_custom.hpp
+248 −0 include/godot_cpp/variant/callable_method_pointer.hpp
+15 −1 include/godot_cpp/variant/variant.hpp
+50 −0 src/classes/wrapped.cpp
+14 −10 src/core/class_db.cpp
+6 −5 src/core/memory.cpp
+88 −24 src/godot.cpp
+113 −0 src/variant/callable_custom.cpp
+114 −0 src/variant/callable_method_pointer.cpp
+7 −2 src/variant/char_string.cpp
+16 −0 src/variant/variant.cpp
+1 −1 test/CMakeLists.txt
+11 −0 test/SConstruct
+7 −0 test/generate_xcframework.sh
+0 −0 test/project/bin/libgdexample.macos.template_debug.framework/Resources/Info.plist
+0 −0 test/project/bin/libgdexample.macos.template_release.framework/Resources/Info.plist
+16 −0 test/project/example.gdextension
+72 −0 test/project/main.gd
+2 −1 test/project/project.godot
+186 −0 test/src/example.cpp
+26 −0 test/src/example.h
+22 −12 tools/android.py
+39 −11 tools/godotcpp.py
+1 −1 tools/ios.py
+3 −0 tools/linux.py
2 changes: 1 addition & 1 deletion extern/godot-engine
Submodule godot-engine updated 4148 files
2 changes: 1 addition & 1 deletion project/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ config_version=5

config/name="Roguelite"
run/main_scene="res://main.tscn"
config/features=PackedStringArray("4.1", "Forward Plus")
config/features=PackedStringArray("4.2", "Forward Plus")

[debug]

Expand Down
3 changes: 2 additions & 1 deletion project/roguelite.gdextension
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[configuration]

entry_symbol = "extension_library_init"
compatibility_minimum = 4.1
compatibility_minimum = 4.2
reloadable = false

[libraries]

Expand Down
4 changes: 2 additions & 2 deletions project/scenes/projectiles/bullet.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[gd_scene load_steps=3 format=3 uid="uid://csam3a1tugjo4"]

[ext_resource type="Texture2D" uid="uid://cbx5pr44nef0m" path="res://assets/art/topdown/tanks_redux/projectiles/bulletdark1_outline.png" id="1_sadn1"]
[ext_resource type="Texture2D" uid="uid://cowqe776n4b25" path="res://assets/art/topdown/tanks_redux/projectiles/bulletdark1_outline.png" id="1_sadn1"]

[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_i8hct"]
radius = 9.89949
Expand All @@ -10,10 +10,10 @@ height = 35.0
collision_layer = 4
collision_mask = 74
mass = 0.01
can_sleep = false
continuous_cd = 1
max_contacts_reported = 1
contact_monitor = true
can_sleep = false

[node name="Bullet" type="Sprite2D" parent="."]
rotation = 1.5708
Expand Down
3 changes: 2 additions & 1 deletion src/entity/character/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ namespace rl
this->find_child(name::character::firing_pt, true, false));

runtime_assert(m_firing_point != nullptr);
runtime_assert(m_character_controller != nullptr);
if (!engine::editor_active())
runtime_assert(m_character_controller != nullptr);

if (m_character_controller != nullptr)
{
Expand Down
20 changes: 0 additions & 20 deletions src/entity/controller/character_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,4 @@ namespace rl
signal_binding<CharacterController, event::position_changed>::add<godot::Object*,
godot::Vector2>();
}

// void CharacterController::_notification(int notification)
// {
// switch (notification)
// {
// case NOTIFICATION_PREDELETE:
// [[fallthrough]];
// case Node::NOTIFICATION_UNPARENTED:
// {
// console::get()->clear_context();
// console::get()->stop_logging();
// break;
// }
// default:
// break;
// }

// auto console{ console::get() };
// console->print("CharacterController: {}", notification);
// }
}
1 change: 0 additions & 1 deletion src/entity/controller/character_controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ namespace rl

protected:
static void _bind_methods();
// void _notification(int notification);

protected:
// the active input mode for character controls
Expand Down
2 changes: 0 additions & 2 deletions src/entity/controller/player_controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ namespace rl
InputMode get_input_mode(godot::Input* const input);

protected:
// void _notification(int notification);

static void _bind_methods()
{
}
Expand Down
14 changes: 0 additions & 14 deletions src/entity/projectile/projectile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,6 @@ namespace rl
[[property]] void set_acceleration(double acceleration);
[[property]] void set_velocity(double velocity);

// [[signal_slot]]
// void on_body_enter(godot::Node* node) const
// {
// console::get()->print("Projectile: {} {} {}", to<std::string>(this->get_name()),
// io::yellow("entering >>"), to<std::string>(node->get_name()));
// }

// [[signal_slot]]
// void on_body_exit(godot::Node* node) const
// {
// console::get()->print("Projectile: {} {} {}", to<std::string>(this->get_name()),
// io::orange("exiting <<"), to<std::string>(node->get_name()));
// }

protected:
static void _bind_methods()
{
Expand Down

0 comments on commit 071c1eb

Please sign in to comment.