diff --git a/project.godot b/project.godot index 8489401..b87d690 100644 --- a/project.godot +++ b/project.godot @@ -14,6 +14,7 @@ config/name="GmtkGameJam2024" config/tags=PackedStringArray("game_jam") run/main_scene="res://scenes/Main/main.tscn" config/features=PackedStringArray("4.3", "GL Compatibility") +run/max_fps=120 config/icon="res://icon.svg" [autoload] @@ -38,6 +39,10 @@ version_control/autoload_on_startup=true enabled=PackedStringArray("res://addons/debug_menu/plugin.cfg") +[global_group] + +Block="Block" + [input] left={ @@ -87,12 +92,9 @@ locale/locale_filter_mode=0 [layer_names] 2d_physics/layer_1="map" -2d_physics/layer_2="blockPart" -2d_physics/layer_3="blockPartDetector" -2d_physics/layer_4="border" -2d_physics/layer_5="mapDetector" -2d_physics/layer_6="block" -2d_physics/layer_7="blockDetector" +2d_physics/layer_2="block" +2d_physics/layer_3="rowTest" +2d_physics/layer_4="TurnTest" [rendering] diff --git a/scenes/Block/1x3/1x3_Collision.tscn b/scenes/Block/1x3/1x3_Collision.tscn deleted file mode 100644 index 076c7c0..0000000 --- a/scenes/Block/1x3/1x3_Collision.tscn +++ /dev/null @@ -1,4 +0,0 @@ -[gd_scene format=3 uid="uid://d31ahyg7o077g"] - -[node name="CollisionPolygon2D" type="CollisionPolygon2D"] -polygon = PackedVector2Array(-59, -5, 123, -5, 123, -59, -59, -59) diff --git a/scenes/Block/1x3/1x3_block.gd b/scenes/Block/1x3/1x3_block.gd deleted file mode 100644 index 7c1cf5a..0000000 --- a/scenes/Block/1x3/1x3_block.gd +++ /dev/null @@ -1 +0,0 @@ -extends "res://scenes/Block/block.gd" diff --git a/scenes/Block/1x3/1x3_block.tscn b/scenes/Block/1x3/1x3_block.tscn deleted file mode 100644 index 7d6df01..0000000 --- a/scenes/Block/1x3/1x3_block.tscn +++ /dev/null @@ -1,58 +0,0 @@ -[gd_scene load_steps=4 format=3 uid="uid://ddxt76ksj1jw"] - -[ext_resource type="PackedScene" uid="uid://bu6grrxuhypny" path="res://scenes/Block/block.tscn" id="1_gs0af"] -[ext_resource type="Script" path="res://scenes/Block/1x3/1x3_block.gd" id="2_p067p"] -[ext_resource type="PackedScene" uid="uid://d31ahyg7o077g" path="res://scenes/Block/1x3/1x3_Collision.tscn" id="3_dydci"] - -[node name="1x3-Block" instance=ExtResource("1_gs0af")] -script = ExtResource("2_p067p") - -[node name="CollisionPolygon2D" parent="Tests/Position 1" index="0" instance=ExtResource("3_dydci")] - -[node name="CollisionPolygon2D" parent="Tests/Position 2" index="0" instance=ExtResource("3_dydci")] -position = Vector2(0, -64) -rotation = 1.57079 - -[node name="CollisionPolygon2D" parent="Tests/Position 3" index="0" instance=ExtResource("3_dydci")] -position = Vector2(64, -64) -rotation = 3.14159 - -[node name="CollisionPolygon2D" parent="Tests/Position 4" index="0" instance=ExtResource("3_dydci")] -position = Vector2(64, 0) -rotation = 4.71238 - -[node name="Marker2D" type="Marker2D" parent="Position 1" index="0"] -position = Vector2(-32, -32) - -[node name="Marker2D2" type="Marker2D" parent="Position 1" index="1"] -position = Vector2(32, -32) - -[node name="Marker2D3" type="Marker2D" parent="Position 1" index="2"] -position = Vector2(96, -32) - -[node name="Marker2D" type="Marker2D" parent="Position 2" index="0"] -position = Vector2(32, -96) - -[node name="Marker2D2" type="Marker2D" parent="Position 2" index="1"] -position = Vector2(32, -32) - -[node name="Marker2D3" type="Marker2D" parent="Position 2" index="2"] -position = Vector2(32, 32) - -[node name="Marker2D" type="Marker2D" parent="Position 3" index="0"] -position = Vector2(96, -32) - -[node name="Marker2D2" type="Marker2D" parent="Position 3" index="1"] -position = Vector2(32, -32) - -[node name="Marker2D3" type="Marker2D" parent="Position 3" index="2"] -position = Vector2(-32, -32) - -[node name="Marker2D" type="Marker2D" parent="Position 4" index="0"] -position = Vector2(32, 32) - -[node name="Marker2D2" type="Marker2D" parent="Position 4" index="1"] -position = Vector2(32, -32) - -[node name="Marker2D3" type="Marker2D" parent="Position 4" index="2"] -position = Vector2(32, -96) diff --git a/scenes/Block/1x4/1x4_Collision.tscn b/scenes/Block/1x4/1x4_Collision.tscn deleted file mode 100644 index 291c693..0000000 --- a/scenes/Block/1x4/1x4_Collision.tscn +++ /dev/null @@ -1,4 +0,0 @@ -[gd_scene format=3 uid="uid://bp15gv616ch2q"] - -[node name="CollisionPolygon2D" type="CollisionPolygon2D"] -polygon = PackedVector2Array(-123, -5, 123, -5, 123, -59, -123, -59) diff --git a/scenes/Block/1x4/1x4_block.gd b/scenes/Block/1x4/1x4_block.gd deleted file mode 100644 index 7c1cf5a..0000000 --- a/scenes/Block/1x4/1x4_block.gd +++ /dev/null @@ -1 +0,0 @@ -extends "res://scenes/Block/block.gd" diff --git a/scenes/Block/1x4/1x4_block.tscn b/scenes/Block/1x4/1x4_block.tscn deleted file mode 100644 index e206ff3..0000000 --- a/scenes/Block/1x4/1x4_block.tscn +++ /dev/null @@ -1,70 +0,0 @@ -[gd_scene load_steps=4 format=3 uid="uid://cgyslql51mvlm"] - -[ext_resource type="PackedScene" uid="uid://bu6grrxuhypny" path="res://scenes/Block/block.tscn" id="1_g3k8p"] -[ext_resource type="Script" path="res://scenes/Block/1x4/1x4_block.gd" id="2_1erjx"] -[ext_resource type="PackedScene" uid="uid://bp15gv616ch2q" path="res://scenes/Block/1x4/1x4_Collision.tscn" id="3_s74sy"] - -[node name="1x4-Block" instance=ExtResource("1_g3k8p")] -script = ExtResource("2_1erjx") - -[node name="CollisionPolygon2D" parent="Tests/Position 1" index="0" instance=ExtResource("3_s74sy")] - -[node name="CollisionPolygon2D" parent="Tests/Position 2" index="0" instance=ExtResource("3_s74sy")] -position = Vector2(0, -64) -rotation = 1.57079 - -[node name="CollisionPolygon2D" parent="Tests/Position 3" index="0" instance=ExtResource("3_s74sy")] -position = Vector2(0, -64) -rotation = 3.14159 - -[node name="CollisionPolygon2D" parent="Tests/Position 4" index="0" instance=ExtResource("3_s74sy")] -position = Vector2(64, -64) -rotation = -1.57079 - -[node name="Marker2D" type="Marker2D" parent="Position 1" index="0"] -position = Vector2(-96, -32) - -[node name="Marker2D2" type="Marker2D" parent="Position 1" index="1"] -position = Vector2(-32, -32) - -[node name="Marker2D3" type="Marker2D" parent="Position 1" index="2"] -position = Vector2(32, -32) - -[node name="Marker2D4" type="Marker2D" parent="Position 1" index="3"] -position = Vector2(96, -32) - -[node name="Marker2D" type="Marker2D" parent="Position 2" index="0"] -position = Vector2(32, -160) - -[node name="Marker2D2" type="Marker2D" parent="Position 2" index="1"] -position = Vector2(32, -96) - -[node name="Marker2D3" type="Marker2D" parent="Position 2" index="2"] -position = Vector2(32, -32) - -[node name="Marker2D4" type="Marker2D" parent="Position 2" index="3"] -position = Vector2(32, 32) - -[node name="Marker2D" type="Marker2D" parent="Position 3" index="0"] -position = Vector2(96, -32) - -[node name="Marker2D2" type="Marker2D" parent="Position 3" index="1"] -position = Vector2(32, -32) - -[node name="Marker2D3" type="Marker2D" parent="Position 3" index="2"] -position = Vector2(-32, -32) - -[node name="Marker2D4" type="Marker2D" parent="Position 3" index="3"] -position = Vector2(-96, -32) - -[node name="Marker2D" type="Marker2D" parent="Position 4" index="0"] -position = Vector2(32, 32) - -[node name="Marker2D2" type="Marker2D" parent="Position 4" index="1"] -position = Vector2(32, -32) - -[node name="Marker2D3" type="Marker2D" parent="Position 4" index="2"] -position = Vector2(32, -96) - -[node name="Marker2D4" type="Marker2D" parent="Position 4" index="3"] -position = Vector2(32, -160) diff --git a/scenes/Block/2x2/2x2_Collision.tscn b/scenes/Block/2x2/2x2_Collision.tscn deleted file mode 100644 index f916b37..0000000 --- a/scenes/Block/2x2/2x2_Collision.tscn +++ /dev/null @@ -1,4 +0,0 @@ -[gd_scene format=3 uid="uid://kv3xj8qgo8bt"] - -[node name="CollisionPolygon2D" type="CollisionPolygon2D"] -polygon = PackedVector2Array(59, 59, -59, 59, -59, -59, 59, -59) diff --git a/scenes/Block/2x2/2x2_block.gd b/scenes/Block/2x2/2x2_block.gd deleted file mode 100644 index 7c1cf5a..0000000 --- a/scenes/Block/2x2/2x2_block.gd +++ /dev/null @@ -1 +0,0 @@ -extends "res://scenes/Block/block.gd" diff --git a/scenes/Block/2x2/2x2_block.tscn b/scenes/Block/2x2/2x2_block.tscn deleted file mode 100644 index 69c308d..0000000 --- a/scenes/Block/2x2/2x2_block.tscn +++ /dev/null @@ -1,64 +0,0 @@ -[gd_scene load_steps=4 format=3 uid="uid://dp4h8tas2iyqk"] - -[ext_resource type="PackedScene" uid="uid://bu6grrxuhypny" path="res://scenes/Block/block.tscn" id="1_gmexj"] -[ext_resource type="Script" path="res://scenes/Block/2x2/2x2_block.gd" id="2_25xl5"] -[ext_resource type="PackedScene" uid="uid://kv3xj8qgo8bt" path="res://scenes/Block/2x2/2x2_Collision.tscn" id="3_qnfwy"] - -[node name="2x2-Block" instance=ExtResource("1_gmexj")] -script = ExtResource("2_25xl5") - -[node name="CollisionPolygon2D" parent="Tests/Position 1" index="0" instance=ExtResource("3_qnfwy")] - -[node name="CollisionPolygon2D" parent="Tests/Position 2" index="0" instance=ExtResource("3_qnfwy")] - -[node name="CollisionPolygon2D" parent="Tests/Position 3" index="0" instance=ExtResource("3_qnfwy")] - -[node name="CollisionPolygon2D" parent="Tests/Position 4" index="0" instance=ExtResource("3_qnfwy")] - -[node name="Marker2D" type="Marker2D" parent="Position 1" index="0"] -position = Vector2(-32, -32) - -[node name="Marker2D2" type="Marker2D" parent="Position 1" index="1"] -position = Vector2(32, -32) - -[node name="Marker2D3" type="Marker2D" parent="Position 1" index="2"] -position = Vector2(32, 32) - -[node name="Marker2D4" type="Marker2D" parent="Position 1" index="3"] -position = Vector2(-32, 32) - -[node name="Marker2D" type="Marker2D" parent="Position 2" index="0"] -position = Vector2(-32, -32) - -[node name="Marker2D2" type="Marker2D" parent="Position 2" index="1"] -position = Vector2(32, -32) - -[node name="Marker2D3" type="Marker2D" parent="Position 2" index="2"] -position = Vector2(32, 32) - -[node name="Marker2D4" type="Marker2D" parent="Position 2" index="3"] -position = Vector2(-32, 32) - -[node name="Marker2D" type="Marker2D" parent="Position 3" index="0"] -position = Vector2(-32, -32) - -[node name="Marker2D2" type="Marker2D" parent="Position 3" index="1"] -position = Vector2(32, -32) - -[node name="Marker2D3" type="Marker2D" parent="Position 3" index="2"] -position = Vector2(32, 32) - -[node name="Marker2D4" type="Marker2D" parent="Position 3" index="3"] -position = Vector2(-32, 32) - -[node name="Marker2D" type="Marker2D" parent="Position 4" index="0"] -position = Vector2(-32, -32) - -[node name="Marker2D2" type="Marker2D" parent="Position 4" index="1"] -position = Vector2(32, -32) - -[node name="Marker2D3" type="Marker2D" parent="Position 4" index="2"] -position = Vector2(32, 32) - -[node name="Marker2D4" type="Marker2D" parent="Position 4" index="3"] -position = Vector2(-32, 32) diff --git a/scenes/Block/2x3/2x3_Collision.tscn b/scenes/Block/2x3/2x3_Collision.tscn deleted file mode 100644 index a60f49b..0000000 --- a/scenes/Block/2x3/2x3_Collision.tscn +++ /dev/null @@ -1,4 +0,0 @@ -[gd_scene format=3 uid="uid://c3akl5atqyawx"] - -[node name="CollisionPolygon2D" type="CollisionPolygon2D"] -polygon = PackedVector2Array(59, 59, 59, -123, -59, -123, -59, 59) diff --git a/scenes/Block/2x3/2x3_block.gd b/scenes/Block/2x3/2x3_block.gd deleted file mode 100644 index 7c1cf5a..0000000 --- a/scenes/Block/2x3/2x3_block.gd +++ /dev/null @@ -1 +0,0 @@ -extends "res://scenes/Block/block.gd" diff --git a/scenes/Block/2x3/2x3_block.tscn b/scenes/Block/2x3/2x3_block.tscn deleted file mode 100644 index 98716a0..0000000 --- a/scenes/Block/2x3/2x3_block.tscn +++ /dev/null @@ -1,90 +0,0 @@ -[gd_scene load_steps=4 format=3 uid="uid://m0p5hh65ixef"] - -[ext_resource type="PackedScene" uid="uid://bu6grrxuhypny" path="res://scenes/Block/block.tscn" id="1_7ihjd"] -[ext_resource type="Script" path="res://scenes/Block/2x3/2x3_block.gd" id="2_j00i1"] -[ext_resource type="PackedScene" uid="uid://c3akl5atqyawx" path="res://scenes/Block/2x3/2x3_Collision.tscn" id="3_hwreo"] - -[node name="Block" instance=ExtResource("1_7ihjd")] -script = ExtResource("2_j00i1") - -[node name="CollisionPolygon2D" parent="Tests/Position 1" index="0" instance=ExtResource("3_hwreo")] - -[node name="CollisionPolygon2D" parent="Tests/Position 2" index="0" instance=ExtResource("3_hwreo")] -rotation = 1.57079 - -[node name="CollisionPolygon2D" parent="Tests/Position 3" index="0" instance=ExtResource("3_hwreo")] - -[node name="CollisionPolygon2D" parent="Tests/Position 4" index="0" instance=ExtResource("3_hwreo")] -rotation = 1.57079 - -[node name="Marker2D" type="Marker2D" parent="Position 1" index="0"] -position = Vector2(-32, -96) - -[node name="Marker2D2" type="Marker2D" parent="Position 1" index="1"] -position = Vector2(-32, -32) - -[node name="Marker2D3" type="Marker2D" parent="Position 1" index="2"] -position = Vector2(-32, 32) - -[node name="Marker2D4" type="Marker2D" parent="Position 1" index="3"] -position = Vector2(32, 32) - -[node name="Marker2D5" type="Marker2D" parent="Position 1" index="4"] -position = Vector2(32, -32) - -[node name="Marker2D6" type="Marker2D" parent="Position 1" index="5"] -position = Vector2(32, -96) - -[node name="Marker2D" type="Marker2D" parent="Position 2" index="0"] -position = Vector2(96, -32) - -[node name="Marker2D2" type="Marker2D" parent="Position 2" index="1"] -position = Vector2(32, -32) - -[node name="Marker2D3" type="Marker2D" parent="Position 2" index="2"] -position = Vector2(-32, -32) - -[node name="Marker2D4" type="Marker2D" parent="Position 2" index="3"] -position = Vector2(-32, 32) - -[node name="Marker2D5" type="Marker2D" parent="Position 2" index="4"] -position = Vector2(32, 32) - -[node name="Marker2D6" type="Marker2D" parent="Position 2" index="5"] -position = Vector2(96, 32) - -[node name="Marker2D" type="Marker2D" parent="Position 3" index="0"] -position = Vector2(-32, -96) - -[node name="Marker2D2" type="Marker2D" parent="Position 3" index="1"] -position = Vector2(-32, -32) - -[node name="Marker2D3" type="Marker2D" parent="Position 3" index="2"] -position = Vector2(-32, 32) - -[node name="Marker2D4" type="Marker2D" parent="Position 3" index="3"] -position = Vector2(32, 32) - -[node name="Marker2D5" type="Marker2D" parent="Position 3" index="4"] -position = Vector2(32, -32) - -[node name="Marker2D6" type="Marker2D" parent="Position 3" index="5"] -position = Vector2(32, -96) - -[node name="Marker2D" type="Marker2D" parent="Position 4" index="0"] -position = Vector2(96, -32) - -[node name="Marker2D2" type="Marker2D" parent="Position 4" index="1"] -position = Vector2(32, -32) - -[node name="Marker2D3" type="Marker2D" parent="Position 4" index="2"] -position = Vector2(-32, -32) - -[node name="Marker2D4" type="Marker2D" parent="Position 4" index="3"] -position = Vector2(-32, 32) - -[node name="Marker2D5" type="Marker2D" parent="Position 4" index="4"] -position = Vector2(32, 32) - -[node name="Marker2D6" type="Marker2D" parent="Position 4" index="5"] -position = Vector2(96, 32) diff --git a/scenes/Block/Fork/Fork_Collision.tscn b/scenes/Block/Fork/Fork_Collision.tscn deleted file mode 100644 index 34d322e..0000000 --- a/scenes/Block/Fork/Fork_Collision.tscn +++ /dev/null @@ -1,4 +0,0 @@ -[gd_scene format=3 uid="uid://dc5jsudyiemsi"] - -[node name="CollisionPolygon2D" type="CollisionPolygon2D"] -polygon = PackedVector2Array(123, 59, 123, -59, 69, -59, 69, 5, -5, 5, -5, -59, -59, -59, -59, 5, -123, 5, -123, 59) diff --git a/scenes/Block/Fork/Fork_block.gd b/scenes/Block/Fork/Fork_block.gd deleted file mode 100644 index 7c1cf5a..0000000 --- a/scenes/Block/Fork/Fork_block.gd +++ /dev/null @@ -1 +0,0 @@ -extends "res://scenes/Block/block.gd" diff --git a/scenes/Block/Fork/Fork_block.tscn b/scenes/Block/Fork/Fork_block.tscn deleted file mode 100644 index a6555a8..0000000 --- a/scenes/Block/Fork/Fork_block.tscn +++ /dev/null @@ -1,91 +0,0 @@ -[gd_scene load_steps=4 format=3 uid="uid://dbvc3pr7niwjj"] - -[ext_resource type="PackedScene" uid="uid://bu6grrxuhypny" path="res://scenes/Block/block.tscn" id="1_hrv0c"] -[ext_resource type="Script" path="res://scenes/Block/Fork/Fork_block.gd" id="2_x7do8"] -[ext_resource type="PackedScene" uid="uid://dc5jsudyiemsi" path="res://scenes/Block/Fork/Fork_Collision.tscn" id="3_hwx0i"] - -[node name="Block" instance=ExtResource("1_hrv0c")] -script = ExtResource("2_x7do8") - -[node name="CollisionPolygon2D" parent="Tests/Position 1" index="0" instance=ExtResource("3_hwx0i")] - -[node name="CollisionPolygon2D2" parent="Tests/Position 2" index="0" instance=ExtResource("3_hwx0i")] -rotation = 1.57079 - -[node name="CollisionPolygon2D" parent="Tests/Position 3" index="0" instance=ExtResource("3_hwx0i")] -rotation = -3.14159 - -[node name="CollisionPolygon2D" parent="Tests/Position 4" index="0" instance=ExtResource("3_hwx0i")] -rotation = -1.57079 - -[node name="Marker2D" type="Marker2D" parent="Position 1" index="0"] -position = Vector2(-96, 32) - -[node name="Marker2D2" type="Marker2D" parent="Position 1" index="1"] -position = Vector2(-32, 32) - -[node name="Marker2D3" type="Marker2D" parent="Position 1" index="2"] -position = Vector2(32, 32) - -[node name="Marker2D4" type="Marker2D" parent="Position 1" index="3"] -position = Vector2(96, 32) - -[node name="Marker2D5" type="Marker2D" parent="Position 1" index="4"] -position = Vector2(-32, -32) - -[node name="Marker2D6" type="Marker2D" parent="Position 1" index="5"] -position = Vector2(96, -32) - -[node name="Marker2D" type="Marker2D" parent="Position 2" index="0"] -position = Vector2(-32, -96) - -[node name="Marker2D2" type="Marker2D" parent="Position 2" index="1"] -position = Vector2(-32, -32) - -[node name="Marker2D3" type="Marker2D" parent="Position 2" index="2"] -position = Vector2(-32, 32) - -[node name="Marker2D4" type="Marker2D" parent="Position 2" index="3"] -position = Vector2(-32, 96) - -[node name="Marker2D5" type="Marker2D" parent="Position 2" index="4"] -position = Vector2(32, -32) - -[node name="Marker2D6" type="Marker2D" parent="Position 2" index="5"] -position = Vector2(32, 96) - -[node name="Marker2D" type="Marker2D" parent="Position 3" index="0"] -position = Vector2(96, -32) - -[node name="Marker2D2" type="Marker2D" parent="Position 3" index="1"] -position = Vector2(32, -32) - -[node name="Marker2D3" type="Marker2D" parent="Position 3" index="2"] -position = Vector2(-32, -32) - -[node name="Marker2D4" type="Marker2D" parent="Position 3" index="3"] -position = Vector2(-96, -32) - -[node name="Marker2D5" type="Marker2D" parent="Position 3" index="4"] -position = Vector2(32, 32) - -[node name="Marker2D6" type="Marker2D" parent="Position 3" index="5"] -position = Vector2(-96, 32) - -[node name="Marker2D" type="Marker2D" parent="Position 4" index="0"] -position = Vector2(32, 96) - -[node name="Marker2D2" type="Marker2D" parent="Position 4" index="1"] -position = Vector2(32, 32) - -[node name="Marker2D3" type="Marker2D" parent="Position 4" index="2"] -position = Vector2(32, -32) - -[node name="Marker2D4" type="Marker2D" parent="Position 4" index="3"] -position = Vector2(32, -96) - -[node name="Marker2D5" type="Marker2D" parent="Position 4" index="4"] -position = Vector2(-32, 32) - -[node name="Marker2D6" type="Marker2D" parent="Position 4" index="5"] -position = Vector2(-32, -96) diff --git a/scenes/Block/L-small/L-small_Collision.tscn b/scenes/Block/L-small/L-small_Collision.tscn deleted file mode 100644 index 786ad7b..0000000 --- a/scenes/Block/L-small/L-small_Collision.tscn +++ /dev/null @@ -1,4 +0,0 @@ -[gd_scene format=3 uid="uid://sdjhhungtjpp"] - -[node name="CollisionPolygon2D" type="CollisionPolygon2D"] -polygon = PackedVector2Array(59, 59, 59, 5, -5, 5, -5, -59, -59, -59, -59, 59) diff --git a/scenes/Block/L-small/L-small_block.gd b/scenes/Block/L-small/L-small_block.gd deleted file mode 100644 index 7c1cf5a..0000000 --- a/scenes/Block/L-small/L-small_block.gd +++ /dev/null @@ -1 +0,0 @@ -extends "res://scenes/Block/block.gd" diff --git a/scenes/Block/L-small/L-small_block.tscn b/scenes/Block/L-small/L-small_block.tscn deleted file mode 100644 index c69abf4..0000000 --- a/scenes/Block/L-small/L-small_block.tscn +++ /dev/null @@ -1,55 +0,0 @@ -[gd_scene load_steps=4 format=3 uid="uid://gmwso8esa8o8"] - -[ext_resource type="PackedScene" uid="uid://bu6grrxuhypny" path="res://scenes/Block/block.tscn" id="1_41sok"] -[ext_resource type="PackedScene" uid="uid://sdjhhungtjpp" path="res://scenes/Block/L-small/L-small_Collision.tscn" id="2_1jxh0"] -[ext_resource type="Script" path="res://scenes/Block/L-small/L-small_block.gd" id="2_orqrx"] - -[node name="Block" instance=ExtResource("1_41sok")] -script = ExtResource("2_orqrx") - -[node name="CollisionPolygon2D" parent="Tests/Position 1" index="0" instance=ExtResource("2_1jxh0")] - -[node name="CollisionPolygon2D" parent="Tests/Position 2" index="0" instance=ExtResource("2_1jxh0")] -rotation = 1.57079 - -[node name="CollisionPolygon2D" parent="Tests/Position 3" index="0" instance=ExtResource("2_1jxh0")] -rotation = -3.14159 - -[node name="CollisionPolygon2D" parent="Tests/Position 4" index="0" instance=ExtResource("2_1jxh0")] -rotation = -1.57079 - -[node name="Marker2D" type="Marker2D" parent="Position 1" index="0"] -position = Vector2(-32, -32) - -[node name="Marker2D2" type="Marker2D" parent="Position 1" index="1"] -position = Vector2(-32, 32) - -[node name="Marker2D3" type="Marker2D" parent="Position 1" index="2"] -position = Vector2(32, 32) - -[node name="Marker2D" type="Marker2D" parent="Position 2" index="0"] -position = Vector2(32, -32) - -[node name="Marker2D2" type="Marker2D" parent="Position 2" index="1"] -position = Vector2(-32, -32) - -[node name="Marker2D3" type="Marker2D" parent="Position 2" index="2"] -position = Vector2(-32, 32) - -[node name="Marker2D" type="Marker2D" parent="Position 3" index="0"] -position = Vector2(32, 32) - -[node name="Marker2D2" type="Marker2D" parent="Position 3" index="1"] -position = Vector2(32, -32) - -[node name="Marker2D3" type="Marker2D" parent="Position 3" index="2"] -position = Vector2(-32, -32) - -[node name="Marker2D" type="Marker2D" parent="Position 4" index="0"] -position = Vector2(-32, 32) - -[node name="Marker2D2" type="Marker2D" parent="Position 4" index="1"] -position = Vector2(32, 32) - -[node name="Marker2D3" type="Marker2D" parent="Position 4" index="2"] -position = Vector2(32, -32) diff --git a/scenes/Block/L/L_Collision.tscn b/scenes/Block/L/L_Collision.tscn deleted file mode 100644 index 8d66445..0000000 --- a/scenes/Block/L/L_Collision.tscn +++ /dev/null @@ -1,4 +0,0 @@ -[gd_scene format=3 uid="uid://ce6kkaplvq6w4"] - -[node name="CollisionPolygon2D" type="CollisionPolygon2D"] -polygon = PackedVector2Array(59, 59, 59, 5, -5, 5, -5, -123, -59, -123, -59, 59) diff --git a/scenes/Block/L/L_block.gd b/scenes/Block/L/L_block.gd deleted file mode 100644 index 7c1cf5a..0000000 --- a/scenes/Block/L/L_block.gd +++ /dev/null @@ -1 +0,0 @@ -extends "res://scenes/Block/block.gd" diff --git a/scenes/Block/L/L_block.tscn b/scenes/Block/L/L_block.tscn deleted file mode 100644 index af33894..0000000 --- a/scenes/Block/L/L_block.tscn +++ /dev/null @@ -1,69 +0,0 @@ -[gd_scene load_steps=4 format=3 uid="uid://d3083acqn1d3a"] - -[ext_resource type="PackedScene" uid="uid://bu6grrxuhypny" path="res://scenes/Block/block.tscn" id="1_er5ve"] -[ext_resource type="Script" path="res://scenes/Block/L/L_block.gd" id="2_q1cd1"] -[ext_resource type="PackedScene" uid="uid://ce6kkaplvq6w4" path="res://scenes/Block/L/L_Collision.tscn" id="3_wdblg"] - -[node name="Block" instance=ExtResource("1_er5ve")] -script = ExtResource("2_q1cd1") - -[node name="CollisionPolygon2D" parent="Tests/Position 1" index="0" instance=ExtResource("3_wdblg")] - -[node name="CollisionPolygon2D" parent="Tests/Position 2" index="0" instance=ExtResource("3_wdblg")] -rotation = 1.57079 - -[node name="CollisionPolygon2D" parent="Tests/Position 3" index="0" instance=ExtResource("3_wdblg")] -position = Vector2(0, -64) -rotation = -3.14159 - -[node name="CollisionPolygon2D" parent="Tests/Position 4" index="0" instance=ExtResource("3_wdblg")] -position = Vector2(64, 0) -rotation = -1.57079 - -[node name="Marker2D" type="Marker2D" parent="Position 1" index="0"] -position = Vector2(-32, -96) - -[node name="Marker2D2" type="Marker2D" parent="Position 1" index="1"] -position = Vector2(-32, -32) - -[node name="Marker2D3" type="Marker2D" parent="Position 1" index="2"] -position = Vector2(-32, 32) - -[node name="Marker2D4" type="Marker2D" parent="Position 1" index="3"] -position = Vector2(32, 32) - -[node name="Marker2D" type="Marker2D" parent="Position 2" index="0"] -position = Vector2(96, -32) - -[node name="Marker2D2" type="Marker2D" parent="Position 2" index="1"] -position = Vector2(32, -32) - -[node name="Marker2D3" type="Marker2D" parent="Position 2" index="2"] -position = Vector2(-32, -32) - -[node name="Marker2D4" type="Marker2D" parent="Position 2" index="3"] -position = Vector2(-32, 32) - -[node name="Marker2D" type="Marker2D" parent="Position 3" index="0"] -position = Vector2(32, 32) - -[node name="Marker2D2" type="Marker2D" parent="Position 3" index="1"] -position = Vector2(32, -32) - -[node name="Marker2D3" type="Marker2D" parent="Position 3" index="2"] -position = Vector2(32, -96) - -[node name="Marker2D4" type="Marker2D" parent="Position 3" index="3"] -position = Vector2(-32, -96) - -[node name="Marker2D" type="Marker2D" parent="Position 4" index="0"] -position = Vector2(-32, 32) - -[node name="Marker2D2" type="Marker2D" parent="Position 4" index="1"] -position = Vector2(32, 32) - -[node name="Marker2D3" type="Marker2D" parent="Position 4" index="2"] -position = Vector2(96, 32) - -[node name="Marker2D4" type="Marker2D" parent="Position 4" index="3"] -position = Vector2(96, -32) diff --git a/scenes/Block/Snake/Snake_Collision.tscn b/scenes/Block/Snake/Snake_Collision.tscn deleted file mode 100644 index c7b041e..0000000 --- a/scenes/Block/Snake/Snake_Collision.tscn +++ /dev/null @@ -1,4 +0,0 @@ -[gd_scene format=3 uid="uid://m02134rcpv2p"] - -[node name="CollisionPolygon2D" type="CollisionPolygon2D"] -polygon = PackedVector2Array(128, 0, 128, -64, 0, -64, 0, 0, -64, 0, -64, 64, 64, 64, 64, 0) diff --git a/scenes/Block/Snake/Snake_block.gd b/scenes/Block/Snake/Snake_block.gd deleted file mode 100644 index 7c1cf5a..0000000 --- a/scenes/Block/Snake/Snake_block.gd +++ /dev/null @@ -1 +0,0 @@ -extends "res://scenes/Block/block.gd" diff --git a/scenes/Block/Snake/Snake_block.tscn b/scenes/Block/Snake/Snake_block.tscn deleted file mode 100644 index d7443bf..0000000 --- a/scenes/Block/Snake/Snake_block.tscn +++ /dev/null @@ -1,66 +0,0 @@ -[gd_scene load_steps=4 format=3 uid="uid://bnsptw7gc7mmp"] - -[ext_resource type="PackedScene" uid="uid://bu6grrxuhypny" path="res://scenes/Block/block.tscn" id="1_yh2qq"] -[ext_resource type="Script" path="res://scenes/Block/Snake/Snake_block.gd" id="2_5tnwi"] -[ext_resource type="PackedScene" uid="uid://m02134rcpv2p" path="res://scenes/Block/Snake/Snake_Collision.tscn" id="3_447tx"] - -[node name="Block" instance=ExtResource("1_yh2qq")] -script = ExtResource("2_5tnwi") - -[node name="CollisionPolygon2D" parent="Tests/Position 1" index="0" instance=ExtResource("3_447tx")] - -[node name="CollisionPolygon2D" parent="Tests/Position 2" index="0" instance=ExtResource("3_447tx")] -rotation = 1.57079 - -[node name="CollisionPolygon2D" parent="Tests/Position 3" index="0" instance=ExtResource("3_447tx")] - -[node name="CollisionPolygon2D" parent="Tests/Position 4" index="0" instance=ExtResource("3_447tx")] -rotation = 1.57079 - -[node name="Marker2D" type="Marker2D" parent="Position 1" index="0"] -position = Vector2(-32, 32) - -[node name="Marker2D2" type="Marker2D" parent="Position 1" index="1"] -position = Vector2(32, 32) - -[node name="Marker2D3" type="Marker2D" parent="Position 1" index="2"] -position = Vector2(32, -32) - -[node name="Marker2D4" type="Marker2D" parent="Position 1" index="3"] -position = Vector2(96, -32) - -[node name="Marker2D" type="Marker2D" parent="Position 2" index="0"] -position = Vector2(-32, -32) - -[node name="Marker2D2" type="Marker2D" parent="Position 2" index="1"] -position = Vector2(-32, 32) - -[node name="Marker2D3" type="Marker2D" parent="Position 2" index="2"] -position = Vector2(32, 32) - -[node name="Marker2D4" type="Marker2D" parent="Position 2" index="3"] -position = Vector2(32, 96) - -[node name="Marker2D" type="Marker2D" parent="Position 3" index="0"] -position = Vector2(-32, 32) - -[node name="Marker2D2" type="Marker2D" parent="Position 3" index="1"] -position = Vector2(32, 32) - -[node name="Marker2D3" type="Marker2D" parent="Position 3" index="2"] -position = Vector2(32, -32) - -[node name="Marker2D4" type="Marker2D" parent="Position 3" index="3"] -position = Vector2(96, -32) - -[node name="Marker2D" type="Marker2D" parent="Position 4" index="0"] -position = Vector2(-32, -32) - -[node name="Marker2D2" type="Marker2D" parent="Position 4" index="1"] -position = Vector2(-32, 32) - -[node name="Marker2D3" type="Marker2D" parent="Position 4" index="2"] -position = Vector2(32, 32) - -[node name="Marker2D4" type="Marker2D" parent="Position 4" index="3"] -position = Vector2(32, 96) diff --git a/scenes/Block/T/T_Collision.tscn b/scenes/Block/T/T_Collision.tscn deleted file mode 100644 index e5c5bf9..0000000 --- a/scenes/Block/T/T_Collision.tscn +++ /dev/null @@ -1,4 +0,0 @@ -[gd_scene format=3 uid="uid://y28wwij2c37i"] - -[node name="CollisionPolygon2D" type="CollisionPolygon2D"] -polygon = PackedVector2Array(59, -5, 59, -59, -5, -59, -5, -123, -59, -123, -59, -59, -123, -59, -123, -5) diff --git a/scenes/Block/T/T_block.gd b/scenes/Block/T/T_block.gd deleted file mode 100644 index 7c1cf5a..0000000 --- a/scenes/Block/T/T_block.gd +++ /dev/null @@ -1 +0,0 @@ -extends "res://scenes/Block/block.gd" diff --git a/scenes/Block/T/T_block.tscn b/scenes/Block/T/T_block.tscn deleted file mode 100644 index 3ef1034..0000000 --- a/scenes/Block/T/T_block.tscn +++ /dev/null @@ -1,86 +0,0 @@ -[gd_scene load_steps=4 format=3 uid="uid://blie7m1eu4ah0"] - -[ext_resource type="PackedScene" uid="uid://bu6grrxuhypny" path="res://scenes/Block/block.tscn" id="1_hgreb"] -[ext_resource type="Script" path="res://scenes/Block/T/T_block.gd" id="2_uy5uy"] -[ext_resource type="PackedScene" uid="uid://y28wwij2c37i" path="res://scenes/Block/T/T_Collision.tscn" id="3_n3dps"] - -[node name="T-Block" instance=ExtResource("1_hgreb")] -script = ExtResource("2_uy5uy") - -[node name="Position 1" parent="Tests" index="0"] -position = Vector2(-64, 0) -rotation = 1.57079 - -[node name="Tests_Area2D4#CollisionPolygon2D" parent="Tests/Position 1" index="0" instance=ExtResource("3_n3dps")] -position = Vector2(0, -64) -rotation = -1.57079 - -[node name="Position 2" parent="Tests" index="1"] -position = Vector2(0, -64) -rotation = -1.57079 - -[node name="Tests_Area2D3#CollisionPolygon2D" parent="Tests/Position 2" index="0" instance=ExtResource("3_n3dps")] -position = Vector2(-64.0001, -63.9999) -rotation = -3.14159 - -[node name="Position 3" parent="Tests" index="2"] -position = Vector2(-64, -64) -rotation = 1.57079 - -[node name="Tests_Area2D2#CollisionPolygon2D" parent="Tests/Position 3" index="0" instance=ExtResource("3_n3dps")] -position = Vector2(-64, -0.000141207) -rotation = 1.57079 - -[node name="Position 4" parent="Tests" index="3"] -position = Vector2(64, -64) -rotation = -1.57079 - -[node name="Tests_Area2D#CollisionPolygon2D" parent="Tests/Position 4" index="0" instance=ExtResource("3_n3dps")] - -[node name="Marker2D" type="Marker2D" parent="Position 1" index="0"] -position = Vector2(-32, -96) - -[node name="Marker2D2" type="Marker2D" parent="Position 1" index="1"] -position = Vector2(-96, -32) - -[node name="Marker2D3" type="Marker2D" parent="Position 1" index="2"] -position = Vector2(-32, -32) - -[node name="Marker2D4" type="Marker2D" parent="Position 1" index="3"] -position = Vector2(32, -32) - -[node name="Marker2D" type="Marker2D" parent="Position 2" index="0"] -position = Vector2(32, -32) - -[node name="Marker2D2" type="Marker2D" parent="Position 2" index="1"] -position = Vector2(-32, -96) - -[node name="Marker2D3" type="Marker2D" parent="Position 2" index="2"] -position = Vector2(-32, -32) - -[node name="Marker2D4" type="Marker2D" parent="Position 2" index="3"] -position = Vector2(-32, 32) - -[node name="Marker2D" type="Marker2D" parent="Position 3" index="0"] -position = Vector2(-96, -96) - -[node name="Marker2D2" type="Marker2D" parent="Position 3" index="1"] -position = Vector2(-32, -32) - -[node name="Marker2D3" type="Marker2D" parent="Position 3" index="2"] -position = Vector2(-32, -96) - -[node name="Marker2D4" type="Marker2D" parent="Position 3" index="3"] -position = Vector2(32, -96) - -[node name="Marker2D" type="Marker2D" parent="Position 4" index="0"] -position = Vector2(-32, -32) - -[node name="Marker2D2" type="Marker2D" parent="Position 4" index="1"] -position = Vector2(32, 32) - -[node name="Marker2D3" type="Marker2D" parent="Position 4" index="2"] -position = Vector2(32, -32) - -[node name="Marker2D4" type="Marker2D" parent="Position 4" index="3"] -position = Vector2(32, -96) diff --git a/scenes/Block/block.gd b/scenes/Block/block.gd deleted file mode 100644 index bcc2f45..0000000 --- a/scenes/Block/block.gd +++ /dev/null @@ -1,150 +0,0 @@ -extends Node2D - -var secretPosition = Vector2() - -@onready var blockParts = $BlockParts -@onready var stopTimer = $stopTimer - -var stopped = false - -var type : GLOBAL.BLOCKTYPES = GLOBAL.BLOCKTYPES.LIGHT - -var TestPositions : Dictionary = { - 1: $"Tests/Position 1", - 2: $"Tests/Position 2", - 3: $"Tests/Position 3", - 4: $"Tests/Position 4", -} - -var Positions : Dictionary = { - 1: $"Position 1", - 2: $"Position 2", - 3: $"Position 3", - 4: $"Position 4" -} - -var currentRotation = 1 - -var id = 0 - -# Called when the node enters the scene tree for the first time. -func _ready() -> void: - secretPosition = position - generateBlockParts() - self.modulate = Color.from_hsv((randi() % 12) / 12.0, 1, 1) - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta: float) -> void: - position = secretPosition.snapped(Vector2(64,64)) - if not isCollidingBOTTOM() and( GLOBAL.hasSelectedSpeed or (self != GLOBAL.currentBlock)) : - secretPosition.y += GLOBAL.currentSpeed * delta * 30 - if self == GLOBAL.currentBlock and not stopped: - #if not isCollidingBOTTOM(): - # secretPosition.y += GLOBAL.SPEED.MAX * delta * 30 - #else: - if stopTimer.is_stopped(): - stopTimer.start(0.7) - #secretPosition = secretPosition.snapped(Vector2(64,64)) - - - if Input.is_action_just_pressed("rotate_left"): - if not isNextRotationColliding(1): - currentRotation = interpolateRotation(1) - rotateBlock() - elif not isNextRotationColliding(1,1): - currentRotation = interpolateRotation(1,1) - rotateBlock() - elif Input.is_action_just_pressed("rotate_right"): - if not isNextRotationColliding(2): - currentRotation = interpolateRotation(2) - rotateBlock() - elif not isNextRotationColliding(2,1): - currentRotation = interpolateRotation(2,1) - rotateBlock() - elif Input.is_action_just_pressed("left"): - if not isCollidingLeft(): - secretPosition.x -= GLOBAL.GRID - elif Input.is_action_just_pressed("right"): - if not isCollidingRIGHT(): - secretPosition.x += GLOBAL.GRID - -func isCollidingTOP() -> bool: - for i in blockParts.get_children(): - if i.getCollisionTOP(): - return true - return false - -func isCollidingLeft() -> bool: - for i in blockParts.get_children(): - if i.getCollisionLEFT(): - return true - return false - -func isCollidingRIGHT() -> bool: - for i in blockParts.get_children(): - if i.getCollisionRIGHT(): - return true - return false - -func isCollidingBOTTOM() -> bool: - for i in blockParts.get_children(): - if i.getCollisionBOTTOM(): - return true - return false - - -func generateBlockParts(): - for i in Positions[1].get_children(): - var blockPart = load("res://scenes/Block/block_part.tscn").instantiate() - blockPart.position = i.position# + Vector2( GLOBAL.GRID / 2, GLOBAL.GRID / 2) - blockParts.add_child(blockPart) - -func rotateBlock(): - for i in blockParts.get_children().size(): - blockParts.get_children()[i].position = Positions[currentRotation].get_children()[i].position - -func interpolateRotation(direction, additions=0): - match direction: - 1: - if currentRotation + 1 > 4: - return 1 + additions - elif currentRotation + (1 + additions) > 4: - return 1 - elif currentRotation + (1 + additions) <= 4: - return currentRotation + (1 + additions) - - 2: - if currentRotation - 1 < 1: - return 4 - additions - elif currentRotation - (1 + additions) < 1: - return 4 - elif currentRotation - (1 + additions) >= 1: - return currentRotation - (1 + additions) - -func isNextRotationColliding(direction, additions=0): - var colliding = false - match direction: - 1: - for i in TestPositions[interpolateRotation(1, additions)].get_overlapping_areas(): - if not i.get_parent().get_parent() == TestPositions[interpolateRotation(1, additions)].get_parent().get_parent(): - colliding = true - return colliding#TestPositions[interpolateRotation(1, additions)].has_overlapping_areas() - 2: - for i in TestPositions[interpolateRotation(2, additions)].get_overlapping_areas(): - if not i.get_parent().get_parent() == TestPositions[interpolateRotation(2, additions)].get_parent().get_parent(): - colliding = true - return colliding#TestPositions[interpolateRotation(2, additions)].has_overlapping_areas() - - -func setId(newID): - id = newID - -func setType(newType): - type = newType - -func _on_stop_timer_timeout() -> void: - if isCollidingBOTTOM(): - $Tests.queue_free() - for i in Positions: - Positions[i].queue_free() - stopped = true diff --git a/scenes/Block/block.tscn b/scenes/Block/block.tscn deleted file mode 100644 index 17fabb5..0000000 --- a/scenes/Block/block.tscn +++ /dev/null @@ -1,40 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://bu6grrxuhypny"] - -[ext_resource type="Script" path="res://scenes/Block/block.gd" id="1_chscu"] - -[node name="Block" type="Node2D"] -script = ExtResource("1_chscu") - -[node name="Tests" type="Node2D" parent="."] - -[node name="Position 1" type="Area2D" parent="Tests"] -collision_layer = 68 -collision_mask = 43 - -[node name="Position 2" type="Area2D" parent="Tests"] -collision_layer = 68 -collision_mask = 43 - -[node name="Position 3" type="Area2D" parent="Tests"] -collision_layer = 68 -collision_mask = 43 - -[node name="Position 4" type="Area2D" parent="Tests"] -collision_layer = 68 -collision_mask = 43 - -[node name="Position 1" type="Node2D" parent="."] - -[node name="Position 2" type="Node2D" parent="."] - -[node name="Position 3" type="Node2D" parent="."] - -[node name="Position 4" type="Node2D" parent="."] - -[node name="BlockParts" type="Node2D" parent="."] - -[node name="stopTimer" type="Timer" parent="."] -process_callback = 0 -one_shot = true - -[connection signal="timeout" from="stopTimer" to="." method="_on_stop_timer_timeout"] diff --git a/scenes/Block/block_part.gd b/scenes/Block/block_part.gd deleted file mode 100644 index 40379c5..0000000 --- a/scenes/Block/block_part.gd +++ /dev/null @@ -1,33 +0,0 @@ -extends Area2D - -var points = 1 - -@onready var rayCastTOP = $Raycasts/RayCastTOP -@onready var rayCastRIGHT = $Raycasts/RayCastRIGHT -@onready var rayCastBOTTOM = $Raycasts/RayCastBOTTOM -@onready var rayCastLEFT = $Raycasts/RayCastLEFT - - -func getCollisionTOP() -> bool: - if rayCastTOP.get_collider() != null: - if rayCastTOP.get_collider().get_parent() != get_parent(): - return rayCastTOP.is_colliding() - return false - -func getCollisionRIGHT() -> bool: - if rayCastRIGHT.get_collider() != null: - if rayCastRIGHT.get_collider().get_parent() != get_parent(): - return rayCastRIGHT.is_colliding() - return false - -func getCollisionBOTTOM() -> bool: - if rayCastBOTTOM.get_collider() != null: - if rayCastBOTTOM.get_collider().get_parent() != get_parent(): - return rayCastBOTTOM.is_colliding() - return false - -func getCollisionLEFT() -> bool: - if rayCastLEFT.get_collider() != null: - if rayCastLEFT.get_collider().get_parent() != get_parent(): - return rayCastLEFT.is_colliding() - return false diff --git a/scenes/Block/block_part.tscn b/scenes/Block/block_part.tscn deleted file mode 100644 index 3b6c2fa..0000000 --- a/scenes/Block/block_part.tscn +++ /dev/null @@ -1,50 +0,0 @@ -[gd_scene load_steps=4 format=3 uid="uid://yajhyi0j8b6a"] - -[ext_resource type="Script" path="res://scenes/Block/block_part.gd" id="1_nb58p"] - -[sub_resource type="RectangleShape2D" id="RectangleShape2D_tjkbt"] -size = Vector2(64, 64) - -[sub_resource type="QuadMesh" id="QuadMesh_puslh"] - -[node name="BlockPart" type="Area2D"] -collision_layer = 2 -collision_mask = 4 -script = ExtResource("1_nb58p") - -[node name="CollisionShape2D" type="CollisionShape2D" parent="."] -shape = SubResource("RectangleShape2D_tjkbt") - -[node name="Raycasts" type="Node2D" parent="."] - -[node name="RayCastTOP" type="RayCast2D" parent="Raycasts"] -position = Vector2(0, -48) -target_position = Vector2(0, -16) -collision_mask = 11 -hit_from_inside = true -collide_with_areas = true - -[node name="RayCastRIGHT" type="RayCast2D" parent="Raycasts"] -position = Vector2(48, 0) -target_position = Vector2(16, 0) -collision_mask = 11 -hit_from_inside = true -collide_with_areas = true - -[node name="RayCastBOTTOM" type="RayCast2D" parent="Raycasts"] -position = Vector2(0, 48) -target_position = Vector2(0, 16) -collision_mask = 11 -hit_from_inside = true -collide_with_areas = true - -[node name="RayCastLEFT" type="RayCast2D" parent="Raycasts"] -position = Vector2(-48, 0) -target_position = Vector2(-16, 0) -collision_mask = 11 -hit_from_inside = true -collide_with_areas = true - -[node name="MeshInstance2D" type="MeshInstance2D" parent="."] -scale = Vector2(62, 62) -mesh = SubResource("QuadMesh_puslh") diff --git a/scenes/Blocks/Patterns/1x3/1x3_Collision.tscn b/scenes/Blocks/Patterns/1x3/1x3_Collision.tscn new file mode 100644 index 0000000..9910313 --- /dev/null +++ b/scenes/Blocks/Patterns/1x3/1x3_Collision.tscn @@ -0,0 +1,5 @@ +[gd_scene format=3 uid="uid://yw2cspv5rkwh"] + +[node name="CollisionPolygon2D" type="CollisionPolygon2D"] +position = Vector2(32, 32) +polygon = PackedVector2Array(48, -16, 48, -48, -112, -48, -112, -16) diff --git a/scenes/Blocks/Patterns/1x3/1x3_block_pattern.tscn b/scenes/Blocks/Patterns/1x3/1x3_block_pattern.tscn new file mode 100644 index 0000000..a875f4e --- /dev/null +++ b/scenes/Blocks/Patterns/1x3/1x3_block_pattern.tscn @@ -0,0 +1,18 @@ +[gd_scene load_steps=4 format=3 uid="uid://b6aa24lk0ush1"] + +[ext_resource type="PackedScene" uid="uid://7knb2yqvkw6i" path="res://scenes/Blocks/Patterns/block_pattern.tscn" id="1_cqyb4"] +[ext_resource type="PackedScene" uid="uid://2v7wok4hnr6c" path="res://scenes/Blocks/Patterns/position_marker.tscn" id="2_4ivv2"] +[ext_resource type="PackedScene" uid="uid://yw2cspv5rkwh" path="res://scenes/Blocks/Patterns/1x3/1x3_Collision.tscn" id="3_vkhdr"] + +[node name="BlockPattern" instance=ExtResource("1_cqyb4")] + +[node name="PositionMarker" parent="Positions" index="0" instance=ExtResource("2_4ivv2")] +position = Vector2(-64, 0) + +[node name="PositionMarker2" parent="Positions" index="1" instance=ExtResource("2_4ivv2")] +turningPoint = true + +[node name="PositionMarker3" parent="Positions" index="2" instance=ExtResource("2_4ivv2")] +position = Vector2(64, 0) + +[node name="CollisionPolygon2D" parent="CollisionTest" index="0" instance=ExtResource("3_vkhdr")] diff --git a/scenes/Blocks/Patterns/2x2/2x2_Collision.tscn b/scenes/Blocks/Patterns/2x2/2x2_Collision.tscn new file mode 100644 index 0000000..acac5a1 --- /dev/null +++ b/scenes/Blocks/Patterns/2x2/2x2_Collision.tscn @@ -0,0 +1,4 @@ +[gd_scene format=3 uid="uid://dw1dt1jp6e06h"] + +[node name="CollisionPolygon2D" type="CollisionPolygon2D"] +polygon = PackedVector2Array(48, 48, 48, -48, -48, -48, -48, 48) diff --git a/scenes/Blocks/Patterns/2x2/2x2_block_pattern.tscn b/scenes/Blocks/Patterns/2x2/2x2_block_pattern.tscn new file mode 100644 index 0000000..b92458b --- /dev/null +++ b/scenes/Blocks/Patterns/2x2/2x2_block_pattern.tscn @@ -0,0 +1,21 @@ +[gd_scene load_steps=4 format=3 uid="uid://dneih4b0e2snv"] + +[ext_resource type="PackedScene" uid="uid://7knb2yqvkw6i" path="res://scenes/Blocks/Patterns/block_pattern.tscn" id="1_sj41y"] +[ext_resource type="PackedScene" uid="uid://2v7wok4hnr6c" path="res://scenes/Blocks/Patterns/position_marker.tscn" id="2_csenr"] +[ext_resource type="PackedScene" uid="uid://dw1dt1jp6e06h" path="res://scenes/Blocks/Patterns/2x2/2x2_Collision.tscn" id="3_10q5w"] + +[node name="BlockPattern" instance=ExtResource("1_sj41y")] + +[node name="PositionMarker" parent="Positions" index="0" instance=ExtResource("2_csenr")] + +[node name="PositionMarker2" parent="Positions" index="1" instance=ExtResource("2_csenr")] +position = Vector2(0, -64) + +[node name="PositionMarker3" parent="Positions" index="2" instance=ExtResource("2_csenr")] +position = Vector2(-64, -64) + +[node name="PositionMarker4" parent="Positions" index="3" instance=ExtResource("2_csenr")] +position = Vector2(-64, 0) + +[node name="CollisionPolygon2D" parent="CollisionTest" index="0" instance=ExtResource("3_10q5w")] +position = Vector2(-32, -32) diff --git a/scenes/Blocks/Patterns/I/I_Collision.tscn b/scenes/Blocks/Patterns/I/I_Collision.tscn new file mode 100644 index 0000000..ad51e82 --- /dev/null +++ b/scenes/Blocks/Patterns/I/I_Collision.tscn @@ -0,0 +1,4 @@ +[gd_scene format=3 uid="uid://ufbeturvvirh"] + +[node name="CollisionPolygon2D" type="CollisionPolygon2D"] +polygon = PackedVector2Array(112, -16, 112, -48, -112, -48, -112, -16) diff --git a/scenes/Blocks/Patterns/I/I_block_pattern.tscn b/scenes/Blocks/Patterns/I/I_block_pattern.tscn new file mode 100644 index 0000000..886a9b1 --- /dev/null +++ b/scenes/Blocks/Patterns/I/I_block_pattern.tscn @@ -0,0 +1,22 @@ +[gd_scene load_steps=4 format=3 uid="uid://hlwbhtymstbv"] + +[ext_resource type="PackedScene" uid="uid://7knb2yqvkw6i" path="res://scenes/Blocks/Patterns/block_pattern.tscn" id="1_ri22b"] +[ext_resource type="PackedScene" uid="uid://2v7wok4hnr6c" path="res://scenes/Blocks/Patterns/position_marker.tscn" id="2_6qvmy"] +[ext_resource type="PackedScene" uid="uid://ufbeturvvirh" path="res://scenes/Blocks/Patterns/I/I_Collision.tscn" id="3_1ktcx"] + +[node name="BlockPattern" instance=ExtResource("1_ri22b")] + +[node name="PositionMarker" parent="Positions" index="0" instance=ExtResource("2_6qvmy")] +position = Vector2(-64, 0) + +[node name="PositionMarker2" parent="Positions" index="1" instance=ExtResource("2_6qvmy")] +turningPoint = true + +[node name="PositionMarker3" parent="Positions" index="2" instance=ExtResource("2_6qvmy")] +position = Vector2(64, 0) + +[node name="PositionMarker4" parent="Positions" index="3" instance=ExtResource("2_6qvmy")] +position = Vector2(128, 0) + +[node name="CollisionPolygon2D" parent="CollisionTest" index="0" instance=ExtResource("3_1ktcx")] +position = Vector2(32, 32) diff --git a/scenes/Blocks/Patterns/L-Reverse/L-Reverse_Collision.tscn b/scenes/Blocks/Patterns/L-Reverse/L-Reverse_Collision.tscn new file mode 100644 index 0000000..a0955b8 --- /dev/null +++ b/scenes/Blocks/Patterns/L-Reverse/L-Reverse_Collision.tscn @@ -0,0 +1,4 @@ +[gd_scene format=3 uid="uid://w0ak23cjswln"] + +[node name="CollisionPolygon2D" type="CollisionPolygon2D"] +polygon = PackedVector2Array(48, -16, 48, -48, -80, -48, -80, -112, -112, -112, -112, -16) diff --git a/scenes/Blocks/Patterns/L-Reverse/L-Reverse_block_pattern.tscn b/scenes/Blocks/Patterns/L-Reverse/L-Reverse_block_pattern.tscn new file mode 100644 index 0000000..ef368d2 --- /dev/null +++ b/scenes/Blocks/Patterns/L-Reverse/L-Reverse_block_pattern.tscn @@ -0,0 +1,22 @@ +[gd_scene load_steps=4 format=3 uid="uid://1ubuiryqny62"] + +[ext_resource type="PackedScene" uid="uid://7knb2yqvkw6i" path="res://scenes/Blocks/Patterns/block_pattern.tscn" id="1_y8gyp"] +[ext_resource type="PackedScene" uid="uid://2v7wok4hnr6c" path="res://scenes/Blocks/Patterns/position_marker.tscn" id="2_tsq70"] +[ext_resource type="PackedScene" uid="uid://w0ak23cjswln" path="res://scenes/Blocks/Patterns/L-Reverse/L-Reverse_Collision.tscn" id="3_k23nd"] + +[node name="BlockPattern" instance=ExtResource("1_y8gyp")] + +[node name="PositionMarker" parent="Positions" index="0" instance=ExtResource("2_tsq70")] +position = Vector2(-64, 0) + +[node name="PositionMarker2" parent="Positions" index="1" instance=ExtResource("2_tsq70")] +turningPoint = true + +[node name="PositionMarker3" parent="Positions" index="2" instance=ExtResource("2_tsq70")] +position = Vector2(64, 0) + +[node name="PositionMarker4" parent="Positions" index="3" instance=ExtResource("2_tsq70")] +position = Vector2(-64, -64) + +[node name="CollisionPolygon2D" parent="CollisionTest" index="0" instance=ExtResource("3_k23nd")] +position = Vector2(32, 32) diff --git a/scenes/Blocks/Patterns/L/L_Collision.tscn b/scenes/Blocks/Patterns/L/L_Collision.tscn new file mode 100644 index 0000000..9f4c82b --- /dev/null +++ b/scenes/Blocks/Patterns/L/L_Collision.tscn @@ -0,0 +1,4 @@ +[gd_scene format=3 uid="uid://663ocu3x6tjb"] + +[node name="CollisionPolygon2D" type="CollisionPolygon2D"] +polygon = PackedVector2Array(48, 48, 48, -48, 16, -48, 16, 16, -112, 16, -112, 48) diff --git a/scenes/Blocks/Patterns/L/L_block_pattern.tscn b/scenes/Blocks/Patterns/L/L_block_pattern.tscn new file mode 100644 index 0000000..4c1e5f9 --- /dev/null +++ b/scenes/Blocks/Patterns/L/L_block_pattern.tscn @@ -0,0 +1,22 @@ +[gd_scene load_steps=4 format=3 uid="uid://d00ywshnytrdo"] + +[ext_resource type="PackedScene" uid="uid://7knb2yqvkw6i" path="res://scenes/Blocks/Patterns/block_pattern.tscn" id="1_e7pv8"] +[ext_resource type="PackedScene" uid="uid://2v7wok4hnr6c" path="res://scenes/Blocks/Patterns/position_marker.tscn" id="2_q62gn"] +[ext_resource type="PackedScene" uid="uid://663ocu3x6tjb" path="res://scenes/Blocks/Patterns/L/L_Collision.tscn" id="3_ji3us"] + +[node name="BlockPattern" instance=ExtResource("1_e7pv8")] + +[node name="PositionMarker" parent="Positions" index="0" instance=ExtResource("2_q62gn")] +position = Vector2(-64, 0) + +[node name="PositionMarker2" parent="Positions" index="1" instance=ExtResource("2_q62gn")] +turningPoint = true + +[node name="PositionMarker3" parent="Positions" index="2" instance=ExtResource("2_q62gn")] +position = Vector2(64, 0) + +[node name="PositionMarker4" parent="Positions" index="3" instance=ExtResource("2_q62gn")] +position = Vector2(64, -64) + +[node name="CollisionPolygon2D" parent="CollisionTest" index="0" instance=ExtResource("3_ji3us")] +position = Vector2(32, -32) diff --git a/scenes/Blocks/Patterns/T/T_Collision.tscn b/scenes/Blocks/Patterns/T/T_Collision.tscn new file mode 100644 index 0000000..fa7cc0b --- /dev/null +++ b/scenes/Blocks/Patterns/T/T_Collision.tscn @@ -0,0 +1,4 @@ +[gd_scene format=3 uid="uid://dwfkvfcrbxr43"] + +[node name="CollisionPolygon2D" type="CollisionPolygon2D"] +polygon = PackedVector2Array(-48, 48, 112, 48, 112, 16, 48, 16, 48, -48, 16, -48, 16, 16, -48, 16) diff --git a/scenes/Blocks/Patterns/T/T_block_pattern.tscn b/scenes/Blocks/Patterns/T/T_block_pattern.tscn new file mode 100644 index 0000000..4b981a4 --- /dev/null +++ b/scenes/Blocks/Patterns/T/T_block_pattern.tscn @@ -0,0 +1,22 @@ +[gd_scene load_steps=4 format=3 uid="uid://c25mwygtprl08"] + +[ext_resource type="PackedScene" uid="uid://7knb2yqvkw6i" path="res://scenes/Blocks/Patterns/block_pattern.tscn" id="1_1p2cg"] +[ext_resource type="PackedScene" uid="uid://2v7wok4hnr6c" path="res://scenes/Blocks/Patterns/position_marker.tscn" id="2_pponh"] +[ext_resource type="PackedScene" uid="uid://dwfkvfcrbxr43" path="res://scenes/Blocks/Patterns/T/T_Collision.tscn" id="3_svqqd"] + +[node name="BlockPattern" instance=ExtResource("1_1p2cg")] + +[node name="PositionMarker" parent="Positions" index="0" instance=ExtResource("2_pponh")] +position = Vector2(-64, 0) + +[node name="PositionMarker2" parent="Positions" index="1" instance=ExtResource("2_pponh")] +turningPoint = true + +[node name="PositionMarker3" parent="Positions" index="2" instance=ExtResource("2_pponh")] +position = Vector2(64, 0) + +[node name="PositionMarker4" parent="Positions" index="3" instance=ExtResource("2_pponh")] +position = Vector2(0, -64) + +[node name="CollisionPolygon2D" parent="CollisionTest" index="0" instance=ExtResource("3_svqqd")] +position = Vector2(-24, -32) diff --git a/scenes/Blocks/Patterns/Z-Reverse/Z-Reverse_Collision.tscn b/scenes/Blocks/Patterns/Z-Reverse/Z-Reverse_Collision.tscn new file mode 100644 index 0000000..0d31ea2 --- /dev/null +++ b/scenes/Blocks/Patterns/Z-Reverse/Z-Reverse_Collision.tscn @@ -0,0 +1,5 @@ +[gd_scene format=3 uid="uid://wv65ib41nt8v"] + +[node name="CollisionPolygon2D" type="CollisionPolygon2D"] +position = Vector2(32, -32) +polygon = PackedVector2Array(48, 48, 48, 16, -16, 16, -16, -48, -112, -48, -112, -16, -48, -16, -48, 48) diff --git a/scenes/Blocks/Patterns/Z-Reverse/Z-Reverse_block_pattern.tscn b/scenes/Blocks/Patterns/Z-Reverse/Z-Reverse_block_pattern.tscn new file mode 100644 index 0000000..8f0a555 --- /dev/null +++ b/scenes/Blocks/Patterns/Z-Reverse/Z-Reverse_block_pattern.tscn @@ -0,0 +1,21 @@ +[gd_scene load_steps=4 format=3 uid="uid://bnpmnhr43ls40"] + +[ext_resource type="PackedScene" uid="uid://7knb2yqvkw6i" path="res://scenes/Blocks/Patterns/block_pattern.tscn" id="1_skje3"] +[ext_resource type="PackedScene" uid="uid://2v7wok4hnr6c" path="res://scenes/Blocks/Patterns/position_marker.tscn" id="2_prllt"] +[ext_resource type="PackedScene" uid="uid://wv65ib41nt8v" path="res://scenes/Blocks/Patterns/Z-Reverse/Z-Reverse_Collision.tscn" id="3_xf113"] + +[node name="BlockPattern" instance=ExtResource("1_skje3")] + +[node name="PositionMarker" parent="Positions" index="0" instance=ExtResource("2_prllt")] +position = Vector2(-64, -64) + +[node name="PositionMarker2" parent="Positions" index="1" instance=ExtResource("2_prllt")] +position = Vector2(0, -64) + +[node name="PositionMarker3" parent="Positions" index="2" instance=ExtResource("2_prllt")] +turningPoint = true + +[node name="PositionMarker4" parent="Positions" index="3" instance=ExtResource("2_prllt")] +position = Vector2(64, 0) + +[node name="CollisionPolygon2D" parent="CollisionTest" index="0" instance=ExtResource("3_xf113")] diff --git a/scenes/Blocks/Patterns/Z/Z-Collision.tscn b/scenes/Blocks/Patterns/Z/Z-Collision.tscn new file mode 100644 index 0000000..91b637a --- /dev/null +++ b/scenes/Blocks/Patterns/Z/Z-Collision.tscn @@ -0,0 +1,4 @@ +[gd_scene format=3 uid="uid://dkugrxq2fo1vh"] + +[node name="CollisionPolygon2D" type="CollisionPolygon2D"] +polygon = PackedVector2Array(16, 16, 16, -48, 80, -48, 80, -80, -16, -80, -16, -16, -80, -16, -80, 16) diff --git a/scenes/Blocks/Patterns/Z/Z_block_pattern.tscn b/scenes/Blocks/Patterns/Z/Z_block_pattern.tscn new file mode 100644 index 0000000..380031b --- /dev/null +++ b/scenes/Blocks/Patterns/Z/Z_block_pattern.tscn @@ -0,0 +1,21 @@ +[gd_scene load_steps=4 format=3 uid="uid://ba70ybe7ico7f"] + +[ext_resource type="PackedScene" uid="uid://7knb2yqvkw6i" path="res://scenes/Blocks/Patterns/block_pattern.tscn" id="1_ccvbw"] +[ext_resource type="PackedScene" uid="uid://2v7wok4hnr6c" path="res://scenes/Blocks/Patterns/position_marker.tscn" id="2_y06oe"] +[ext_resource type="PackedScene" uid="uid://dkugrxq2fo1vh" path="res://scenes/Blocks/Patterns/Z/Z-Collision.tscn" id="3_0127o"] + +[node name="BlockPattern" instance=ExtResource("1_ccvbw")] + +[node name="PositionMarker" parent="Positions" index="0" instance=ExtResource("2_y06oe")] +position = Vector2(-64, 0) + +[node name="PositionMarker2" parent="Positions" index="1" instance=ExtResource("2_y06oe")] +turningPoint = true + +[node name="PositionMarker3" parent="Positions" index="2" instance=ExtResource("2_y06oe")] +position = Vector2(0, -64) + +[node name="PositionMarker4" parent="Positions" index="3" instance=ExtResource("2_y06oe")] +position = Vector2(64, -64) + +[node name="CollisionPolygon2D" parent="CollisionTest" index="0" instance=ExtResource("3_0127o")] diff --git a/scenes/Blocks/Patterns/block_pattern.gd b/scenes/Blocks/Patterns/block_pattern.gd new file mode 100644 index 0000000..bf5a205 --- /dev/null +++ b/scenes/Blocks/Patterns/block_pattern.gd @@ -0,0 +1,104 @@ +extends Node2D + +@onready var positions = $Positions +@onready var collision = $CollisionTest + +var lastDirection = null + +func getPositions(): + return positions.get_children() + +func checkDirection(): + var leftCollision = true + var rightCollision = true + positions.position.x = 0 + collision.position.x = 0 + if await getCollidingAreas() != []: + positions.position.x += GLOBAL.GRID + collision.position.x += GLOBAL.GRID + if await getCollidingAreas() == []: + rightCollision = false + else: + rightCollision = true + positions.position.x = 0 + collision.position.x = 0 + if await getCollidingAreas() != []: + positions.position.x -= GLOBAL.GRID + collision.position.x -= GLOBAL.GRID + if await getCollidingAreas() == []: + leftCollision = false + else: + leftCollision = true + positions.position.x = 0 + collision.position.x = 0 + if not rightCollision: + positions.position.x += GLOBAL.GRID + collision.position.x += GLOBAL.GRID + elif not leftCollision: + positions.position.x -= GLOBAL.GRID + collision.position.x -= GLOBAL.GRID + else: + positions.position.x = 0 + collision.position.x = 0 + +func turn(direction,newPosition): + positions.position.x = 0 + collision.position.x = 0 + position = newPosition + match direction: + GLOBAL.Direction.LEFT: + positions.rotation_degrees += 90 + collision.rotation_degrees += 90 + if await getCollidingAreas() != []: + checkDirection() + if await getCollidingAreas() != []: + positions.rotation_degrees += 90 + collision.rotation_degrees += 90 + + GLOBAL.Direction.RIGHT: + positions.rotation_degrees -= 90 + collision.rotation_degrees -= 90 + if await getCollidingAreas() != []: + checkDirection() + if await getCollidingAreas() != []: + positions.rotation_degrees -= 90 + collision.rotation_degrees -= 90 + #positions.rotation_degrees += 90 + #collision.rotation_degrees += 90 + + + +func getCollidingAreas(): + await get_tree().process_frame + await get_tree().process_frame + await get_tree().process_frame + await get_tree().process_frame + var collidingAreas = [] + for i in collision.get_overlapping_areas(): + if i.is_in_group("Block"): + if i.UID != GLOBAL.currentUID: + collidingAreas.append(i) + else: + collidingAreas.append(i) + return collidingAreas + + +#func _on_collision_test_area_entered(area: Area2D) -> void: + #if lastDirection == null: + #checkLeft() + #else: + #if lastDirection == GLOBAL.Direction.LEFT: + #print(getCollidingAreas()) + #checkRight() + #if lastDirection == GLOBAL.Direction.LEFT: + #print(getCollidingAreas()) + #print(collision.get_overlapping_areas()) + #print(getCollidingAreas()) + #print(checkLeft()) + #print(checkRight()) + +func reset(newPosition): + position = newPosition + positions.position.x = 0 + collision.position.x = 0 + rotation_degrees = 0 diff --git a/scenes/Blocks/Patterns/block_pattern.tscn b/scenes/Blocks/Patterns/block_pattern.tscn new file mode 100644 index 0000000..649a5ce --- /dev/null +++ b/scenes/Blocks/Patterns/block_pattern.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=2 format=3 uid="uid://7knb2yqvkw6i"] + +[ext_resource type="Script" path="res://scenes/Blocks/Patterns/block_pattern.gd" id="1_ne3bj"] + +[node name="BlockPattern" type="Node2D"] +script = ExtResource("1_ne3bj") + +[node name="Positions" type="Node2D" parent="."] + +[node name="CollisionTest" type="Area2D" parent="."] +collision_layer = 8 +collision_mask = 3 diff --git a/scenes/Blocks/Patterns/position_marker.gd b/scenes/Blocks/Patterns/position_marker.gd new file mode 100644 index 0000000..0755fdb --- /dev/null +++ b/scenes/Blocks/Patterns/position_marker.gd @@ -0,0 +1,3 @@ +extends Marker2D + +@export var turningPoint = false diff --git a/scenes/Blocks/Patterns/position_marker.tscn b/scenes/Blocks/Patterns/position_marker.tscn new file mode 100644 index 0000000..4009581 --- /dev/null +++ b/scenes/Blocks/Patterns/position_marker.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://2v7wok4hnr6c"] + +[ext_resource type="Script" path="res://scenes/Blocks/Patterns/position_marker.gd" id="1_775kb"] + +[node name="PositionMarker" type="Marker2D"] +script = ExtResource("1_775kb") diff --git a/scenes/Blocks/block.gd b/scenes/Blocks/block.gd new file mode 100644 index 0000000..1928af9 --- /dev/null +++ b/scenes/Blocks/block.gd @@ -0,0 +1,88 @@ +extends Area2D + +@onready var floorRaycast = $RaycastFloor +@onready var raycastLeft = $RaycastLeft +@onready var raycastRight = $RaycastRight + +@export var UID = 1 + +var secretPosition = Vector2() + +var turningPoint = false + +var type = GLOBAL.BLOCKTYPES.LIGHT + +func _ready() -> void: + secretPosition = position + +#func _physics_process(delta: float) -> void: + #print(secretPosition) + #print(getNeighbours()) + #print(getNeighboursUID(UID)) +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _physics_process(delta: float) -> void: + #if not getIsOnFloor(): + # position = secretPosition.snapped(Vector2(64,64)) + #if Input.is_action_just_pressed("left"): + # if not raycastLeft.is_colliding(): + # secretPosition.x -= GLOBAL.GRID + #if Input.is_action_just_pressed("right"): + # if not raycastRight.is_colliding(): + # secretPosition.x += GLOBAL.GRID + #secretPosition.y += GLOBAL.currentSpeed * delta * 30 + +func getIsOnFloor() -> bool: + return floorRaycast.is_colliding() + +#func getFloorCollider(): + #return floorRaycast.get_collider() + # +#func getLeftCollider(): + #return raycastLeft.get_collider() + # +#func getRightCollider(): + #return raycastRight.get_collider() + +func getLeftColliding() -> bool: + return raycastLeft.is_colliding() + +func getRightColliding() -> bool: + return raycastRight.is_colliding() + +func getCollider(direction : GLOBAL.Direction): + match direction: + GLOBAL.Direction.BOTTOM: + return floorRaycast.get_collider() + GLOBAL.Direction.LEFT: + return raycastLeft.get_collider() + GLOBAL.Direction.RIGHT: + return raycastRight.get_collider() + + +func getNeighbours(): + var neighbours = [] + for i in get_overlapping_areas(): + if i.is_in_group("Block"): + neighbours.append(i) + return neighbours + +func getNeighboursUID(uid): + var neighbours = [] + for i in get_overlapping_areas(): + if i.is_in_group("Block"): + if i.UID == uid: + neighbours.append(i) + return neighbours + +func move(x,y): + secretPosition = position + secretPosition.x += x + secretPosition.y += y + position = secretPosition.snapped(Vector2(64, 64)) + +func moveDown(): + move(0, 64) +func moveLeft(): + move(-64, 0) +func moveRight(): + move(64, 0) diff --git a/scenes/Blocks/block.tscn b/scenes/Blocks/block.tscn new file mode 100644 index 0000000..5ef5f20 --- /dev/null +++ b/scenes/Blocks/block.tscn @@ -0,0 +1,43 @@ +[gd_scene load_steps=4 format=3 uid="uid://do8gr42oq2a0y"] + +[ext_resource type="Script" path="res://scenes/Blocks/block.gd" id="1_t1hpt"] + +[sub_resource type="QuadMesh" id="QuadMesh_lsuac"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_gvev2"] +size = Vector2(80, 80) + +[node name="Block" type="Area2D" groups=["Block"]] +collision_layer = 2 +collision_mask = 14 +script = ExtResource("1_t1hpt") + +[node name="MeshInstance2D" type="MeshInstance2D" parent="."] +position = Vector2(31, 31) +scale = Vector2(62, 62) +mesh = SubResource("QuadMesh_lsuac") + +[node name="RaycastFloor" type="RayCast2D" parent="."] +position = Vector2(32, 72) +target_position = Vector2(0, 32) +collision_mask = 3 +hit_from_inside = true +collide_with_areas = true + +[node name="RaycastLeft" type="RayCast2D" parent="."] +position = Vector2(-8, 32) +target_position = Vector2(-32, 0) +collision_mask = 3 +hit_from_inside = true +collide_with_areas = true + +[node name="RaycastRight" type="RayCast2D" parent="."] +position = Vector2(72, 32) +target_position = Vector2(32, 0) +collision_mask = 3 +hit_from_inside = true +collide_with_areas = true + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2(32, 32) +shape = SubResource("RectangleShape2D_gvev2") diff --git a/scenes/Globals/global.gd b/scenes/Globals/global.gd index 18502f6..37e20f4 100644 --- a/scenes/Globals/global.gd +++ b/scenes/Globals/global.gd @@ -12,29 +12,22 @@ const GRID := 64 enum BLOCKTYPES {LIGHT, HEAVY} -const BLOCKS : Dictionary = { - "1x3": "res://scenes/Block/1x3/1x3_block.tscn", - "1x4": "res://scenes/Block/1x4/1x4_block.tscn", - "2x2": "res://scenes/Block/2x2/2x2_block.tscn", - "2x3": "res://scenes/Block/2x3/2x3_block.tscn", - "T": "res://scenes/Block/T/T_block.tscn", - "L": "res://scenes/Block/L/L_block.tscn", - "L-small": "res://scenes/Block/L-small/L-small_block.tscn", - "Snake": "res://scenes/Block/Snake/Snake_block.tscn", - "Fork": "res://scenes/Block/Fork/Fork_block.tscn" +const BLOCKSPATTERS : Dictionary = { + "Z": "res://scenes/Blocks/Patterns/Z/Z_block_pattern.tscn", + "L": "res://scenes/Blocks/Patterns/L/L_block_pattern.tscn", + "L-Reverse": "res://scenes/Blocks/Patterns/L-Reverse/L-Reverse_block_pattern.tscn", + "Z-Reverse": "res://scenes/Blocks/Patterns/Z-Reverse/Z-Reverse_block_pattern.tscn", + "2x2": "res://scenes/Blocks/Patterns/2x2/2x2_block_pattern.tscn", + "T": "res://scenes/Blocks/Patterns/T/T_block_pattern.tscn", + "I": "res://scenes/Blocks/Patterns/I/I_block_pattern.tscn", + "1x3": "res://scenes/Blocks/Patterns/1x3/1x3_block_pattern.tscn" } +enum Direction {BOTTOM, LEFT, RIGHT} -var lastId = 0 +var lastUID = 1 -var currentBlock = null +var currentUID = lastUID -func getNewId() -> int: - lastId += 1 - return lastId - -func _physics_process(delta: float) -> void: - - - if currentBlock != null: - if currentBlock.stopped: - hasSelectedSpeed = false +func getNewUID() -> int: + lastUID += 1 + return lastUID diff --git a/scenes/Grid/border.tscn b/scenes/Grid/border.tscn index 1046ab6..76db480 100644 --- a/scenes/Grid/border.tscn +++ b/scenes/Grid/border.tscn @@ -1,7 +1,5 @@ [gd_scene format=3 uid="uid://bm7rshwf6pjb"] [node name="Border" type="Area2D"] -collision_layer = 9 -collision_mask = 21 [node name="CollisionShape2D" type="CollisionShape2D" parent="."] diff --git a/scenes/Grid/grid.gd b/scenes/Grid/grid.gd index 8846f75..030fc22 100644 --- a/scenes/Grid/grid.gd +++ b/scenes/Grid/grid.gd @@ -1,13 +1,18 @@ extends Node2D @onready var spawnpoint = $Spawnpoint +@onready var blocks = $Blocks +@onready var tickerTimer = $Ticker +@onready var patterns = $Patterns +@onready var turnTickTimer = $TurnTick var nextBlocks = [] -# Called when the node enters the scene tree for the first time. -func _ready() -> void: - fillNextBlocks() - spawnBlock() +var currentPattern = null + +var patternsArray = [] + +var blockSpeed = 0.4 func spawnBlock() -> void: var block = nextBlocks[0] @@ -17,11 +22,37 @@ func spawnBlock() -> void: if nextBlocks.size() < 2: fillNextBlocks() +func _ready() -> void: + tickerTimer.start(blockSpeed) + getNewPatterns() + PlacePattern() func _physics_process(delta: float) -> void: - if GLOBAL.currentBlock != null: - if GLOBAL.currentBlock.stopped: - spawnBlock() + for i in getBlockGroupsList(): + if i != GLOBAL.currentUID: + moveUidGroup(GLOBAL.Direction.BOTTOM, i) + var blockGroups = getBlockGroupsList() + if Input.is_action_just_pressed("rotate_right"): + for i in blockGroups[GLOBAL.currentUID]: + if i.turningPoint: + if currentPattern != null: + currentPattern.turn(GLOBAL.Direction.RIGHT,i.position + Vector2(GLOBAL.GRID/2, GLOBAL.GRID/2)) + if turnTickTimer.is_stopped(): + turnTickTimer.start(0.18) + + + if Input.is_action_just_pressed("rotate_left"): + for i in blockGroups[GLOBAL.currentUID]: + if i.turningPoint: + if currentPattern != null: + currentPattern.turn(GLOBAL.Direction.LEFT,i.position + Vector2(GLOBAL.GRID/2, GLOBAL.GRID/2)) + if turnTickTimer.is_stopped(): + turnTickTimer.start(0.18) + + if Input.is_action_just_pressed("left"): + moveUidGroup(GLOBAL.Direction.LEFT, GLOBAL.currentUID) + if Input.is_action_just_pressed("right"): + moveUidGroup(GLOBAL.Direction.RIGHT, GLOBAL.currentUID) func fillNextBlocks(): @@ -35,3 +66,142 @@ func fillNextBlocks(): newBlocks[0].setType(GLOBAL.BLOCKTYPES.HEAVY) newBlocks.shuffle() nextBlocks.append_array(newBlocks) + + + + +## returns a Dictionary with the UIDs as the Key and a List of the Blocks as the content +func getBlockGroupsList(): + var blockLists : Dictionary = {} + for i in blocks.get_children(): + if not blockLists.has(i.UID): + blockLists[i.UID] = [] + blockLists[i.UID].append(i) + return blockLists + + +func getBlockedDirection(direction : GLOBAL.Direction, uid : int) -> bool: + #var blockslist = getBlockGroupsList() + var isBlocked = false + #print(getBlockGroupsList()) + if getBlockGroupsList().has(uid): + for i in getBlockGroupsList()[uid]: + if i.getCollider(direction) != null: + if i.getCollider(direction).is_in_group("Block"): + if i.getCollider(direction).UID != i.UID: + isBlocked = true + else: + isBlocked = true + return isBlocked + return true + +func splitOphansUID(uid): + var compareList = {} + #print(uid) + #print(getBlockGroupsList()[uid]) + var group = [] + for i in getBlockGroupsList()[uid]: + compareList[i] = i.getNeighboursUID(uid) + #if i.getNeighboursUID(uid) == []: + # i.UID = GLOBAL.getNewUID() + #print(i.getNeighboursUID(uid)) + if i.getNeighboursUID(uid) == []: + i.UID = GLOBAL.getNewUID() + + for i in compareList: + group.insert(0, compareList[i]) + group[0].append(i) + for j in group[0]: + if compareList[i].has(j) and not group[0].has(j): + group[0].append(j) + + for i in group: + var newUID = GLOBAL.getNewUID() + for j in i: + j.UID = newUID + +func moveUidGroup(direction, uid): + match direction: + GLOBAL.Direction.BOTTOM: + for i in getBlockGroupsList()[uid]: + if not getBlockedDirection(GLOBAL.Direction.BOTTOM, i.UID): + i.moveDown() + GLOBAL.Direction.LEFT: + for i in getBlockGroupsList()[uid]: + if not getBlockedDirection(GLOBAL.Direction.LEFT, i.UID): + i.moveLeft() + GLOBAL.Direction.RIGHT: + for i in getBlockGroupsList()[uid]: + if not getBlockedDirection(GLOBAL.Direction.RIGHT, i.UID): + i.moveRight() + +func PlacePattern(): + patternsArray.pop_at(0) + for child in patterns.get_children(): + child.queue_free() + currentPattern = patternsArray[0] + patterns.add_child(currentPattern) + getNewPatterns() + var newUID = GLOBAL.getNewUID() + GLOBAL.currentUID = newUID + var newColor = Color.from_hsv((randi() % 12) / 12.0, 1, 1) + for i in patterns.get_children(): + i.reset(Vector2()) + if currentPattern != null: + for i in currentPattern.getPositions(): + var block = load("res://scenes/Blocks/block.tscn").instantiate() + block.UID = newUID + block.modulate = newColor + block.position = spawnpoint.position + i.position + + if i.turningPoint: + block.turningPoint = true + blocks.add_child(block) + + +func getNewPatterns(): + var newPatterns = [] + for i in GLOBAL.BLOCKSPATTERS: + print(i) + newPatterns.append(load(GLOBAL.BLOCKSPATTERS[i]).instantiate()) + newPatterns.shuffle() + #newPatterns[0].type = GLOBAL.BLOCKTYPES.HEAVY + newPatterns.shuffle() + patternsArray.append_array(newPatterns) + +func turnBlocks(): + var turningPointBlock + for g in currentPattern.getPositions().size(): + if not getBlockGroupsList()[GLOBAL.currentUID][g].turningPoint: + getBlockGroupsList()[GLOBAL.currentUID][g].global_position = currentPattern.getPositions()[g].global_position- Vector2(32,32) + else: + turningPointBlock = getBlockGroupsList()[GLOBAL.currentUID][g] + for g in currentPattern.getPositions(): + if g.turningPoint: + turningPointBlock.global_position = g.global_position- Vector2(32,32) + +func _on_turn_tick_timeout() -> void: + turnBlocks() + +func _on_ticker_timeout() -> void: + for i in $RowTests.get_children(): + #print(i.getRow()) + #print(i.get_name(), ": ", i.getRow().size(), ": ",i.getRow()) + if i.getRow().size() >= 10: + for j in i.getRow(): + splitOphansUID(j.UID) + GLOBAL.points += j.type + j.queue_free() + #for i in getBlockGroupsList(): + # splitOphansUID(i) + if getBlockedDirection(GLOBAL.Direction.BOTTOM, GLOBAL.currentUID): + PlacePattern() + #print(getBlockGroupsList()) + #print(getBlockGroupsList()[3]) + #for i in getBlockGroupsList(): + # splitOphansUID(i) + + for i in getBlockGroupsList(): + moveUidGroup(GLOBAL.Direction.BOTTOM, i) + + tickerTimer.start(blockSpeed) diff --git a/scenes/Grid/grid.tscn b/scenes/Grid/grid.tscn index bf4b7ad..c33b22e 100644 --- a/scenes/Grid/grid.tscn +++ b/scenes/Grid/grid.tscn @@ -42,14 +42,13 @@ shape = SubResource("RectangleShape2D_flipi") [node name="Bottom" parent="." instance=ExtResource("5_14njh")] position = Vector2(320, 1312) -collision_layer = 8 -collision_mask = 4 +collision_mask = 2 [node name="CollisionShape2D" parent="Bottom" index="0"] shape = SubResource("RectangleShape2D_rxd0s") [node name="Spawnpoint" type="Marker2D" parent="."] -position = Vector2(320, -64) +position = Vector2(256, -128) [node name="RowTests" type="Node2D" parent="."] @@ -113,6 +112,17 @@ position = Vector2(0, 96) [node name="rowTest20" parent="RowTests" instance=ExtResource("4_si3v6")] position = Vector2(0, 32) +[node name="Ticker" type="Timer" parent="."] + +[node name="Patterns" type="Node2D" parent="."] + +[node name="TurnTick" type="Timer" parent="."] +wait_time = 0.1 +one_shot = true + +[connection signal="timeout" from="Ticker" to="." method="_on_ticker_timeout"] +[connection signal="timeout" from="TurnTick" to="." method="_on_turn_tick_timeout"] + [editable path="Border"] [editable path="Border2"] [editable path="Bottom"] diff --git a/scenes/Grid/row_test.gd b/scenes/Grid/row_test.gd index a60fb86..39b310f 100644 --- a/scenes/Grid/row_test.gd +++ b/scenes/Grid/row_test.gd @@ -1,7 +1,10 @@ extends Area2D -func _physics_process(delta: float) -> void: - if get_overlapping_areas().size() == 10 and GLOBAL.currentBlock.stopped: - for i in get_overlapping_areas(): - GLOBAL.points += i.points - i.queue_free()#get_parent().get_parent().split() +#func _physics_process(delta: float) -> void: + #if get_overlapping_areas().size() == 10: + #for i in get_overlapping_areas(): + #GLOBAL.points += i.points + #i.queue_free()#get_parent().get_parent().split() + +func getRow(): + return get_overlapping_areas() diff --git a/scenes/Grid/speed_scale.gd b/scenes/Grid/speed_scale.gd index 8fe0613..0c80ced 100644 --- a/scenes/Grid/speed_scale.gd +++ b/scenes/Grid/speed_scale.gd @@ -7,4 +7,3 @@ func _physics_process(delta: float) -> void: if Input.is_action_just_pressed("stop"): GLOBAL.hasSelectedSpeed = true GLOBAL.currentSpeed = GLOBAL.SPEED.MAX - print()