Skip to content

Commit e841bc8

Browse files
committed
Pong demo: Add areas for goals
Add 2 Area2D nodes to main with the same rectangle shape, one for the left goal and one for the right goal. Add groups so they can be referenced from blocks.
1 parent 7c4ac6b commit e841bc8

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

pong_game/goal_area.tscn

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[gd_scene load_steps=2 format=3 uid="uid://vc7u0ljq02eh"]
2+
3+
[sub_resource type="RectangleShape2D" id="RectangleShape2D_8q7gx"]
4+
size = Vector2(128, 1080)
5+
6+
[node name="GoalArea" type="Area2D"]
7+
8+
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
9+
shape = SubResource("RectangleShape2D_8q7gx")
10+
debug_color = Color(0.91772, 6.97896e-05, 0.704698, 0.42)

pong_game/pong_game.tscn

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[gd_scene load_steps=32 format=3 uid="uid://tf7b8c64ecc0"]
1+
[gd_scene load_steps=33 format=3 uid="uid://tf7b8c64ecc0"]
22

33
[ext_resource type="PackedScene" uid="uid://s7enbp56f256" path="res://pong_game/paddle.tscn" id="1_1k5k2"]
44
[ext_resource type="Script" path="res://pong_game/pong_game.gd" id="1_bjkc8"]
@@ -11,6 +11,7 @@
1111
[ext_resource type="PackedScene" uid="uid://bis7afjjuwypq" path="res://pong_game/hud.tscn" id="8_yg457"]
1212
[ext_resource type="PackedScene" uid="uid://c7l70grmkauij" path="res://pong_game/ball.tscn" id="9_xrqll"]
1313
[ext_resource type="PackedScene" uid="uid://1ownc3rikn2k" path="res://pong_game/ball_spawn_area.tscn" id="10_5vs1t"]
14+
[ext_resource type="PackedScene" uid="uid://vc7u0ljq02eh" path="res://pong_game/goal_area.tscn" id="12_nqmxu"]
1415

1516
[sub_resource type="Resource" id="Resource_535fl"]
1617
script = ExtResource("5_wr38c")
@@ -175,6 +176,12 @@ linear_velocity = Vector2(353.553, 353.553)
175176
[node name="BallSpawnArea" parent="." groups=["ball_spawn_area"] instance=ExtResource("10_5vs1t")]
176177
position = Vector2(960, 544)
177178

179+
[node name="GoalAreaLeft" parent="." groups=["goal", "goal_left"] instance=ExtResource("12_nqmxu")]
180+
position = Vector2(-64, 544)
181+
182+
[node name="GoalAreaRight" parent="." groups=["goal", "goal_right"] instance=ExtResource("12_nqmxu")]
183+
position = Vector2(1984, 544)
184+
178185
[node name="HUD" parent="." instance=ExtResource("8_yg457")]
179186

180187
[node name="BlockCode" type="Node" parent="."]

0 commit comments

Comments
 (0)