diff --git a/.gitmodules b/.gitmodules index 2af85b8..008f729 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 diff --git a/README.md b/README.md index 264c0d2..88584ea 100644 --- a/README.md +++ b/README.md @@ -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 @@ -25,40 +28,48 @@ 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
-│   ├── Character
-│   │   ├── Camera
-│   │   ├── Sprite2D
-│   │   └── CollisionShape2D
-│   └── Projectile Spawner
-│       └── Projectile
-└── Main Canvas Layer (reference to Canvas Layer in MainDialog)
-

+├── Level +│ ├── Player +│ │ ├── (Scene) +│ │ ├── CharacterController +│ │ ├── Camera +│ │ └── FiringPoint (Marker2D) +│ └── Projectile Spawner +│ └── Projectile Console (Singleton) └── RichTextLabel (Reference from MainDialog)
# 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) diff --git a/extern/godot-cpp b/extern/godot-cpp index 04b3407..54136ee 160000 --- a/extern/godot-cpp +++ b/extern/godot-cpp @@ -1 +1 @@ -Subproject commit 04b34077d873f6ef4cd1c3518fefc2616dec41e7 +Subproject commit 54136ee8357c5140a3775c54f08db5f7deda2058 diff --git a/extern/godot-engine b/extern/godot-engine index 2d3b2ab..0bf1295 160000 --- a/extern/godot-engine +++ b/extern/godot-engine @@ -1 +1 @@ -Subproject commit 2d3b2abcf6edcc9b02a9b1894ba43f79845ad2f4 +Subproject commit 0bf12956a10d216c46368f26b00f6999d000c1d8 diff --git a/project/project.godot b/project/project.godot index 8244266..c334b1d 100644 --- a/project/project.godot +++ b/project/project.godot @@ -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] diff --git a/project/roguelite.gdextension b/project/roguelite.gdextension index ba3ff49..50d4929 100644 --- a/project/roguelite.gdextension +++ b/project/roguelite.gdextension @@ -1,7 +1,8 @@ [configuration] entry_symbol = "extension_library_init" -compatibility_minimum = 4.1 +compatibility_minimum = 4.2 +reloadable = false [libraries] diff --git a/project/scenes/projectiles/bullet.tscn b/project/scenes/projectiles/bullet.tscn index 6322b20..960ce9a 100644 --- a/project/scenes/projectiles/bullet.tscn +++ b/project/scenes/projectiles/bullet.tscn @@ -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 @@ -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 diff --git a/src/entity/character/character.cpp b/src/entity/character/character.cpp index 5f6991a..5ded89e 100644 --- a/src/entity/character/character.cpp +++ b/src/entity/character/character.cpp @@ -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) { diff --git a/src/entity/controller/character_controller.cpp b/src/entity/controller/character_controller.cpp index 6fedf24..0fe8e1a 100644 --- a/src/entity/controller/character_controller.cpp +++ b/src/entity/controller/character_controller.cpp @@ -58,24 +58,4 @@ namespace rl signal_binding::add(); } - - // 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); - // } } diff --git a/src/entity/controller/character_controller.hpp b/src/entity/controller/character_controller.hpp index 9032bd3..db2c32c 100644 --- a/src/entity/controller/character_controller.hpp +++ b/src/entity/controller/character_controller.hpp @@ -36,7 +36,6 @@ namespace rl protected: static void _bind_methods(); - // void _notification(int notification); protected: // the active input mode for character controls diff --git a/src/entity/controller/player_controller.hpp b/src/entity/controller/player_controller.hpp index 75f35ae..f352595 100644 --- a/src/entity/controller/player_controller.hpp +++ b/src/entity/controller/player_controller.hpp @@ -18,8 +18,6 @@ namespace rl InputMode get_input_mode(godot::Input* const input); protected: - // void _notification(int notification); - static void _bind_methods() { } diff --git a/src/entity/projectile/projectile.hpp b/src/entity/projectile/projectile.hpp index 3f73033..8b3ba07 100644 --- a/src/entity/projectile/projectile.hpp +++ b/src/entity/projectile/projectile.hpp @@ -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(this->get_name()), - // io::yellow("entering >>"), to(node->get_name())); - // } - - // [[signal_slot]] - // void on_body_exit(godot::Node* node) const - // { - // console::get()->print("Projectile: {} {} {}", to(this->get_name()), - // io::orange("exiting <<"), to(node->get_name())); - // } - protected: static void _bind_methods() {