Create a new scene and make the root a default Node. Add a sprite and name it wall. The texture will be a differently colored 16*16 block that I will include below. Save it into a new folder called “tiles.”
Underneath the wall node add a StaticBody2D, and underneath that, a CollisionShape2D. Give it a RectangleShape2D in the inspector, click it, and set its extents to (8,8). Now go up to Scene>Convert To..>Tileset.. and save it as “wall.tres” in the tiles folder.
Create a new scene and have the default Node as its root. Rename it to test. Save this scene to a new folder called “areas.” Under the root, add a TileMap node. Look in the inspector and set the Tile Set to the walls.tres we just created. Expand the Cell section and set the Size to (16, 16). Draw frame of walls inside the border on the screen. Lock the TileMap node so you don’t accidentally keep clicking it when moving things around in this scene. Now add the player.tscn from our player folder to the scene and move it inside of our frame.
Press F5. It should ask you to set the default scene, which we will set to test.tscn. The game will open and you should be able to move around and collide with walls.
That is all this first tutorial is going to cover. The next one will be on walk and push animations. Here is a quick preview on what we will have:
I hope you found this series useful. Check out the video version of the series here. The text versions will catch up soon.
If you want to support me, please pledge to my Patreon! Patreon is what makes these text tutorials happen. A few dollars every month really helps a broke student like me to keep developing these tutorials.
See you next time!