Your first game on Godot Engine

1. Foreword

Hello, in this article I want to introduce you in the most concise form to the basics of creating simple 2d platformers using the Godot engine. Sometimes we will dwell on some important points, and sometimes skip information that you do not need at the initial level.





2.Let's start!

I think it won't be difficult to install the engine itself. After installation, open it and click on the "new project" button.





Project creation.
Project creation.

. «» «OpenGL ES 3.0», opengl, . .





3.

2D scene in Godot Engine.
2D Godot Engine.

, ! , . , , , , . 3d , , 2d. . , ? , ( , - , ).





4. Godot

, - , ? Godot , .





Explorer in Godot Engine.
Godot Engine.

, , . ! , ( , ). , ., . ! ! , ! , .





.





5.

Creation of new scenes.
.

. , «». ! , , «ctrl + A». , «Node». , «World», . . !





«Sprite», ! ! ! , «Sprite», «KinematicBody2D».





:





Add a player.
.

, «KinematicBode2D» - . ? , , Godot . , ( «KinrmaticBode2D» «Player» ). «Player» «ctrl + A» «Sprite». «CollisionShape2D». :





Add player borders to the sprite.
.

, . . «Sprite», «Player.png»( ) «Texture». , , Godot «», «Flags» «Filter» «». , Godot.





, , .





Add a texture to the player sprite.
.

? , . «» «Hframes», ( 25). , ?





We set the boundaries of the sprite.
.

, ! CollisionShape2D? «Shape» « RectangleShape2D». . :





CollisionShape2d.
CollisionShape2d.

6. Godot

, Godot . , «Player» . ? , . «Player» « , ».





Creating a scene from a branch.
.

«Player» , ! :





— .





7. , GDscript

- :





Create a script.
.

:





Player script.
.

«» Godot. , . , . ! ? , , , . — .





Simple controls.
.

, . Godot, «KinematicBody2D». . 3 4 , . . 6 . 8 «physicsprocess», . , . - . 9 X. Input ( ). 11 - . .





, - delta. , delta? Delta ( , float) . ? , . , , . delta!





13 - clamp. ! , clamp, , «» . . . !





8. .

, ? ! , F5, , , . — World.tscn. F5. - :





Demo window.
.

. . . , «», « ». «Window» 320x180. ? , , . . «Test Width» «Test Height». 1280x720. «Mode» «2d», «Aspect» «keep». . , . , .





, ? . ? , . , . , . !





9.Tilemaps

«Tilemap»? — , . . ? , «World»( ), «ctrl + A» «TileMap».





«Tile Set» « TileSet». «TileSet», - :





Add animation.
.

tilemap, «tile.png».





, . , «» , «snap options» step x y 16. , , , . .





. . .





We set the boundaries of the tile.
.

, . Tilemap «Cell» size 16x16. !





Create a simple level.
.

. , , . player .





Jump and gravity constants.
.

friction, gravity, jumpforce, airresistance. , .





Jump and gravity implementation.
.

. motion.y , delta. , . , ( ). , .





, ! . , - .





What it looks like at startup.
.

10.

Godot . player «AnimationPlayer». «», «» . «Run». «sprite».





Adding frames to animation.
.

«frame» , , . frame 0 8 . :









Create animation from frames.
.

, . — , , idle. . player :





Add variables for animation.
.

sprite player. , - . onready, ? . onready . .





Walking animation.
.

16- . - 22 , ? , . 24 , , idle.





Jump animation.
.

35 , . .





If you did everything right, then you should have a simple platformer. What to do next? Anything! Improve your skills in using the engine, create your own games, learn new features. On this I have to say goodbye to you, I hope you had a good time and learned something new.





Here are all the materials for this tutorial:












All Articles