A Godot game template for game jams.
For use with Godot 4.6-stable and later.
The following dependencies are included in the addons folder and are required for the template to function.
- Dragonforge Controller 0.14.1
- Dragonforge Disk (Save/Load) 0.7
- Dragonforge Display 0.15
- Dragonforge Sound 0.17.1
- Dragonforge State Machine 0.6
- Dragonforge User Interface 0.2.1
- Copy all the folders from the
addonsfolder into your project'saddonsfolder. - Ignore any errors (they are appearing because the component is not yet enabled):
- In your project go to Project -> Project Settings...
- Select the Plugins tab.
- Check the On checkbox under Enabled for Dragonforge Disk (must be enabled before the Display and Sound plugins or you will get errors).
- Check the On checkbox under Enabled for Dragonforge Display.
- Check the On checkbox under Enabled for Dragonforge Sound.
- Check the On checkbox under Enabled for Dragonforge Controller
- Check the On checkbox under Enabled for Dragonforge User Interface
- Check the On checkbox under Enabled for Dragonforge Game Template
- Press the Close button.
- Save your project.
- In your project go to Project -> Reload Current Project.
- Wait for the project to reload.
NOTE: It's important to reload the project after running the plugin because it updates the ui_accpet action, and creates three new actions: back_button, skip, and pause. Once you reboot, you can edit these actions as you wish, but disabling and re-enabling them will reset them.
I felt it was important to be able to update existing games with new features from this code. The easiest way to do that is to create an addon/plugin because then it is clear how to use it and makes it easy to upgrade. If this was a template to start a game that you modified, then any further updates would be much harder to add in.
A plugin also helps in game jams where one may decide tlater to add these features in. When you don't have a lot of time, it's good for using something like this to be as seamless as possible.
There is an example folder that contains an example level and player for loading a level. This is what will load when you first import the template. Note that while it loads a 2D level and charcter, this template works with 3D games as well.
Version 0.8 introduced themes. There are two, default and fantasy, Applying them to the Theme node in main.tscn under the Main Menu Game State. They are located in res://ui/themes/
The folder found at res://example_2d/ contains example code for a 2D game. These instructions assume you have already followed the installation instructions above.
- Copy the
example_2dfolder from the root of this project to your project. - In your project open
res://addons/dragonforge_game_template/game_configuration.tscn(You should have already copied this over during installation.) - In the Inspector under GameConfiguration select the File button next to Main Scene.
- In your project browse to
res://example_2d/game_template_files/main.tscnand select it. - Press Ok.
- In the Inspector under GameConfiguration select the File button next to Game Scene.
- In your project browse to
res://example_2d/game_template_files/game.tscnand select it. - Press Ok.
- Go to Project -> Project Settings...
- Select the Plugins tab.
- Uncheck the On checkbox under Enabled for Dragonforge Game Template
- Check the On checkbox under Enabled for Dragonforge Game Template
- Press the Close button.
- Save your project. (You do not need to reload the project at this time despite the warning message.)
- Press the Run Project button (or use F5). The game will start.
- You should see and hear the template default Godot splash screen video. (You can change or delete this later.)
- You should see and hear the Dragonforge splash screen. (You can delete this later.)
- The main screen should load and the Dragonforge Theme Song should play.
- Press the New Game button.
- A game scene will load with the Godot background and a red Godot logo. You should also hear game music.
- Using the arrow keys or gamepad left joystick will move the red Godot logo.
- Pressing the Escape key or Start button on your gamepad will pause the game and show the main menu.
The folder found at res://example_3d/ contains example code for a 3D game.
- Copy the
example_3dfolder from the root of this project to your project. - In your project open
res://addons/dragonforge_game_template/game_configuration.tscn(You should have already copied this over during installation.) - In the Inspector under GameConfiguration select the File button next to Main Scene.
- In your project browse to
res://example_3d/game_template_files/main.tscnand select it. - Press Ok.
- In the Inspector under GameConfiguration select the File button next to Game Scene.
- In your project browse to
res://example_3d/game_template_files/game.tscnand select it. - Press Ok.
- Go to Project -> Project Settings...
- Select the Plugins tab.
- Uncheck the On checkbox under Enabled for Dragonforge Game Template
- Check the On checkbox under Enabled for Dragonforge Game Template
- Press the Close button.
- Save your project. (You do not need to reload the project at this time despite the warning message.)
- Press the Run Project button (or use F5). The game will start.
- You should see and hear the template default Godot splash screen video. (You can change or delete this later.)
- You should see and hear the Dragonforge splash screen. (You can delete this later.)
- The main screen should load and the Dragonforge Theme Song should play.
- Press the New Game button.
- A game scene will load with an box of grey and brown, and a 3D Godot logo robot. You should also hear game music.
- Using the arrow keys or gamepad left joystick will move the Godot robot. (There are no animations.)
- Pressing the Escape key or Start button on your gamepad will pause the game and show the main menu.
Extends Node2D (can easily be changed to extend Node3D.) It can be used as a base for your own levels.
spawn_point: Node2DA Node2D that is used for spawning the player if they do not have one. (Typically the starting point for the game. This can easily be changed to a Node3D. and used the exact same way.level_music: SongA Song can be added here and will automatically begin playing when the level loads, and paused when the game is paused. Note Song is a Resource in the Sound plugin. This can easily be changed to an AudioStream.
Located in res://addons/dragonforge_game_template/, this node is just an interface to make it easy to change your game's Game autoload and Main scene. Both of these default to the versions in res://addons/dragonforge_game_template/.
To update the Game autoload and customize it do the following:
- Following the installation instructions and reload the project.
- Copy
game.tscnandgame.gdfromres://addons/dragonforge_game_template/into your project. - Open
game.tscn. - Click one the Game node.
- Click the Detach the script from the selected node. button. (Icon is a script with a little red x on it.)
- Click the Attach a new or existing script to the selected node. button. (It's the same button, but now the icon is a script with a little green plus on it.)
- Select the
game.gdscript you copied. (If you don't do this changes to the script will get overwritten when you update.) - Open
res://addons/dragonforge_game_template/game_configuration.tscn - In the Inspector under GameConfiguration select the File button next to Game Scene.
- Browse to the location where you put your version of
game.tscnand select it. - Press Ok.
- Go to Project -> Project Settings...
- Select the Plugins tab.
- Uncheck the On checkbox under Enabled for Dragonforge Game Template
- Check the On checkbox under Enabled for Dragonforge Game Template
- Press the Close button.
- Save your project. (You do not need to reload the project at this time despite the warning message.)
To update the Main scene that is started with the game and customize it, follow the instructions below. Note that you can do the same thing if you have your own scene you want to use as the start of your game instead, just skip to step 8. This will allow you to use that scene and ignore the scene the plugin tries to set.
- Following the installation instructions and reload the project.
- Copy
main_template.tscnfromres://addons/dragonforge_game_template/into your project. (We suggestres://game_template_files/) - Rename
main_template.tscntomain.tscn. - Open
main.tscn. - Rename the root node from MainTemplate node to Main.
- Click on the Main node.
- Click the Detach the script from the selected node. button. (Icon is a script with a little red x on it.)
- Click the Attach a new or existing script to the selected node. button. (It's the same button, but now the icon is a script with a little green plus on it.)
- Create a
main.gdscript. (If you don't do this changes to the script will get overwritten when you update.) - Add the following code to the script:
class_name Main extends MainTemplate. (Delete all other code.) - Open
res://addons/dragonforge_game_template/game_configuration.tscn - In the Inspector under GameConfiguration select the File button next to Main Scene.
- Browse to the location where you put your version of
main.tscnand select it. - Press Ok.
- Save your project. (You do not need to reload the project at this time despite the warning message.)
NOTE: This is no different than setting the value in Project Settings -> Run, however setting it here will retain the value if you update or disable/re-enable the plugin.
- Open up your copied version of
main.tscn. - Select the Splash Screen state node under Game State Machine.
- In the Inspector, expand the Active Splash Screens array.
- Add or remove SplashScreen nodes and/or change the order in which they appear.
- To make your own custom splash screen, copy any of the existing screens and add them.
- Delete any splash screens not needed. (They won't show up, but deleting them reduces the footprint of your initial load.)
- Open up your copied version of
main.tscn. - Select the Main Menu state node under Game State Machine.
- Add a new background using Control (UI) nodes.
- In the Inspector, replace the Background variable with a reference to the root of your new background.
By default, the Game autoload scene is loaded from the addon folder. res://addons/dragonforge_game_template/game.tscn This template inherits from GameBase. The reason for this is you will likely want to add your own custom signals, variables and even functions to Game. You can do this by copying the scene and script to somewhere in your project, and editing them. See Game Configuration for how to load your custom Game scene as the autoload..
signal splash_screens_completeSplash screens have completed or been skipped.signal start_cutscene(cutscene: String)Tell a cutsene to start.signal cutscene_finishedCurrent cutscene has finished.signal load_level(level_name: String, player: Node, target_transition_area: String)Load the passed level. (Null can be passed for the player and transition_area.)
is_loaded: bool = falseWhether or not game is loaded.in_progress: bool = falseStarts out false. Becomes true when a new game is started, or a game is loaded. Saved to disk.level_path: StringPath for loading the next level. Saved to disk.
Most of these functions are convenience methods, as they just call get_tree(). However they have been implemented to make code clearer. Also, the quit method actually sends out a quit signal before calling get_tree().quit(), just as if the user had closed the window.
quit() -> voidQuits the game, after notifying all nodes, which allows save on quit functionality. This should be used instead of get_tree.quit()pause(pause: bool = true) -> voidPauses or unpauses the game based on the boolean sent. Defaults to pausing the game. (Convenience method.)unpause() -> voidUnpauses the game. (Convenience method.)is_paused() -> boolReturns whether or not the game is paused. (Convenience method.)
This scene, found at res://addons/dragonforge_game_template/main.tscn, is intended to be made the Main Scene. The plugin does this automatically. To load your main game scene, add it to the starting_level export variable. NOTE: You may want to copy this scene or inherit from it and place it somewhere else so that future changes you make are not overwritten by new versions of this plugin. See Game Configuration for how to load your custom Main scene to be compatible with plugin updates.
starting_level: StringThe first game level to load and attach to the UI's start button. You can either paste in a path to the scene, or press the Open a File dialog button to the right of the text field and browse to the starting scene.bypass_splash_screens_during_debug: bool = falseThis is here in case we aren't allowing the player to skip the splash screens but we want to do so for testing. (See also GameStateSplashScreen.splash_screens_are_skippable.) It only affects debug builds of the game.
The Game State Machine is an unmodified StateMachine. It has a number of custom States however. It comes configured to start the GameStateSplashScreen State, but that can be changed if desired.
This State handles playing all the splash screens in order, as will as handling requests from the skip action. This State is intended to run while the rest of the game is loading, and as such, it breaks the rules and has a _ready() function implementation. This is not best practice for State nodes, as it can lead to race conditions. You have been warned.
active_splash_screens: Array[SplashScreen]All the splash screens to show, and the order to show them in. Add any SplashScreen nodes you want shown at the beginning of the game. Leaving this blank will cause the splash screen state to be skipped.splash_screens_are_skippable: bool = trueIf true, you can skip the splash screens using theskipaction (which is automatically added when this plugin is activated) as long as you have viewed them once. See GameStateSplashScreen.splash_screens_viewed variable for more information. See also: Main.bypass_splash_screens_during_debug variable.splash_screens_viewed: bool = falseStores whether the user has seen the splash screens before. Saved to disk. Once this value is true, and as long as splash_screens_are_skippable remains true, the player may skip splash screens using theskipaction (which is automatically added when this plugin is activated). This value resets to false ifconfiguration.settingsis deleted in the UserData folder. See also: Main.bypass_splash_screens_during_debug variable.
SplashScreen nodes are configured to be easy to implement and run. Currently there are 6 exmaples under the GameStateSplashScreen node. Two are Godot splash screens that use videos; one is the Dragonforge Development splash screen; and three are Game Jam splash screens. All are provided as examples. Only splash screens that are added to the GameStateSplashScreen's' active_splash_screens array will be run. Once you have figured out which ones you want, you should delete the ones you don't need. You can also delete any files you don't need in res://addons/dragonforge_game_template/assets/video/ and res://addons/dragonforge_game_template/assets/textures/ - or exclude them from the export.
When making your own SplashScreen, it should be a child node of the GameStateSplashScreen like the others. The reason for this is once the splash screens are done playing (or skipped), the are deleted to save memory.
This state handles level loading. It is entered when a level is requested to be loaded by emitting the Game.load_level signal. Once it starts, it displays a progress bar as the level loads. That scene can be edited by changing the Loading Screen CanvasLayer and children beneath it. It is recommended that you change the background, but not necessary.
It should be noted that the GameStateGameplay node is the one that actually starts the level once it is loaded, and so GameStateLoading has no control over when it is exited.
While the player is playing the game, this is the active state. Also note that while GameStateMainMenu, GameStateCutscene, and GameStateDialogue can run on top of this, even while paused GameStateGameplay stays visible.
This State starts monitoring when a level is requested to be loaded by emitting the Game.load_level signal. Then, once the loading is complete, this State takes over and actually starts the loaded level. The other way this State is entered is when the game is paused and the pause action is received. In which case the game is unpaused and this State is entered.
This State monitors the Game.splash_screens_complete signal and takes over immediately. It is also entered when the game is unpaused and the pause action is received. In which case the game is paused and this State is entered.
GameStateMainMenu contains the game background for when the start menu loads. Changing that allows you to create a dynamic background, or just change it from the Godot logo. It also contains all of the menus as part of the UserInterace node.
This project's UI has been created to work with localization. You can easily use localization by using the Dragonforge Localization plugin. The following labels exist and should be given translations:
- VOLUME
- MAIN
- MUSIC
- SOUND_EFFECTS
- DIALOGUE
- BACK
- DISPLAY_SETTINGS
- MONITOR
- FULLSCREEN
- RESOLUTION
- ZOOM_SCALE
- ACTION
- KEYBOARD
- MOUSE
- RESET
- SONG_TITLE
- ARTIST
- ALBUM
- PLAY
- NEXT
- PREVIOUS
- PAUSE
- NEW_GAME
- SETTINGS
- MUSIC_DISPLAY
- CREDITS
- QUIT_GAME
- RESUME_GAME
- RESUME_SAVED_GAME