Skip to content

hatmix/godot-4-jam-template

Repository files navigation

Godot 4 Jam Template

An opinionated quick-start Godot 4.4+ template for game jams. See the plain template in action at https://hatmix.itch.io/godot-4-jam-template (password hatmix).

A styled and modified example (for Godot 4.3) can be found at https://hatmix.itch.io/game-jam-starter-template. This is an example of what the template can look like with customization. The code can be found in the release-promo branch.

Features:

  • Web, Windows, Linux and macOS exports configured for maximum jam
  • Github workflows for automatic uploads to Itch.io
  • Premade basic UI for main menu, pause menu, credits, settings, and remapping controls
  • G.U.I.D.E for input and input prompts
  • Settings persisted across sessions (where user:// filesystem is writable)
  • Full keyboard and controller support for all template UI
  • ATTRIBUTION.md for in-game credits (inspired by Maaack's approach)
  • TODO Manager included and todos added for setting up a new project

Don't just settle for the first template you find! This template was inspired by many other examples created by the Godot community. Compare the alternatives and decide which best fits your desired feature set, coding style, and approach to game development.

Alternatives:

This template is intended to be used at project start. While it is possible to apply updates made to the template to projects created from earlier versions of the template, it is not designed for that. Other templates may be easier to upgrade or add to an existing project.

Getting started

There are a few ways to get started.

  • The "Use this template" link in Github
  • Clone the repository
  • Download a zip file of the source

Once the Godot project files are saved locally, open res://game/game.tscn and create your game!

Folder structure

res://autoloads/ contains scripts added to the Godot project's globals/autoloads. (See section Settings Persistence)

res://exports/ has folders for each pre-configured export platform

res://game/ you should build a game in here

res://input/ contains a default G.U.I.D.E action and context mapping. (See G.U.I.D.E documentation for how to add new actions, etc.)

res://media/ is intended for screenshots and other items used for documentation or the Itch.io page for the project. (See section Publishing on Itch.io)

res://test/ holds automated test scripts.

res://ui/ is where most of the template's work is done (See section UI).

res://ui/game/ is intended for the game UI/HUD and what comes with the template should be replaced when building your project.

It's up to your preference and the type of project whether the separation of res://ui/game and res://game makes sense.

Tip

Save a some time while developing the game by changing Project Settings: application/run/main_scene to res://game/game.tscn. Then, change it back to res://main.tscn when the game is done. Or maybe don't. Follow your heart.

UI

The main UI scene treats its direct children extended from UiPage as components to show or hide. They might be an entire screen or just a widget in the corner. The main UI scene includes basic UI for all of the template's menus, a stub in-game UI with pause screen, and Maaack's ProjectUISoundController.

Main UI components are contained in directories under res://ui.

└───ui
	├───assets
	│   ├───audio
	│   ├───fonts
	│   └───icons
	│       └───notifications
	├───build_info
	├───controls
	├───credits
	├───game
	├───how_to_play
	├───main_menu
	├───notifications
	├───pause_menu
	└───settings

The assets folder is for non-scene/non-code files used in the UI.

The intended approach is to keep all UI in res://ui/ui.tscn and instantiate it as a child of every other root-level scene.

The UI canvas layer is set PROCESS_MODE_ALWAYS with children inheriting the mode. The InGameMenuOverlay will appear when get_tree().paused == true. In games where pausing the tree should not hide the game area, either remove that node or have the PauseMenu show and hide the overaly.

The project default theme is res://ui/ui_theme.tres generated by ThemeGen and res://ui/ui_theme.gd. Variant styles are used for UI notifications and remapping controls.

Input icons are generated by G.U.I.D.E and displayed by a RichTextLabel.

UI Navigation

The template UI is designed to work with keyboard, controller, and touch input as well as mouse. Tab and shift+tab move focus. Any controller input will grab focus except where this is prevented with UiPage.prevent_joypad_focus_capture which is used by the game ui page.

Settings Persistence

Settings are saved in user://settings.cfg and control mappings in user://controls.tres. Saving and loading are handled by res://autoloads/settings.gd.

Todo and Fixme comments

Stay organized with TODO and FIXME comments in scripts and markdown files. Add your own special comments per TODO Manager's documentation.

Tests

gdUnit4 is used for testing.

Github Workflows (CI/CD)

Don't struggle to export games in the last hour before the submission deadline. Use Github workflows to do all of that for you!

The template includes Github actions for running tests and optionally deploying to itch.io. The tests workflow runs on every push to every branch. Deploy runs after successful test runs on the main branch.

On succesful export, and if configured, the deploy workflow uses butler to deploy the game to itch.io. Setup these secrets in your Github repository to enable push:

  • ITCHIO_USERNAME
  • ITCHIO_GAME
  • BUTLER_API_KEY

Note that for butler uploads to work, the game page must already be created on Itch.io with one file manually uploaded. After that, butler can perform all the updates. (See butler's documentation)

The file res://version.txt is used as a version or build identifier in the main menu. This file is generated by the deploy workflow if not already present in source control. Automatic versioning is based on number of git commits. You can maintain the res://version.txt manually whether using source control or not. See the files at res://ui/build_info/.

Publishing on Itch.io

Publishing your game on Itch.io is not the end of your jam journey. A good looking game page will create a strong first impression before your game is played. Jannik Boysen's Easy-Releasy .png templates are included in the media folder to simplify making a great looking page for your game.

About

Godot 4 Jam Template

Topics

Resources

License

Stars

Watchers

Forks

Languages