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