- Edited
Hello!
I'm a longtime programmer and hobbyist game developer. For years I've been building up games "from scratch," but recently I found Godot and I've really enjoyed the tools it gives.
One thing I've noticed is a lot of my games start with some similar logic. Even if I later customize it, it's likely that, for example, in a 2D game I might want an Area2D that can be moved with the arrow keys, or one that I can click and drag around. And I usually add an "Escape to quit" function pretty early on for my root scene, and later expand it to pop up a little context menu with a quit option.
The thing is, I get tired of writing the same thing over and over, even when it's simple. After all, that's why I'm using Godot and not writing the games from scratch like I used to. But, I also usually don't like to take a large system like Top-Down Action RPG Template and get it into the form I want. I'd rather build up from small, reusable pieces.
So, I think I'm going to try out writing some nodes that package the logic I find myself reimplementing. They'd be useful for prototyping, not so much in a final game where you'd surely want more customized and specific logic.
I haven't been able to find evidence of anyone having done this before, but I'd be very interested if there are any I'm missing! I'd much rather use someone else's.
If I do write these myself, I'm curious if anyone would be interested? I know to some extent the best thing to do is make some and upload them to the Asset Library and see how they do, but I'll be more motivated if I hear there's interest ahead of time.
Just to give something concrete, here's a trivial example. I'll also note that my employer demands that any code I share like this be copyrighted to them and licensed with Apache 2, so if any of that will be a problem for you, please be aware!
Example: Quit Node
Name: QuitNode.tscn
Usage: Add an instance to the "main" scene, such as the one started by F5, or that you call get_tree().change_scene()
on.
QuitNode.gd:
# Copyright 2022 Google LLC.
# SPDX-License-Identifier: Apache-2.0
extends Node2D
func _input(event):
if event.is_action_pressed("ui_cancel"):
get_tree().quit()
(Again, this is very simple, and many cases would likely need to do some unusual things, like directly adjust get_parent().position
in order to work, but again, the idea is to make tools that help with the initial prototyping, and so they should be easy to add and easy to replace later.)
Thanks for reading!