Coder Social home page Coder Social logo

godot-game-template's Introduction

game-template-overview

๐ŸŒŸ You make games, the template handles the boring stuff.

Godot Download badge GitHub release (latest by date)

Godot Game Template is a generic starter project for Godot games.

Its main focus is to provide a solid base to build upon.

Get started

You have 2 options:

1. Get started with Github Templates:

  1. Create a new repo using this template
  2. Clone the new repository locally
  3. Open the project in Godot (GDScript)

2. Get started with a local project:

  1. Go to https://github.com/crystal-bit/godot-game-template/releases
  2. Download Source code (zip)
  3. Unzip the project
  4. Open the project in Godot Engine (GDScript) and create your game!

Used by

Logo Godot Title Link
YouAreUto icon 3.x YouAreUto (2019) Android, iOS, GitHub
Defending Todot icon 3.x Defending Todot (2020) HTML5, GitHub
Karooto No Gase icon 3.x Karooto No Gase (2021) Android, Itch.io
Godot Game Template Demo 3.x demo-godot-game-template (2021) Android, GitHub

Get in contact if you want to be featured here!

How to...

Change scene

Game.change_scene("res://scenes/gameplay/gameplay.tscn")

change_scene

Change scene and show progress bar

Game.change_scene("res://scenes/gameplay/gameplay.tscn", {
  "show_progress_bar": true
})

progress

Change scene and pass parameters

# you can pass whatever value you like: int, float, dictionary, ...
var params = {
  "level": 4,
  "skin": 'dark'
}
Game.change_scene("res://scenes/gameplay/gameplay.tscn", params)
# gameplay.gd

func pre_start(params):
   print(params.level) # 4
   print(params.skin) # 'dark'
   # setup your scene here

_ready() vs pre_start() vs start()

They are called in this order:

method description
_ready() gets called when the graphic transition covers the screen
pre_start(params) gets called immediately after _ready, it receives params passed via Game.change_scene(scene_path, params)
start it's called as soon as the graphic transition finishes. It's a good place to activate gameplay logic, enemy AI, timers, ...

Restart the current scene

Game.restart_scene() # old params will be reused

Restart the current scene and override params

var new_params = {
  "level": 5,
}
Game.restart_scene_with_params(new_params)

Center a Node2D into the viewport

$Sprite.position = Game.size / 2
# Game.size it's just a shortcut to  get_viewport().get_visible_rect().size

Conventions and project structure

  • assets/
    • Contains textures, sprites, sounds, music, fonts, ...
  • builds/
    • output directory for game builds (ignored by .gitignore and .gdignore)
  • scenes/
    • Contains Godot scenes (both entities, reusable scenes and "game screen" scenes)
    • Scene folders can contain .gd scripts or resources used by the scene

Mostly inspired by the official Godot Engine guidelines:

  • snake_case for files and folders (eg: game.gd, game.tscn)
  • PascalCase for node names (eg: Game, Player)

Lower Case file names

This convention avoids having filesystem issues on different platforms. Stick with it and it will save you time. Read more here:

Windows and recent macOS versions use case-insensitive filesystems by default, whereas Linux distributions use a case-sensitive filesystem by default. This can cause issues after exporting a project, since Godot's PCK virtual filesystem is case-sensitive. To avoid this, it's recommended to stick to snake_case naming for all files in the project (and lowercase characters in general).

See also this PR that adds is_case_sensitive().

Export utilities

release.sh

From your project root:

./release.sh MyGameName # this assumes that you have a "godot" binary/alias in your $PATH

Look inside the ./builds/ directory:

builds
โ””โ”€โ”€ MyGameName
    โ”œโ”€โ”€ html5
    โ”‚ย ย  โ”œโ”€โ”€ build.log # an export log + build datetime and git hash
    โ”‚ย ย  โ”œโ”€โ”€ index.html
    โ”‚ย ย  โ”œโ”€โ”€ ...
    โ”œโ”€โ”€ linux
    โ”‚ย ย  โ”œโ”€โ”€ MyGameName.x86_64
    โ”‚ย ย  โ””โ”€โ”€ build.log
    โ”œโ”€โ”€ osx
    โ”‚ย ย  โ”œโ”€โ”€ MyGameName.dmg
    โ”‚ย ย  โ””โ”€โ”€ build.log
    โ””โ”€โ”€ windows
        โ”œโ”€โ”€ MyGameName.exe
        โ””โ”€โ”€ build.log

Github Actions

If you are using Github you can take advantage of:

  1. automatic exports for every commit push (see push-export.yml)
  2. manual exports via Github CI (see dispatch-export.yml )

You can read more on Wiki - Continuos Integration

Contributing

If you want to help the project, create games and feel free to get in touch and report any issue.

Discord

You can also join the Discord server (#godot-game-template channel).

Before adding new features please open an issue to discuss it with other contributors.

Contributors

Many features were implemented only thanks to the help of:

Also many tools were already available in the open source community, see the Thanks section.

Thanks

godot-game-template's People

Contributors

davcri avatar andrea-miele avatar securityrisk avatar mashumafi avatar andrea1141 avatar fahien avatar idbrii avatar jrassa avatar microwonk avatar vini-guerrero avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.