From 885351b624f332458892e78a80e365af00afcfb3 Mon Sep 17 00:00:00 2001 From: Exobyt Date: Sat, 17 Aug 2024 19:46:21 +0200 Subject: [PATCH] Erster Prototyp --- assets/Slider.png | Bin 0 -> 103 bytes assets/Slider.png.import | 34 +++++ assets/Slider.pxo | Bin 0 -> 598 bytes assets/SpeedScale.png | Bin 0 -> 128 bytes assets/SpeedScale.png.import | 34 +++++ assets/SpeedScale.pxo | Bin 0 -> 601 bytes project.godot | 27 ++++ scenes/Block/1x3/1x3_Collision.tscn | 4 + scenes/Block/1x3/1x3_block.gd | 1 + scenes/Block/1x3/1x3_block.tscn | 58 ++++++++ scenes/Block/1x4/1x4_Collision.tscn | 4 + scenes/Block/1x4/1x4_block.gd | 1 + scenes/Block/1x4/1x4_block.tscn | 70 +++++++++ scenes/Block/2x2/2x2_Collision.tscn | 4 + scenes/Block/2x2/2x2_block.gd | 1 + scenes/Block/2x2/2x2_block.tscn | 64 +++++++++ scenes/Block/2x3/2x3_Collision.tscn | 4 + scenes/Block/2x3/2x3_block.gd | 1 + scenes/Block/2x3/2x3_block.tscn | 90 ++++++++++++ scenes/Block/Fork/Fork_Collision.tscn | 4 + scenes/Block/Fork/Fork_block.gd | 1 + scenes/Block/Fork/Fork_block.tscn | 91 ++++++++++++ scenes/Block/L-small/L-small_Collision.tscn | 4 + scenes/Block/L-small/L-small_block.gd | 1 + scenes/Block/L-small/L-small_block.tscn | 55 +++++++ scenes/Block/L/L_Collision.tscn | 4 + scenes/Block/L/L_block.gd | 1 + scenes/Block/L/L_block.tscn | 69 +++++++++ scenes/Block/Snake/Snake_Collision.tscn | 4 + scenes/Block/Snake/Snake_block.gd | 1 + scenes/Block/Snake/Snake_block.tscn | 66 +++++++++ scenes/Block/T/T_Collision.tscn | 4 + scenes/Block/T/T_block.gd | 1 + scenes/Block/T/T_block.tscn | 86 +++++++++++ scenes/Block/block.gd | 150 ++++++++++++++++++++ scenes/Block/block.tscn | 40 ++++++ scenes/Block/block_part.gd | 33 +++++ scenes/Block/block_part.tscn | 50 +++++++ scenes/Globals/global.gd | 40 ++++++ scenes/Grid/SpeedScale.tscn | 33 +++++ scenes/Grid/border.tscn | 7 + scenes/Grid/bottom.tscn | 5 + scenes/Grid/grid.gd | 37 +++++ scenes/Grid/grid.tscn | 118 +++++++++++++++ scenes/Grid/row_test.gd | 7 + scenes/Grid/row_test.tscn | 15 ++ scenes/Grid/speed_scale.gd | 10 ++ scenes/Main/main.tscn | 16 +++ 48 files changed, 1350 insertions(+) create mode 100644 assets/Slider.png create mode 100644 assets/Slider.png.import create mode 100644 assets/Slider.pxo create mode 100644 assets/SpeedScale.png create mode 100644 assets/SpeedScale.png.import create mode 100644 assets/SpeedScale.pxo create mode 100644 scenes/Block/1x3/1x3_Collision.tscn create mode 100644 scenes/Block/1x3/1x3_block.gd create mode 100644 scenes/Block/1x3/1x3_block.tscn create mode 100644 scenes/Block/1x4/1x4_Collision.tscn create mode 100644 scenes/Block/1x4/1x4_block.gd create mode 100644 scenes/Block/1x4/1x4_block.tscn create mode 100644 scenes/Block/2x2/2x2_Collision.tscn create mode 100644 scenes/Block/2x2/2x2_block.gd create mode 100644 scenes/Block/2x2/2x2_block.tscn create mode 100644 scenes/Block/2x3/2x3_Collision.tscn create mode 100644 scenes/Block/2x3/2x3_block.gd create mode 100644 scenes/Block/2x3/2x3_block.tscn create mode 100644 scenes/Block/Fork/Fork_Collision.tscn create mode 100644 scenes/Block/Fork/Fork_block.gd create mode 100644 scenes/Block/Fork/Fork_block.tscn create mode 100644 scenes/Block/L-small/L-small_Collision.tscn create mode 100644 scenes/Block/L-small/L-small_block.gd create mode 100644 scenes/Block/L-small/L-small_block.tscn create mode 100644 scenes/Block/L/L_Collision.tscn create mode 100644 scenes/Block/L/L_block.gd create mode 100644 scenes/Block/L/L_block.tscn create mode 100644 scenes/Block/Snake/Snake_Collision.tscn create mode 100644 scenes/Block/Snake/Snake_block.gd create mode 100644 scenes/Block/Snake/Snake_block.tscn create mode 100644 scenes/Block/T/T_Collision.tscn create mode 100644 scenes/Block/T/T_block.gd create mode 100644 scenes/Block/T/T_block.tscn create mode 100644 scenes/Block/block.gd create mode 100644 scenes/Block/block.tscn create mode 100644 scenes/Block/block_part.gd create mode 100644 scenes/Block/block_part.tscn create mode 100644 scenes/Grid/SpeedScale.tscn create mode 100644 scenes/Grid/border.tscn create mode 100644 scenes/Grid/bottom.tscn create mode 100644 scenes/Grid/grid.gd create mode 100644 scenes/Grid/grid.tscn create mode 100644 scenes/Grid/row_test.gd create mode 100644 scenes/Grid/row_test.tscn create mode 100644 scenes/Grid/speed_scale.gd create mode 100644 scenes/Main/main.tscn diff --git a/assets/Slider.png b/assets/Slider.png new file mode 100644 index 0000000000000000000000000000000000000000..8666b465c8a8dacee87f786c8097ddd3d68cf825 GIT binary patch literal 103 zcmeAS@N?(olHy`uVBq!ia0vp^JV4CC!3HFEsom=WQjEnx?oJHr&dIz4auhvX978x} zCMPHe8W{*?IZ!c!r>mdKI;Vst0Lo+> A&j0`b literal 0 HcmV?d00001 diff --git a/assets/Slider.png.import b/assets/Slider.png.import new file mode 100644 index 0000000..c7d1985 --- /dev/null +++ b/assets/Slider.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dbspjkdc5q1mc" +path="res://.godot/imported/Slider.png-7121d2749dc259e03f67f754efc5d0ba.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/Slider.png" +dest_files=["res://.godot/imported/Slider.png-7121d2749dc259e03f67f754efc5d0ba.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/Slider.pxo b/assets/Slider.pxo new file mode 100644 index 0000000000000000000000000000000000000000..da98ab627b578226b94e66f58baa65b2d30d9386 GIT binary patch literal 598 zcmWIWW@Zs#VBp|jsGJ}e$!+R3C4iBEp^b@wfs=uOAtkXSQ7@}FKQDLU-MnT4p4Rx( zPo}O*W4|B%J1=2+u&AVgNtDMT6@!ec<@1@p_}>R*AX4begTtabx&golMwiH*^)7N?5^Vy1nw{u#o>I|Q%lG1(lsZ^Yt z=Lg=+XM>7YrRyD^7QQPmLisDp{M47x+it4f{!;sUS91D+w3&jBW*^h;auj*7bU)7@ z?H=KKYwhpx{QvgcWUjh;T1~1296N k03M&{+R$A9)4;$`4%CguJptaVY#_xV!Z literal 0 HcmV?d00001 diff --git a/assets/SpeedScale.png b/assets/SpeedScale.png new file mode 100644 index 0000000000000000000000000000000000000000..cd6962faffaf0e2be3576a61898b203396dffbfc GIT binary patch literal 128 zcmeAS@N?(olHy`uVBq!ia0vp^Aa)7|8<5<8X5n-o#aJBV?!>U}oXkrg$I8>iF(jh( z?b(Bz3<^998@1+MRE!M@f8ng*^iFn%ptYaKEK!zy%{y;jQ~05JCL%UlfW;An{;gTe~DWM4faxx`U literal 0 HcmV?d00001 diff --git a/assets/SpeedScale.png.import b/assets/SpeedScale.png.import new file mode 100644 index 0000000..6064647 --- /dev/null +++ b/assets/SpeedScale.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://blj4h34gr3s0q" +path="res://.godot/imported/SpeedScale.png-1c213110fe8f036530597123ee8887de.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/SpeedScale.png" +dest_files=["res://.godot/imported/SpeedScale.png-1c213110fe8f036530597123ee8887de.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/SpeedScale.pxo b/assets/SpeedScale.pxo new file mode 100644 index 0000000000000000000000000000000000000000..ecfadfca5f936e93b44d07de443d7d17970c1645 GIT binary patch literal 601 zcmWIWW@Zs#VBp|j=;{-UT(9dT>c+^x(8R>Rz{$YCkdj!EsFziopO-uFVqUWWk86GE zC*!palhvkvuRR*#%Eq%*YLW&gPt@1@&mAJ8bNyNF$NZLi&NWs3P$$!r_~SeoMc3S~ zZc@7%bw9bqs9sn44X2lc&yy7^8+oGC-|_#fni#ZL`^u8*&i;bZJseNJPHQZUD4w%W z$7qL!8L#i9|7y*%4<@H%i@m%#REoc9|=EQ|)#hA8zp-h3Z&Tf7?^Uy+dW$#-jEzjlo8WkmQ zvZsDwR&BWM*r$FeY+7rU$h20eV@dPhcgJ?jm{XLwiT|rDv%l`i6|+RX-^jhqQKP78 zt@G)(< 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 new file mode 100644 index 0000000..17fabb5 --- /dev/null +++ b/scenes/Block/block.tscn @@ -0,0 +1,40 @@ +[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 new file mode 100644 index 0000000..40379c5 --- /dev/null +++ b/scenes/Block/block_part.gd @@ -0,0 +1,33 @@ +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 new file mode 100644 index 0000000..3b6c2fa --- /dev/null +++ b/scenes/Block/block_part.tscn @@ -0,0 +1,50 @@ +[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/Globals/global.gd b/scenes/Globals/global.gd index e69de29..18502f6 100644 --- a/scenes/Globals/global.gd +++ b/scenes/Globals/global.gd @@ -0,0 +1,40 @@ +extends Node + +var points = 0 + +enum SPEED {MIN= 5, MAX= 12} + +var currentSpeed := SPEED.MIN + +var hasSelectedSpeed = false + +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" +} + +var lastId = 0 + +var currentBlock = null + +func getNewId() -> int: + lastId += 1 + return lastId + +func _physics_process(delta: float) -> void: + + + if currentBlock != null: + if currentBlock.stopped: + hasSelectedSpeed = false diff --git a/scenes/Grid/SpeedScale.tscn b/scenes/Grid/SpeedScale.tscn new file mode 100644 index 0000000..f26ccd3 --- /dev/null +++ b/scenes/Grid/SpeedScale.tscn @@ -0,0 +1,33 @@ +[gd_scene load_steps=5 format=3 uid="uid://c03h0nwewolfx"] + +[ext_resource type="Texture2D" uid="uid://dbspjkdc5q1mc" path="res://assets/Slider.png" id="1_idpo1"] +[ext_resource type="Texture2D" uid="uid://blj4h34gr3s0q" path="res://assets/SpeedScale.png" id="1_otl7y"] +[ext_resource type="Script" path="res://scenes/Grid/speed_scale.gd" id="1_w2ui3"] + +[sub_resource type="Curve2D" id="Curve2D_jnpcs"] +_data = { +"points": PackedVector2Array(0, 0, 0, 0, 0, 628, 0, 0, 0, 0, 0, -636) +} +point_count = 2 + +[node name="SpeedScale" type="Node2D"] +script = ExtResource("1_w2ui3") + +[node name="Sprite2D" type="Sprite2D" parent="."] +scale = Vector2(12.8, 12.8) +texture = ExtResource("1_otl7y") + +[node name="Path2D" type="Path2D" parent="."] +position = Vector2(0, 3.94867) +scale = Vector2(1, 0.99359) +curve = SubResource("Curve2D_jnpcs") + +[node name="Slider" type="PathFollow2D" parent="Path2D"] +position = Vector2(0, -636) +progress = 1264.0 +rotates = false +loop = false + +[node name="Sprite2D" type="Sprite2D" parent="Path2D/Slider"] +scale = Vector2(12.8, 12.8) +texture = ExtResource("1_idpo1") diff --git a/scenes/Grid/border.tscn b/scenes/Grid/border.tscn new file mode 100644 index 0000000..1046ab6 --- /dev/null +++ b/scenes/Grid/border.tscn @@ -0,0 +1,7 @@ +[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/bottom.tscn b/scenes/Grid/bottom.tscn new file mode 100644 index 0000000..90fe818 --- /dev/null +++ b/scenes/Grid/bottom.tscn @@ -0,0 +1,5 @@ +[gd_scene load_steps=2 format=3 uid="uid://dvrotjxom4u6d"] + +[ext_resource type="PackedScene" uid="uid://bm7rshwf6pjb" path="res://scenes/Grid/border.tscn" id="1_djp4e"] + +[node name="Bottom" instance=ExtResource("1_djp4e")] diff --git a/scenes/Grid/grid.gd b/scenes/Grid/grid.gd new file mode 100644 index 0000000..8846f75 --- /dev/null +++ b/scenes/Grid/grid.gd @@ -0,0 +1,37 @@ +extends Node2D + +@onready var spawnpoint = $Spawnpoint + +var nextBlocks = [] + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + fillNextBlocks() + spawnBlock() + +func spawnBlock() -> void: + var block = nextBlocks[0] + GLOBAL.currentBlock = block + spawnpoint.add_child(block) + nextBlocks.pop_at(0) + if nextBlocks.size() < 2: + fillNextBlocks() + + +func _physics_process(delta: float) -> void: + if GLOBAL.currentBlock != null: + if GLOBAL.currentBlock.stopped: + spawnBlock() + + +func fillNextBlocks(): + var newBlocks = [] + for i in GLOBAL.BLOCKS: + var block = load(GLOBAL.BLOCKS[i]).instantiate() + block.setId(GLOBAL.getNewId()) + block.setType(GLOBAL.BLOCKTYPES.LIGHT) + newBlocks.append(block) + newBlocks.shuffle() + newBlocks[0].setType(GLOBAL.BLOCKTYPES.HEAVY) + newBlocks.shuffle() + nextBlocks.append_array(newBlocks) diff --git a/scenes/Grid/grid.tscn b/scenes/Grid/grid.tscn new file mode 100644 index 0000000..bf4b7ad --- /dev/null +++ b/scenes/Grid/grid.tscn @@ -0,0 +1,118 @@ +[gd_scene load_steps=8 format=3 uid="uid://dwl4lotl1d3ij"] + +[ext_resource type="Script" path="res://scenes/Grid/grid.gd" id="1_vie5m"] +[ext_resource type="PackedScene" uid="uid://bm7rshwf6pjb" path="res://scenes/Grid/border.tscn" id="4_3j08q"] +[ext_resource type="PackedScene" uid="uid://duubii5uu3lgq" path="res://scenes/Grid/row_test.tscn" id="4_si3v6"] +[ext_resource type="PackedScene" uid="uid://dvrotjxom4u6d" path="res://scenes/Grid/bottom.tscn" id="5_14njh"] + +[sub_resource type="QuadMesh" id="QuadMesh_qfjsc"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_flipi"] +size = Vector2(128, 1536) + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_rxd0s"] +size = Vector2(896, 64) + +[node name="Grid" type="Node2D"] +script = ExtResource("1_vie5m") + +[node name="Sprite2D" type="Sprite2D" parent="."] +position = Vector2(7.62939e-06, 7.62939e-06) +scale = Vector2(108.422, 96.375) + +[node name="MeshInstance2D" type="MeshInstance2D" parent="."] +modulate = Color(0.359096, 0.426588, 0.599397, 1) +position = Vector2(320, 640) +scale = Vector2(640, 1280) +mesh = SubResource("QuadMesh_qfjsc") + +[node name="Blocks" type="Node2D" parent="."] + +[node name="Border" parent="." instance=ExtResource("4_3j08q")] + +[node name="CollisionShape2D" parent="Border" index="0"] +position = Vector2(-64, 512) +shape = SubResource("RectangleShape2D_flipi") + +[node name="Border2" parent="." instance=ExtResource("4_3j08q")] + +[node name="CollisionShape2D" parent="Border2" index="0"] +position = Vector2(704, 512) +shape = SubResource("RectangleShape2D_flipi") + +[node name="Bottom" parent="." instance=ExtResource("5_14njh")] +position = Vector2(320, 1312) +collision_layer = 8 +collision_mask = 4 + +[node name="CollisionShape2D" parent="Bottom" index="0"] +shape = SubResource("RectangleShape2D_rxd0s") + +[node name="Spawnpoint" type="Marker2D" parent="."] +position = Vector2(320, -64) + +[node name="RowTests" type="Node2D" parent="."] + +[node name="rowTest" parent="RowTests" instance=ExtResource("4_si3v6")] +position = Vector2(0, 1248) + +[node name="rowTest2" parent="RowTests" instance=ExtResource("4_si3v6")] +position = Vector2(0, 1184) + +[node name="rowTest3" parent="RowTests" instance=ExtResource("4_si3v6")] +position = Vector2(0, 1120) + +[node name="rowTest4" parent="RowTests" instance=ExtResource("4_si3v6")] +position = Vector2(0, 1056) + +[node name="rowTest5" parent="RowTests" instance=ExtResource("4_si3v6")] +position = Vector2(0, 992) + +[node name="rowTest6" parent="RowTests" instance=ExtResource("4_si3v6")] +position = Vector2(0, 928) + +[node name="rowTest7" parent="RowTests" instance=ExtResource("4_si3v6")] +position = Vector2(0, 864) + +[node name="rowTest8" parent="RowTests" instance=ExtResource("4_si3v6")] +position = Vector2(0, 800) + +[node name="rowTest9" parent="RowTests" instance=ExtResource("4_si3v6")] +position = Vector2(0, 736) + +[node name="rowTest10" parent="RowTests" instance=ExtResource("4_si3v6")] +position = Vector2(0, 672) + +[node name="rowTest11" parent="RowTests" instance=ExtResource("4_si3v6")] +position = Vector2(0, 608) + +[node name="rowTest12" parent="RowTests" instance=ExtResource("4_si3v6")] +position = Vector2(0, 544) + +[node name="rowTest13" parent="RowTests" instance=ExtResource("4_si3v6")] +position = Vector2(0, 480) + +[node name="rowTest14" parent="RowTests" instance=ExtResource("4_si3v6")] +position = Vector2(0, 416) + +[node name="rowTest15" parent="RowTests" instance=ExtResource("4_si3v6")] +position = Vector2(0, 352) + +[node name="rowTest16" parent="RowTests" instance=ExtResource("4_si3v6")] +position = Vector2(0, 288) + +[node name="rowTest17" parent="RowTests" instance=ExtResource("4_si3v6")] +position = Vector2(0, 224) + +[node name="rowTest18" parent="RowTests" instance=ExtResource("4_si3v6")] +position = Vector2(0, 160) + +[node name="rowTest19" parent="RowTests" instance=ExtResource("4_si3v6")] +position = Vector2(0, 96) + +[node name="rowTest20" parent="RowTests" instance=ExtResource("4_si3v6")] +position = Vector2(0, 32) + +[editable path="Border"] +[editable path="Border2"] +[editable path="Bottom"] diff --git a/scenes/Grid/row_test.gd b/scenes/Grid/row_test.gd new file mode 100644 index 0000000..a60fb86 --- /dev/null +++ b/scenes/Grid/row_test.gd @@ -0,0 +1,7 @@ +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() diff --git a/scenes/Grid/row_test.tscn b/scenes/Grid/row_test.tscn new file mode 100644 index 0000000..4bd7a13 --- /dev/null +++ b/scenes/Grid/row_test.tscn @@ -0,0 +1,15 @@ +[gd_scene load_steps=3 format=3 uid="uid://duubii5uu3lgq"] + +[ext_resource type="Script" path="res://scenes/Grid/row_test.gd" id="1_a8m2k"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_rkqoc"] +size = Vector2(640, 20) + +[node name="rowTest" type="Area2D"] +collision_layer = 4 +collision_mask = 2 +script = ExtResource("1_a8m2k") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2(320, 0) +shape = SubResource("RectangleShape2D_rkqoc") diff --git a/scenes/Grid/speed_scale.gd b/scenes/Grid/speed_scale.gd new file mode 100644 index 0000000..8fe0613 --- /dev/null +++ b/scenes/Grid/speed_scale.gd @@ -0,0 +1,10 @@ +extends Node2D + +@onready var slider = $Path2D/Slider + +func _physics_process(delta: float) -> void: + if not GLOBAL.hasSelectedSpeed: + if Input.is_action_just_pressed("stop"): + GLOBAL.hasSelectedSpeed = true + GLOBAL.currentSpeed = GLOBAL.SPEED.MAX + print() diff --git a/scenes/Main/main.tscn b/scenes/Main/main.tscn new file mode 100644 index 0000000..c440ba8 --- /dev/null +++ b/scenes/Main/main.tscn @@ -0,0 +1,16 @@ +[gd_scene load_steps=3 format=3 uid="uid://bq5hrqgv0f6hp"] + +[ext_resource type="PackedScene" uid="uid://dwl4lotl1d3ij" path="res://scenes/Grid/grid.tscn" id="1_88eap"] +[ext_resource type="PackedScene" uid="uid://c03h0nwewolfx" path="res://scenes/Grid/SpeedScale.tscn" id="2_mnoeo"] + +[node name="main" type="Node"] + +[node name="Grid" parent="." instance=ExtResource("1_88eap")] +position = Vector2(128, 256) + +[node name="Node2D" parent="." instance=ExtResource("2_mnoeo")] +visible = false +position = Vector2(960, 896) + +[node name="Camera2D" type="Camera2D" parent="."] +position = Vector2(448, 800)