Skip to content

4. Creating a Project

Colin Benaissa edited this page Nov 6, 2024 · 2 revisions

Step 1: Setting Up the Project

  1. Open Godot and create a new project.
  2. Choose a location for the project and select the "2D" or "3D" from the project template.
  3. Create a new scene. In Godot, the "Main" scene will be your entry point. You’ll likely use a Node2D (assuming you chose 2D) as the root node. If you chose to use a 3D scene, use 3D nodes rather than 2D for this project.
  4. Save this scene as Main.tscn.

Step 2: Creating the Player Character

  1. Add a new Node2D to a new scene and name the Node2D Player. To add a node, click the plus seen below, then you can search for the node you desire. Keep in mind that adding a node in this manner makes it a child to whatever scene or other node you have highlighted (in this case our main scene).
Screenshot 2024-11-05 at 7 48 39 PM
  1. Add a Sprite node to the Player node, and assign a simple image (e.g., a square or player character)by clicking the created sprite node on the left then clicking the empty texture field on the right and then clicking new ImageTexture(then you can drag an image from a folder).
Screenshot 2024-11-05 at 7 54 26 PM
  1. Add a CollisionShape2D to the Player node. Set its shape to a rectangle that matches the size of your sprite.
  2. Save your scene and name it Player.tscn.
  3. Now we’ll write the GDScript to handle movement (covered in previous page of this wiki)

Step 3: Setting Up the Obstacle

  1. Create a new Node2D to a new scene and call the Node2D Obstacle.
  2. Add a Sprite and assign an image for the obstacle (e.g., a block or a circle).
  3. Add a CollisionShape2D node, set its shape to a rectangle or circle matching the obstacle’s size.
  4. Save your scene and name it Obstacle.tscn.
  5. Now we’ll write the GDScript to handle movement (covered in previous page of this wiki)

Step 4: Main Scene Setup

  1. Go back to the Main.tscn scene. This will be the root scene where the game logic is handled. Add the following nodes:
  • A Player instance (drag and drop Player.tscn into the scene).
  • An Obstacle instance (drag and drop Obstacle.tscn into the scene).
  1. Now let’s manage obstacles and the game’s flow. In the Main.tscn script, we’ll instantiate obstacles and handle the game loop. Refer to number __ of page __.

Step 5: Game Over and Restarting

  1. To implement a game over that effectively restarts the game refer to number _ of page _.