ball now more consistently collides with arbitrary objects and bounces off them appropriately
This commit is contained in:
+8
-83
@@ -5,7 +5,7 @@
|
||||
[ext_resource type="PackedScene" uid="uid://sl3jbnopo0yh" path="res://balls/basic/ball_basic.tscn" id="3_14yi2"]
|
||||
[ext_resource type="Script" path="res://scenes/world_boundary.gd" id="3_w4mye"]
|
||||
[ext_resource type="PackedScene" uid="uid://cbygje4vi2rkv" path="res://boundaries/world_boundary.tscn" id="4_455ct"]
|
||||
[ext_resource type="Script" path="res://scenes/boundary.gd" id="4_r1kkq"]
|
||||
[ext_resource type="PackedScene" uid="uid://c1i1fp3xbp6ly" path="res://blocks/block.tscn" id="7_7fnx3"]
|
||||
|
||||
[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_ybmo2"]
|
||||
normal = Vector2(0, 1)
|
||||
@@ -18,7 +18,7 @@ distance = -510.0
|
||||
normal = Vector2(1, 0)
|
||||
distance = -750.0
|
||||
|
||||
[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_ktw6h"]
|
||||
[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_0wr4g"]
|
||||
normal = Vector2(-1, 0)
|
||||
distance = -750.0
|
||||
|
||||
@@ -54,7 +54,7 @@ horizontal_alignment = 1
|
||||
|
||||
[node name="GameContent" type="Node2D" parent="."]
|
||||
|
||||
[node name="WorldBoundary" type="Area2D" parent="GameContent"]
|
||||
[node name="WorldBoundary" type="StaticBody2D" parent="GameContent"]
|
||||
position = Vector2(1140, 540)
|
||||
collision_layer = 2
|
||||
collision_mask = 4
|
||||
@@ -70,10 +70,8 @@ shape = SubResource("WorldBoundaryShape2D_k0bca")
|
||||
shape = SubResource("WorldBoundaryShape2D_4nfnd")
|
||||
boundary_invert_axis = 0
|
||||
|
||||
[node name="Right" type="CollisionShape2D" parent="GameContent/WorldBoundary"]
|
||||
shape = SubResource("WorldBoundaryShape2D_ktw6h")
|
||||
debug_color = Color(0.878431, 0, 0.415686, 0.419608)
|
||||
script = ExtResource("4_r1kkq")
|
||||
[node name="Right" parent="GameContent/WorldBoundary" instance=ExtResource("4_455ct")]
|
||||
shape = SubResource("WorldBoundaryShape2D_0wr4g")
|
||||
boundary_invert_axis = 0
|
||||
|
||||
[node name="Balls" type="Node2D" parent="GameContent"]
|
||||
@@ -83,80 +81,7 @@ position = Vector2(791, 656)
|
||||
motion_mode = 0
|
||||
floor_stop_on_slope = true
|
||||
|
||||
[node name="Ball2" parent="GameContent/Balls" instance=ExtResource("3_14yi2")]
|
||||
position = Vector2(1049, 563)
|
||||
motion_mode = 0
|
||||
floor_stop_on_slope = true
|
||||
[node name="Blocks" type="Node2D" parent="GameContent"]
|
||||
|
||||
[node name="Ball3" parent="GameContent/Balls" instance=ExtResource("3_14yi2")]
|
||||
position = Vector2(1382, 687)
|
||||
motion_mode = 0
|
||||
floor_stop_on_slope = true
|
||||
|
||||
[node name="Ball4" parent="GameContent/Balls" instance=ExtResource("3_14yi2")]
|
||||
position = Vector2(1289, 856)
|
||||
motion_mode = 0
|
||||
floor_stop_on_slope = true
|
||||
|
||||
[node name="Ball5" parent="GameContent/Balls" instance=ExtResource("3_14yi2")]
|
||||
position = Vector2(619, 256)
|
||||
motion_mode = 0
|
||||
floor_stop_on_slope = true
|
||||
|
||||
[node name="Ball6" parent="GameContent/Balls" instance=ExtResource("3_14yi2")]
|
||||
position = Vector2(663, 857)
|
||||
motion_mode = 0
|
||||
floor_stop_on_slope = true
|
||||
|
||||
[node name="Ball7" parent="GameContent/Balls" instance=ExtResource("3_14yi2")]
|
||||
position = Vector2(859, 252)
|
||||
motion_mode = 0
|
||||
floor_stop_on_slope = true
|
||||
|
||||
[node name="Ball8" parent="GameContent/Balls" instance=ExtResource("3_14yi2")]
|
||||
position = Vector2(958, 792)
|
||||
motion_mode = 0
|
||||
floor_stop_on_slope = true
|
||||
|
||||
[node name="Ball9" parent="GameContent/Balls" instance=ExtResource("3_14yi2")]
|
||||
position = Vector2(1418, 412)
|
||||
motion_mode = 0
|
||||
floor_stop_on_slope = true
|
||||
|
||||
[node name="Ball10" parent="GameContent/Balls" instance=ExtResource("3_14yi2")]
|
||||
position = Vector2(1677, 692)
|
||||
motion_mode = 0
|
||||
floor_stop_on_slope = true
|
||||
|
||||
[node name="Ball11" parent="GameContent/Balls" instance=ExtResource("3_14yi2")]
|
||||
position = Vector2(1610, 877)
|
||||
motion_mode = 0
|
||||
floor_stop_on_slope = true
|
||||
|
||||
[node name="Ball12" parent="GameContent/Balls" instance=ExtResource("3_14yi2")]
|
||||
position = Vector2(1394, 185)
|
||||
motion_mode = 0
|
||||
floor_stop_on_slope = true
|
||||
|
||||
[node name="Ball13" parent="GameContent/Balls" instance=ExtResource("3_14yi2")]
|
||||
position = Vector2(1285, 546)
|
||||
motion_mode = 0
|
||||
floor_stop_on_slope = true
|
||||
|
||||
[node name="Ball14" parent="GameContent/Balls" instance=ExtResource("3_14yi2")]
|
||||
position = Vector2(1078, 172)
|
||||
motion_mode = 0
|
||||
floor_stop_on_slope = true
|
||||
|
||||
[node name="Ball15" parent="GameContent/Balls" instance=ExtResource("3_14yi2")]
|
||||
position = Vector2(1562, 537)
|
||||
motion_mode = 0
|
||||
floor_stop_on_slope = true
|
||||
|
||||
[node name="Ball16" parent="GameContent/Balls" instance=ExtResource("3_14yi2")]
|
||||
position = Vector2(1507, 299)
|
||||
motion_mode = 0
|
||||
floor_stop_on_slope = true
|
||||
|
||||
[connection signal="body_entered" from="GameContent/WorldBoundary" to="GameContent/WorldBoundary" method="_on_ball_entered"]
|
||||
[connection signal="body_shape_entered" from="GameContent/WorldBoundary" to="GameContent/WorldBoundary" method="_on_ball_shape_entered"]
|
||||
[node name="Block" parent="GameContent/Blocks" instance=ExtResource("7_7fnx3")]
|
||||
position = Vector2(907, 752)
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
extends Area2D
|
||||
extends StaticBody2D
|
||||
|
||||
func _on_ball_shape_entered(body_rid, body, body_shape_index, local_shape_index):
|
||||
print("FUCK YES")
|
||||
match self.shape_owner_get_owner(local_shape_index).boundary_invert_axis:
|
||||
0: # x
|
||||
body.invert_x()
|
||||
1: # y
|
||||
body.invert_y()
|
||||
#func _on_ball_shape_entered(body_rid, body, body_shape_index, local_shape_index):
|
||||
#print("FUCK YES")
|
||||
#body.has_collided()
|
||||
#match self.shape_owner_get_owner(local_shape_index).boundary_invert_axis:
|
||||
#0: # x
|
||||
#body.invert_x()
|
||||
#1: # y
|
||||
#body.invert_y()
|
||||
|
||||
Reference in New Issue
Block a user