Skip to content

CoderDojo-Ennis/Godot_Block_Pong

Repository files navigation

GODOT BLOCK PONG

Block Pong Tutorial Page

^^ This Page ^^

Important Points

  • Math Skills

    • Negative numbers
    • Decimal numbers
    • Multiplication
    • Heirarchy
  • This is a stepping stone to ease the transition to a new tool. It's not a long term programming strategy.

  • Moving from Scratch

    • A LOT more power and control. No limitations
    • Things in the virtual world are like real world things.
      • In order to see something on the screen, we need a camera
    • Node heirarchy instead of flat list
      • Each scene must have one root node
    • Sub-scenes
    • There are 2D and 3D nodes that generally don't mix
    • The visual and physical aspects of the virtual world are separate

Steps

Setting up the Scene - YouTube Video

Install the Block Coding plugin

  1. Create a new Godot project
  2. Select AssetLib from the top center
  3. Search for Block Codking by endless
    1. Download
    2. Install into the project
  4. In the AssetLib on the top right, select Plugins
  5. Turn on Enabled for BlockCode
  6. Switch from AssetLib to 2D view

Creating the game world

  1. Staring with a 2D scene, rename the root node to "PongGame"
  2. Do Save Scene and again enter "PongGame" as the scene name
  3. 🎥 Create the Camera
    1. Select the PongGame node, and add a child Camera 2D node. This will be in the center of the world.
    2. Change the camera's zoom value from 1.0 to 0.5
  4. 🏓 Create the paddles
    1. Add a child node to the game and search for Simple Character
    2. Set the texture using Quick Load Paddle
    3. Drag it to the left side and rename it to **Left Paddle"
    4. Use CTRL+D to duplicate it
    5. Rename the new paddle to Right Paddle
    6. Drag this to the right side
  5. ⚽ Create the ball
    1. With the PongGame node selected, add a new child object that is a Rigid Body 2D
    2. Rename this to "Ball"
    3. To this, add another child which is a Sprite 2D
    4. In the texture, quick load the "Ball"
    5. Note the warning on the ball. It needs a collision shape. Add a child node that is a "Collision Shape 2D"
    6. Set the shape to a Cirlce Shape, and drag the size to be as big as the ball sprite
    7. On the ball's Rigidbody create a new Physics Material with Frction=0 and Bounce=1, and set the GravityScale to 0
    8. In the Linear section, set the Velocity to X=400 and Y=400
  6. 🧱 Create the walls
    1. From the PongGame node, add a child of type **Static Body 2D" and rename this to "TopWall"
    2. To this, add a child node that is a Collision Shape 2D and set the shape to a new Rectangle Shape
    3. Drag and resize this shape to sit above the full play field
    4. Select the TopWall object and duplicate it.
    5. Rename this to **BottomWall" and drag it to the bottom of the scene
  7. 💯 Create the score display
    1. From the PongGame node, add a child node of type Simple Scoring
    2. In the Canvas Layer set the Transform Offset X=-1000 Y=-700
  8. 🥅 Create Goals
    1. From the PongGame node, add an Area2D child
    2. Name this LeftGoal
    3. Add a child to it that is a CollisionShape2D with a rectagle shape
    4. Move this just off the left side of the camera's view
    5. Duplicate this LeftGoal and rename it RightGoal and move it off the right side
  9. .🦋 Make it pretty
    1. Select the PongGame node, and add a Sprite2D child node
    2. On the Texture, Quick Load the "Space" graphic.
    3. Resize the sprite to fill the camera area
    4. Drag it to the top of the list so it doesn't block the other elements
    5. Select the Ball - Sprite2D and in the Canvas Item - Visibility Choose Modulate and pick a nice colour.
    6. Do the same for both of the Paddles
  10. ▶️ Give it a try! You should see the ball bouncing around a bit before getting lost.

About

A simple Pong game in Godot using Bock Coding

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published