This be a machine-translated text that might contain errors!
Where be this information cominâ from?
Much oâ this be just a tellinâ oâ Godotâs official documentation. Below yeâll find some useful links to the official documentation (which I mostly recommend over this one on Piggy, but if ye prefer this one, then just use it!)
Useful Booty:
What about graphics, do I need to make âem meself?
Nay! Ye can find a heap oâ free assets here:
Other Useful Links:
Other game engines, aye?
If ye be preferrinâ, ye can use other game engines, savvy? Examples oâ other game engines be:
There be many other as well, search âround if ye be wantinâ to try somethinâ else, arr!
What be Godot?
Godot (Pronounced Guh-doh), be a âGame Engineâ. To put it simple, âtis a program what lets ye make games (or regular programs if ye be so inclined). Godot can do most anythinâ other game-engines can do, both 2D and 3D.
Examples oâ games made in Godot: Godot Showcase
âTis not just Indie games whatâs been made in Godot, Sonic Colors Ultimate be made with Godot!
How Do Ye Get Yer Hands on Godot?
Ye can either download Godot from:
- The official page: Godot Official Page.
- Or on Steam: Godot Steam.
Just download and install (or run on steam).
Set Up a Project!
When ye start Godot, ye get this window:
Here ye be asked about the programming language, GDScript or C#. GDScript be mighty like Python.
Differences âtween GDScript and Python (without colors):
def hello():
text = "Hello world!"
print(text)
func hello():
var text = "Hello world!"
print(text)
For variables in Python, ye just need to write the name oâ the variable. In GDScript, ye must write var
first. To make functions, ye write func
instead oâ def
.
Scenes & Nodes
One oâ the most important concepts within Godot be Scenes and Nodes. We can begin with nodes. A node be an object in Godot, and it can represent anythinâ. It can be somethinâ representinâ a player, a foe, a button in a menu, text on the screen, anythinâ at all. Scenes be a collection oâ nodes.
Here we be makinâ a very simple example.
Part 1a - Set Up the âPlayerâ Scene
At the top oâ the Godot window, press the â2Dâ button to change the view to a 2D view.
On the left side oâ the window ye see the followinâ interface:
Press the âOther Nodeâ button, anâ search fer âCharacterBody2Dâ, choose it, anâ press âCreateâ. This be a node that be used fer a 2D player. Ye might see that there be a warninâ triangle â ď¸ beside the âCharacterBody2Dâ node. This be âcause it be missinâ some things it be wantinâ.
If ye right-click on the node, there be a â+ Add Child NodeâŚâ button. Use this anâ add two nodes, Sprite2D anâ CollisionShape2D. Sprite2D be used to add some graphics to the player, while the other be used to check fer collisions. Ye can also give âem names if it makes it easier to keep track oâ things. Iâve given me CharacterBody2D the name âPlayerâ. This be how the scene should look now:
Part 1b - Fixinâ â ď¸ on CollsionShape2D
The warninâ triangle in this case be that the CollsionShape2D be lackinâ actual collision. Ye can fix this by thrashinâ on the node (to the left), then a panelâll pop up on the right side. Here yeâll get a heap oâ information âbout the node ye can change. Feel free to mess âround with it. But the one weâll be focusinâ on be âShape,â set this to, say, RectangleShape2D. It ainât so very important, we ainât gonna be usinâ the collisions here.
Part 1c - Addinâ a Sprite, Graphic
If ye click on Sprite2D to the left, yeâll get the field to the right, where it says âTextureâ. Here be where ye can put in a picture fer the player. Just drag a picture in anâ drop it in the field.
This be how itâll look after yeâve added a sprite.
Part 2 - Addinâ Input, Checkinâ
At the top oâ the window be a menu, âScene - Project - Debug - Editor - Helpâ. Press on âProjectâ anâ dretter âProject Settingsâ. Here ye get a menu with a heap oâ settings. Press on âInput Mapâ. Here ye can set up buttons on the keyboard.
- In the âAdd New Actionâ field, write âleftâ then press âAddâ.
- Dretter add ârightâ, âupâ anâ âdownâ.
- These be known as âActionsâ
- On each âActionâ ye can add buttons by pressinâ on the + button to the right.
- Here it be just to press on the keyboard, then press Add.
- Add buttons to all actions.
Part 3 - Addinâ a Script tâ Control the Player.
Tâ be able tâ add game logic, that be doinâ somethinâ with the player, the background, or whatever it be in the game, we need a script. Scripts be code, and can be written in two languages, GDScript or C#, GDScript be the default.
- Press on the âCharacterBody2Dâ (Iâve called it âPlayerâ) node.
- Press on the âAttach Scriptâ button (see below)
- Here ye get a window where ye can choose the language (choose GDScript) and a path (just let it be called what it be, but ye can give it a name), then press onward. Here ye get a âScriptâ window. Not much be standinâ here tâ begin with.
extends CharacterBody2D
# Dette er en enkel karakterkontroller
# This be a simple character controller
# Hastighet for bevegelse
# Speed fer movin'
var speed = 200
The only thing this code says at the moment is that the code shall belong to a node oâ the type âCharacterBody2Dâ, which be our player.
We be addinâ a function here that we be usinâ to manipulate the player:
extends CharacterBody2D
func _physics_process(delta: float) -> void:
# Dette er en tom funksjon.
# This be a empty function, aye.
return
Physics Process?
_physics_process
be a function that updates every single âframe,â aye, âround 60 times a second (default). There be another function just called _process
, which updates the whole way. If ye want the player to move at a steady pace, use _physics_process
.
Aye, âtis here we be addinâ code that moves the player.
Part 4 - Basic Input
In part 2 ye added input buttons, now we be usinâ âem. There be a built-in object called Input
that we can use to check if the player has pressed what we set up in âInput Mapâ.
Try to put this code in the _physics_process
code:
if Input.is_action_pressed('right'):
# Her settes farten til høyre
# Here be settin' the speed to starboard
velocity.x = 100
move_and_slide()
What be move_and_slide()
?
move_and_slide()
be a built-in function in Godot, used when we be wantinâ to actually move what we be usinâ it on. Without this, the player wonât be movinâ.
Warning
The spaces âtween the lines be mighty important, aye, just like in Python.
What be happeninâ when ye start the program by pressinâ the play-button in the Godot window, then pressinâ ârightâ?
If nothinâ be happeninâ now:
- Be ye remember to set up somethinâ in the âInput Mapâ?
- Be ye wrote
right
and notRight
? Aye, be it what ye wrote in the code the same as the name in the input map?
The whole code thus far
extends CharacterBody2D
func _physics_process(delta: float) -> void:
if Input.is_action_pressed('right'):
velocity.x = 100
move_and_slide()
Aye, now try tâ add code fer 'left'
, 'up'
, 'down'
.
What must velocity.x
be fer left
? What âbout up
anâ down
?
The whole code now
extends CharacterBody2D
func _physics_process(delta: float) -> void:
if Input.is_action_pressed('right'):
velocity.x = 100
if Input.is_action_pressed('left'):
velocity.x = -100
if Input.is_action_pressed('down'):
velocity.y = 100
if Input.is_action_pressed('up'):
velocity.y = -100
move_and_slide()
Part 5 - Fixinâ the Code
Ye might be noticinâ that the player donât stops when ye lets go oâ a direction. We can fix that now!
âFore all the if
-s, add a line that sets velocity to 0. Ye can do that by writinâ velocity = Vector2()
All speeds and directions in Godot be vectors, this be a math-concept we ainât gonna be goinâ into now, but if ye be wonderinâ more âbout what this means, ye can go here: Wikipedia vectors.
The whole code now
extends CharacterBody2D
func _physics_process(delta: float) -> void:
velovity = Vector2()
if Input.is_action_pressed('right'):
velocity.x = 100
if Input.is_action_pressed('left'):
velocity.x = -100
if Input.is_action_pressed('down'):
velocity.y = 100
if Input.is_action_pressed('up'):
velocity.y = -100
move_and_slide()
When ye start the game now, ye can move the player around:
Further on, ye can fix the code to make the speed not just a number, but can be stored elsewhere.
Ye can fer example (before the function) add a constant to keep track oâ the speed.
The whole code at the end with const
extends CharacterBody2D
const SPEED = 100
func _physics_process(delta: float) -> void:
velovity = Vector2()
if Input.is_action_pressed('right'):
velocity.x = SPEED
if Input.is_action_pressed('left'):
velocity.x = -SPEED
if Input.is_action_pressed('down'):
velocity.y = SPEED
if Input.is_action_pressed('up'):
velocity.y = -SPEED
move_and_slide()
Part 6 - Play âRound Yeâ Own!
If ye be headinâ back to the first part, Helpful Resources, ye can find what ye can continue to play with.
After that, ye can try to make yer own game. What ye make be up to ye! If ye want to make somethinâ brand new, do it! If ye want to try to copy a game that already exists, do it! The best way to learn be to try!