give each wall a seperate collider

this means i can detect if the ball hits the right or left wall, and it makes it easier to maintain.
This commit is contained in:
Fries 2023-05-18 10:38:22 -07:00
parent 4200a3e7df
commit 2805cd0e95
2 changed files with 66 additions and 15 deletions

View file

@ -1,35 +1,69 @@
[gd_scene load_steps=4 format=3 uid="uid://c5n541vsuvfk8"]
[gd_scene load_steps=8 format=3 uid="uid://c5n541vsuvfk8"]
[ext_resource type="Script" path="res://Scripts/WallManager.cs" id="1_mxer2"]
[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_f7jy5"]
size = Vector2(30, 600)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_1mqst"]
size = Vector2(30, 600)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_sip7s"]
size = Vector2(30, 600)
[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_868ov"]
size = Vector2(756, 30)
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_a4dbc"]
friction = 0.0
bounce = 1.0
[sub_resource type="RectangleShape2D" id="RectangleShape2D_rw4mt"]
size = Vector2(756, 30)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_dydpt"]
size = Vector2(756, 30)
[node name="Walls" type="Node2D"]
[node name="Left" type="Sprite2D" parent="."]
[node name="Left" type="Area2D" parent="."]
position = Vector2(-393, -2)
script = ExtResource("1_mxer2")
[node name="Left" type="Sprite2D" parent="Left"]
position = Vector2(2.08165e-12, 2.08165e-12)
texture = SubResource("PlaceholderTexture2D_f7jy5")
[node name="Right" type="Sprite2D" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Left"]
position = Vector2(-2.04636e-12, -2.08167e-12)
shape = SubResource("RectangleShape2D_1mqst")
[node name="Right" type="Area2D" parent="."]
position = Vector2(393, -2)
script = ExtResource("1_mxer2")
[node name="Right" type="Sprite2D" parent="Right"]
position = Vector2(2.08165e-12, 2.08165e-12)
texture = SubResource("PlaceholderTexture2D_f7jy5")
[node name="Top" type="Sprite2D" parent="."]
position = Vector2(0, -287)
[node name="CollisionShape2D" type="CollisionShape2D" parent="Right"]
position = Vector2(-2.10321e-12, -2.08167e-12)
shape = SubResource("RectangleShape2D_sip7s")
[node name="Top" type="StaticBody2D" parent="."]
position = Vector2(2.08165e-12, -287)
[node name="Top" type="Sprite2D" parent="Top"]
position = Vector2(2.08165e-12, 2.08165e-12)
texture = SubResource("PlaceholderTexture2D_868ov")
[node name="Bottom" type="Sprite2D" parent="."]
position = Vector2(0, 283)
[node name="CollisionShape2D" type="CollisionShape2D" parent="Top"]
position = Vector2(-2.08165e-12, 0)
shape = SubResource("RectangleShape2D_rw4mt")
[node name="Bottom" type="StaticBody2D" parent="."]
position = Vector2(2.08165e-12, 283)
[node name="Bottom" type="Sprite2D" parent="Bottom"]
position = Vector2(2.08165e-12, 2.08165e-12)
texture = SubResource("PlaceholderTexture2D_868ov")
[node name="StaticBody2D" type="StaticBody2D" parent="."]
physics_material_override = SubResource("PhysicsMaterial_a4dbc")
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="StaticBody2D"]
polygon = PackedVector2Array(-408, -302, 408, -302, 408, 298, -408, 298, -408, -301, -378, -272, -378, 268, 378, 268, 378, -272, -378, -272)
[node name="CollisionShape2D" type="CollisionShape2D" parent="Bottom"]
position = Vector2(-2.08165e-12, 0)
shape = SubResource("RectangleShape2D_dydpt")

17
Scripts/WallManager.cs Normal file
View file

@ -0,0 +1,17 @@
using Godot;
using System;
public partial class WallManager : Area2D
{
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
}
}