Saturday, 6 May 2017

Gitting Gud At Godot - Part 1 - Introduction to Godot


You can find the video version of this post below:



In this post, I'm going to help get you into the basic thought processes that are vital to understanding the engine.


First and foremost, Godot is a visual editor. This means that a lot of the development is done by using the mouse to graphically manipulate on-screen elements, which will more or less appear in-game as they appear in the editor.

This is what Godot's UI looks like:


I'll explain each of the important areas in due course, but let's start with one of the most important concepts in Godot- "nodes".

If you've used a visual editor such as Unity before, the concept of nodes shouldn't be too foreign. Nodes make up the basis of your entire workflow in Godot. They can be compared to ingredients in a meal. Where a soup might contain broth and carrots, a game in Godot might contain Sprites and PhysicsBodies (and probably a lot more).

Furthermore, nodes in Godot are organized in a kind of tree structure. You have one "tree root" node, and then several other nodes which branch off of that. If you've ever tried to save an empty scene and received the message "This operation can't be done without a tree root", this is what I'm talking about.

In order to add a tree root node, you can navigate to the "Scene" tab and select the "+" button. This will open a dialogue box where there are about a billion nodes to choose from.



Don't be intimidated, you don't need most of them(yet)! You may notice that the nodes are already organized in a tree structure, where certain nodes can be expanded to reveal further nodes. This is done to show the way that nodes inherit each other's qualities.

For example, CanvasItem is the base class for a generic node which draws to the screen. Inside CanvasItem you can see Control and Node2D. Control is for the UI - menus, buttons, dialogue boxes, etc - while Node2D is for the (2D) objects which are drawn to the screen, such as sprites. Because of this, objects which are not drawn to the screen(such as ResourcePreloader) are not children of CanvasItem.




For now, let's add a node of type Node as our tree root. You do this by selecting "Node" at the top of the list, and either double clicking it or selecting "Create" at the bottom right.

Hopefully, a node named "Node" should appear as our tree root in the Scene tab.

The Scene tab keeps track of all of our nodes. It lists them in a tree structure, similar to the "Create New Node" dialogue from earlier, except this structure can be adjusted based on your needs.





We'll come back to what we can do with this node in the next tutorial. For now, let's take a look at the Inspector tab just below.




This tab allows us to view and edit our node's properties. Since this is the base class for all other nodes, it doesn't have very many built-in properties. The two properties listed are "Pause Mode", and "Script".

"Pause Mode" refers to what this object does when the game is paused. Don't worry about this too much for now.

"Script" is where Godot gets interesting. We'll cover it more closely in another tutorial, but this property allows us to attach extra code-based functionality to our node.










This is the FileSystem tab. This allows us to see the file structure of our project clearly. It's not particularly complicated, and it doesn't have much special going for it.

One thing to note is that the root folder of your project is referred to by Godot as "res://". This stands for "resource", and is used as the reference point for Godot to access all of your images, sounds and other fancy things you might put in your game.

The top section only shows you the folders in your project. If you want to see what is contained in each folder, you have to select the folder and its contents will show up in the bottom section. By default, Godot's mascot is in the "res://" folder, in a file named "icon.png".







Lastly, let's look at the top bar of the editor. None of this is particularly complicated, but it's worth referencing for completeness.

Starting on the left, "Scene" is the equivalent of a word processor's "File" dropdown menu. It allows you to save scenes, open scenes, quit the editor entirely or change project settings. That last one is going to come in quite handy later on.

"Import" allows you to import resources and files from outside of your project folder, or to convert things such as .ttf fonts into something that Godot can understand.

"Tools" quite frankly isn't that useful.

"Export" does what it says on the tin and will export your game to Windows, Linux, OSX, HTML5, Android and experimentally Blackberry 10.

The 4 options "2D", "3D", "Script" and "AssetLib" change the scene view area between either 2D mode, 3D mode, script editing mode or the asset library. For most of these tutorials, it'll be on either 2D or Script mode.

In the center are the buttons to play your game, and on the right there is the "Settings" button which allows you to adjust the editor settings.

That's all for this tutorial, since I don't want to overload you with information. Thanks for reading, and stay tuned for Part 2, on the topic of "Nodes"!

Find Part 2 here: http://alexhoratiogamedev.blogspot.com/2017/05/gitting-gud-at-godot-part-2-nodes.html

Addendum

The reason I have decided to make these tutorials is because Godot's available tutorials simply aren't good enough. The popular GamesFromScratch tutorials for Godot are poorly written, poorly paced and exhibit a poor use of the engine. Also, I genuinely want to see this engine succeed and getting more people to use the engine can only mean good things for its future.

Plus, it's free publicity. Who am I to complain?

No comments :

Post a Comment