added a basic ball that properly inverts velocity when colliding with a world boundary. my balls are getting stuck on each other tho
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
extends CollisionShape2D
|
||||
|
||||
@export_enum("x", "y") var boundary_invert_axis = 1
|
||||
+151
-10
@@ -1,19 +1,160 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://bmscox3qtwvs2"]
|
||||
[gd_scene load_steps=11 format=3 uid="uid://bmscox3qtwvs2"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://c7wvhwsys1ll4" path="res://resources/backgrounds/levelbg.webp" id="1_7ct6t"]
|
||||
[ext_resource type="FontFile" uid="uid://dxgnofummhosw" path="res://fonts/play_bold.ttf" id="2_musvo"]
|
||||
[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"]
|
||||
|
||||
[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_ybmo2"]
|
||||
normal = Vector2(0, 1)
|
||||
distance = -510.0
|
||||
|
||||
[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_k0bca"]
|
||||
distance = -510.0
|
||||
|
||||
[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_4nfnd"]
|
||||
normal = Vector2(1, 0)
|
||||
distance = -750.0
|
||||
|
||||
[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_ktw6h"]
|
||||
normal = Vector2(-1, 0)
|
||||
distance = -750.0
|
||||
|
||||
[node name="Level" type="Node2D"]
|
||||
|
||||
[node name="GUI" type="Control" parent="."]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
|
||||
[node name="PlayArea" type="Camera2D" parent="."]
|
||||
[node name="Camera2D" type="Camera2D" parent="."]
|
||||
position = Vector2(960, 540)
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="."]
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
offset_right = 1920.0
|
||||
offset_bottom = 1080.0
|
||||
texture = ExtResource("1_7ct6t")
|
||||
|
||||
[node name="GUI" type="VBoxContainer" parent="."]
|
||||
offset_left = 20.0
|
||||
offset_top = 20.0
|
||||
offset_right = 360.0
|
||||
offset_bottom = 1060.0
|
||||
|
||||
[node name="Title0" type="Label" parent="GUI"]
|
||||
layout_mode = 2
|
||||
theme_override_fonts/font = ExtResource("2_musvo")
|
||||
theme_override_font_sizes/font_size = 154
|
||||
text = "IDLE"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="Title1" type="Label" parent="GUI"]
|
||||
layout_mode = 2
|
||||
theme_override_fonts/font = ExtResource("2_musvo")
|
||||
theme_override_font_sizes/font_size = 64
|
||||
text = "BREAKOUT"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="GameContent" type="Node2D" parent="."]
|
||||
|
||||
[node name="WorldBoundary" type="Area2D" parent="GameContent"]
|
||||
position = Vector2(1140, 540)
|
||||
script = ExtResource("3_w4mye")
|
||||
|
||||
[node name="Top" parent="GameContent/WorldBoundary" instance=ExtResource("4_455ct")]
|
||||
shape = SubResource("WorldBoundaryShape2D_ybmo2")
|
||||
|
||||
[node name="Bottom" parent="GameContent/WorldBoundary" instance=ExtResource("4_455ct")]
|
||||
shape = SubResource("WorldBoundaryShape2D_k0bca")
|
||||
|
||||
[node name="Left" parent="GameContent/WorldBoundary" instance=ExtResource("4_455ct")]
|
||||
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")
|
||||
boundary_invert_axis = 0
|
||||
|
||||
[node name="Balls" type="Node2D" parent="GameContent"]
|
||||
|
||||
[node name="Ball" parent="GameContent/Balls" instance=ExtResource("3_14yi2")]
|
||||
position = Vector2(687, 534)
|
||||
motion_mode = 0
|
||||
floor_stop_on_slope = true
|
||||
|
||||
[node name="Ball2" parent="GameContent/Balls" instance=ExtResource("3_14yi2")]
|
||||
position = Vector2(971, 920)
|
||||
motion_mode = 0
|
||||
floor_stop_on_slope = true
|
||||
|
||||
[node name="Ball3" parent="GameContent/Balls" instance=ExtResource("3_14yi2")]
|
||||
position = Vector2(1641, 958)
|
||||
motion_mode = 0
|
||||
floor_stop_on_slope = true
|
||||
|
||||
[node name="Ball4" parent="GameContent/Balls" instance=ExtResource("3_14yi2")]
|
||||
position = Vector2(482, 986)
|
||||
motion_mode = 0
|
||||
floor_stop_on_slope = true
|
||||
|
||||
[node name="Ball5" parent="GameContent/Balls" instance=ExtResource("3_14yi2")]
|
||||
position = Vector2(899, 280)
|
||||
motion_mode = 0
|
||||
floor_stop_on_slope = true
|
||||
|
||||
[node name="Ball6" parent="GameContent/Balls" instance=ExtResource("3_14yi2")]
|
||||
position = Vector2(1427, 577)
|
||||
motion_mode = 0
|
||||
floor_stop_on_slope = true
|
||||
|
||||
[node name="Ball7" parent="GameContent/Balls" instance=ExtResource("3_14yi2")]
|
||||
position = Vector2(1330, 823)
|
||||
motion_mode = 0
|
||||
floor_stop_on_slope = true
|
||||
|
||||
[node name="Ball8" parent="GameContent/Balls" instance=ExtResource("3_14yi2")]
|
||||
position = Vector2(1544, 413)
|
||||
motion_mode = 0
|
||||
floor_stop_on_slope = true
|
||||
|
||||
[node name="Ball9" parent="GameContent/Balls" instance=ExtResource("3_14yi2")]
|
||||
position = Vector2(1646, 179)
|
||||
motion_mode = 0
|
||||
floor_stop_on_slope = true
|
||||
|
||||
[node name="Ball10" parent="GameContent/Balls" instance=ExtResource("3_14yi2")]
|
||||
position = Vector2(1666, 660)
|
||||
motion_mode = 0
|
||||
floor_stop_on_slope = true
|
||||
|
||||
[node name="Ball11" parent="GameContent/Balls" instance=ExtResource("3_14yi2")]
|
||||
position = Vector2(516, 671)
|
||||
motion_mode = 0
|
||||
floor_stop_on_slope = true
|
||||
|
||||
[node name="Ball12" parent="GameContent/Balls" instance=ExtResource("3_14yi2")]
|
||||
position = Vector2(553, 174)
|
||||
motion_mode = 0
|
||||
floor_stop_on_slope = true
|
||||
|
||||
[node name="Ball13" parent="GameContent/Balls" instance=ExtResource("3_14yi2")]
|
||||
position = Vector2(1303, 479)
|
||||
motion_mode = 0
|
||||
floor_stop_on_slope = true
|
||||
|
||||
[node name="Ball14" parent="GameContent/Balls" instance=ExtResource("3_14yi2")]
|
||||
position = Vector2(943, 726)
|
||||
motion_mode = 0
|
||||
floor_stop_on_slope = true
|
||||
|
||||
[node name="Ball15" parent="GameContent/Balls" instance=ExtResource("3_14yi2")]
|
||||
position = Vector2(1363, 282)
|
||||
motion_mode = 0
|
||||
floor_stop_on_slope = true
|
||||
|
||||
[node name="Ball16" parent="GameContent/Balls" instance=ExtResource("3_14yi2")]
|
||||
position = Vector2(1135, 158)
|
||||
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"]
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
extends Area2D
|
||||
|
||||
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()
|
||||
Reference in New Issue
Block a user