Cleaned up the Code; reworked the Block Physics

This commit is contained in:
Exobyt 2024-08-27 22:35:24 +02:00
parent ed9f671256
commit 9f6750b08a
48 changed files with 1237 additions and 1116 deletions

View file

@ -1,33 +0,0 @@
[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")

View file

@ -1,6 +1,6 @@
[gd_scene format=3 uid="uid://bm7rshwf6pjb"]
[node name="Border" type="Area2D"]
collision_mask = 16
[node name="Border" type="StaticBody2D" groups=["Border"]]
collision_mask = 2
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]

View file

@ -1,13 +1,11 @@
extends Node2D
@onready var spawnpoint = $Spawnpoint
@onready var blocks = $Blocks
@onready var tickerTimer = $Ticker
@onready var patterns = $Patterns
@onready var turnTickTimer = $TurnTick
@onready var loseArea = $LoseArea
@onready var blockContainer = $Blocks
@onready var gameTimer = $GameTimer
var partPath = "res://scenes/NewBlocks/part.tscn"
var nextBlocks = []
var currentPattern = null
@ -18,8 +16,28 @@ var blockSpeed = 0.5
var stopped = false
#func _ready() -> void:
#addBlocks()
#for i in blockContainer.get_children():
#i.init(i.global_position)
func _physics_process(delta: float) -> void:
if GLOBAL.blockStopped:
GLOBAL.testingPhase = true
for i in $Rows.get_children():
i.check()
if $Borders/RayCast2D.is_colliding():
GLOBAL.lose()
spawnBlock()
GLOBAL.testingPhase = false
GLOBAL.blockStopped = false
$TestTimer.start(0.2)
func startGame():
fillNextBlocks()
spawnBlock()
GLOBAL.resetGame()
match GLOBAL.currentMode:
GLOBAL.MODES.INFINITE:
@ -27,205 +45,6 @@ func startGame():
GLOBAL.MODES.TIME:
GLOBAL.setTimeModeTimer()
gameTimer.start(1)
tickerTimer.start(blockSpeed)
getNewPatterns()
PlacePattern()
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:
var blockGroups = getBlockGroupsList()
#if Input.is_action_pressed("down"):
if Input.is_action_pressed("down") and not stopped and not Input.is_action_just_released("down"):
if not tickerTimer.is_stopped():
blockSpeed = GLOBAL.maxSpeed
else:
if not tickerTimer.is_stopped():
blockSpeed = GLOBAL.minSpeed
if Input.is_action_just_pressed("rotate_right") and not stopped:
if blockGroups.has(GLOBAL.currentUID):
for i in blockGroups[GLOBAL.currentUID]:
if i.turningPoint:
if currentPattern != null:
if not stopped:
currentPattern.turn(GLOBAL.Direction.RIGHT,i.position-spawnpoint.position + Vector2(GLOBAL.GRID/2, GLOBAL.GRID/2))
#turnBlocks()
if turnTickTimer.is_stopped():
turnTickTimer.start(9*delta)
if Input.is_action_just_pressed("rotate_left") and not stopped:
if blockGroups.has(GLOBAL.currentUID):
for i in blockGroups[GLOBAL.currentUID]:
if i.turningPoint:
if currentPattern != null:
if not stopped:
currentPattern.turn(GLOBAL.Direction.LEFT,i.position-spawnpoint.position + Vector2(GLOBAL.GRID/2, GLOBAL.GRID/2))
#turnBlocks()
if turnTickTimer.is_stopped():
turnTickTimer.start(9*delta)
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():
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)
## 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
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 = {}
var group = []
for i in getBlockGroupsList()[uid]:
compareList[i] = 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):
if getBlockGroupsList().has(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()
if patternsArray.size() <= 2:
getNewPatterns()
currentPattern = patternsArray[0]
patterns.add_child(currentPattern)
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
block.type = currentPattern.type
block.expand = currentPattern.expand
if i.turningPoint:
block.turningPoint = true
blocks.add_child(block)
block.setlook()
func getNewPatterns():
var newPatterns = []
for i in GLOBAL.BLOCKSPATTERS:
newPatterns.append(load(GLOBAL.BLOCKSPATTERS[i]).instantiate())
newPatterns.shuffle()
newPatterns[0].type = GLOBAL.BLOCKTYPES.HEAVY
newPatterns.shuffle()
newPatterns[0].expand = true
#for i in newPatterns:
#i.expand = true
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:
if getBlockedDirection(GLOBAL.Direction.BOTTOM, GLOBAL.currentUID):
stopped = true
test()
for i in getBlockGroupsList():
moveUidGroup(GLOBAL.Direction.BOTTOM, i)
if not stopped:
tickerTimer.start(blockSpeed)
stopped = false
elif stopped:
if loseArea.get_overlapping_areas() != []:
GLOBAL.lose()
tickerTimer.start(GLOBAL.minSpeed)
stopped = false
func _on_game_timer_timeout() -> void:
match GLOBAL.currentMode:
@ -239,65 +58,31 @@ func _on_game_timer_timeout() -> void:
gameTimer.start(1)
func test():
for i in $RowTests.get_children():
for j in getBlockGroupsList():
if j != GLOBAL.currentUID:
moveUidGroup(GLOBAL.Direction.BOTTOM, i)
stopped = true
var previousPosition = currentPattern.position
if currentPattern.expand:
if currentPattern.get_scale() != Vector2(2,2):
#currentPattern.position.y -= 64
for i in getBlockGroupsList()[GLOBAL.currentUID]:
if i.turningPoint:
currentPattern.set_scale(Vector2(2,2))
currentPattern.moveToPosition(i.global_position-spawnpoint.position)
for j in await currentPattern.getCollidingBorder():
if j.is_in_group("Floor"):
currentPattern.position.y -= GLOBAL.GRID
if await currentPattern.getCollidingBorder() == []:
break
if j.is_in_group("LeftBorder"):
for s in range(1,7):
currentPattern.position.x += GLOBAL.GRID
if await currentPattern.getCollidingBorder() == []:
break
elif j.is_in_group("RightBorder"):
for s in range(1,7):
currentPattern.position.x -= GLOBAL.GRID
if await currentPattern.getCollidingBorder() == []:
break
if await currentPattern.getCollidingBorder() == []:
for i in getBlockGroupsList()[GLOBAL.currentUID].size():
getBlockGroupsList()[GLOBAL.currentUID][i].global_position = currentPattern.getPositions()[i].global_position - Vector2(GLOBAL.GRID, GLOBAL.GRID)
getBlockGroupsList()[GLOBAL.currentUID][i].set_scale(Vector2(2,2))
for i in await currentPattern.getCollidingBlocks():
i.queue_free()
testRows()
PlacePattern()
func testRows():
for i in $RowTests.get_children():
if i.isCompleted():
for j in i.getRow():
splitOphansUID(j.UID)
if j.expand:
GLOBAL.points += j.type * 2
GLOBAL.time += j.type
elif not j.expand:
GLOBAL.points += j.type
GLOBAL.time += j.type
j.queue_free()
for j in getBlockGroupsList():
if j != GLOBAL.currentUID:
moveUidGroup(GLOBAL.Direction.BOTTOM, j)
func toggleButton():
$Camera2D/CanvasLayer/Control.toggleButton()
func fillNextBlocks():
var newBlocks = []
for i in GLOBAL.BLOCKS:
newBlocks.append(load(GLOBAL.BLOCKS[i]).instantiate())
newBlocks.shuffle()
newBlocks[0].expand = true
newBlocks.shuffle()
newBlocks[0].type = GLOBAL.BLOCKTYPES.HEAVY
newBlocks.shuffle()
nextBlocks.append_array(newBlocks)
func spawnBlock():
GLOBAL.speedUp()
var newBlock = nextBlocks[0]
nextBlocks.pop_at(0)
if nextBlocks == []:
fillNextBlocks()
blockContainer.add_child(newBlock)
newBlock.init(spawnpoint.global_position)
newBlock.setNewID()
func _on_test_timer_timeout() -> void:
GLOBAL.rowRemoved = false

View file

@ -1,11 +1,8 @@
[gd_scene load_steps=21 format=3 uid="uid://dwl4lotl1d3ij"]
[gd_scene load_steps=15 format=3 uid="uid://dwl4lotl1d3ij"]
[ext_resource type="Script" path="res://scenes/Grid/grid.gd" id="1_vie5m"]
[ext_resource type="Texture2D" uid="uid://cj6fsj1ac11a1" path="res://assets/background.png" id="2_vakrw"]
[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"]
[ext_resource type="PackedScene" uid="uid://d2m5xvw4ucwfw" path="res://scenes/Grid/lose_area.tscn" id="5_u5wlg"]
[ext_resource type="Script" path="res://scenes/Grid/camera_2d.gd" id="6_mbeib"]
[ext_resource type="Theme" uid="uid://1nebbd65iyce" path="res://Theme/main.tres" id="7_38u5s"]
[ext_resource type="Script" path="res://scenes/Main/control.gd" id="8_4bfjb"]
@ -15,28 +12,12 @@
[ext_resource type="Texture2D" uid="uid://ct4dkk00pyv6v" path="res://assets/Buttons/RotationLeft.png" id="12_qk3ju"]
[ext_resource type="Texture2D" uid="uid://5gbnb7gtwww3" path="res://assets/Buttons/RotationRight.png" id="13_kls78"]
[ext_resource type="Texture2D" uid="uid://cevua7g7nsrfj" path="res://assets/Buttons/DownArrow.png" id="14_i1yud"]
[ext_resource type="PackedScene" uid="uid://ibyhtfpc52vc" path="res://scenes/Grid/row_test.tscn" id="14_ogg0j"]
[ext_resource type="AudioStream" uid="uid://tf3d2uu84gf1" path="res://assets/Audio/Background.wav" id="16_ng6e7"]
[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, 128)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_m21a1"]
size = Vector2(640, 256)
[node name="Grid" type="Node2D"]
script = ExtResource("1_vie5m")
[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="TextureRect" type="TextureRect" parent="."]
offset_right = 640.0
offset_bottom = 1280.0
@ -46,106 +27,7 @@ stretch_mode = 1
[node name="Blocks" type="Node2D" parent="."]
[node name="Spawnpoint" type="Marker2D" parent="."]
position = Vector2(256, -128)
[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)
[node name="Ticker" type="Timer" parent="."]
[node name="Patterns" type="Node2D" parent="."]
position = Vector2(256, -128)
[node name="TurnTick" type="Timer" parent="."]
wait_time = 0.1
one_shot = true
[node name="Borders" type="Node2D" parent="."]
[node name="Border" parent="Borders" groups=["LeftBorder"] instance=ExtResource("4_3j08q")]
[node name="CollisionShape2D" parent="Borders/Border" index="0" groups=["LeftBorder"]]
position = Vector2(-64, 512)
shape = SubResource("RectangleShape2D_flipi")
[node name="Border2" parent="Borders" groups=["RightBorder"] instance=ExtResource("4_3j08q")]
[node name="CollisionShape2D" parent="Borders/Border2" index="0" groups=["RightBorder"]]
position = Vector2(704, 512)
shape = SubResource("RectangleShape2D_flipi")
[node name="Bottom" parent="." groups=["Floor"] instance=ExtResource("5_14njh")]
position = Vector2(320, 1312)
collision_mask = 2
[node name="CollisionShape2D" parent="Bottom" index="0"]
position = Vector2(0, 32)
shape = SubResource("RectangleShape2D_rxd0s")
[node name="LoseArea" parent="." instance=ExtResource("5_u5wlg")]
[node name="CollisionShape2D" type="CollisionShape2D" parent="LoseArea"]
position = Vector2(320, -128)
shape = SubResource("RectangleShape2D_m21a1")
position = Vector2(288, -96)
[node name="GameTimer" type="Timer" parent="."]
@ -282,17 +164,87 @@ action_mode = 0
icon = ExtResource("14_i1yud")
icon_alignment = 1
[node name="Background" type="Sprite2D" parent="."]
position = Vector2(320, 640)
scale = Vector2(10, 20)
[node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="."]
stream = ExtResource("16_ng6e7")
volume_db = 3.0
autoplay = true
[connection signal="timeout" from="Ticker" to="." method="_on_ticker_timeout"]
[connection signal="timeout" from="TurnTick" to="." method="_on_turn_tick_timeout"]
[node name="Borders" type="Node2D" parent="."]
[node name="Border" parent="Borders" instance=ExtResource("4_3j08q")]
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Borders/Border"]
polygon = PackedVector2Array(0, -64, 0, 1280, 640, 1280, 640, -64, 1088, -64, 1088, 1536, -448, 1536, -448, -64)
[node name="RayCast2D" type="RayCast2D" parent="Borders"]
position = Vector2(32, -32)
target_position = Vector2(576, 0)
collision_mask = 2
hit_from_inside = true
[node name="Rows" type="Node2D" parent="."]
[node name="RowTest" parent="Rows" instance=ExtResource("14_ogg0j")]
position = Vector2(0, 1216)
[node name="RowTest2" parent="Rows" instance=ExtResource("14_ogg0j")]
position = Vector2(0, 1152)
[node name="RowTest3" parent="Rows" instance=ExtResource("14_ogg0j")]
position = Vector2(0, 1088)
[node name="RowTest4" parent="Rows" instance=ExtResource("14_ogg0j")]
position = Vector2(0, 1024)
[node name="RowTest5" parent="Rows" instance=ExtResource("14_ogg0j")]
position = Vector2(0, 960)
[node name="RowTest6" parent="Rows" instance=ExtResource("14_ogg0j")]
position = Vector2(0, 896)
[node name="RowTest7" parent="Rows" instance=ExtResource("14_ogg0j")]
position = Vector2(0, 832)
[node name="RowTest8" parent="Rows" instance=ExtResource("14_ogg0j")]
position = Vector2(0, 768)
[node name="RowTest9" parent="Rows" instance=ExtResource("14_ogg0j")]
position = Vector2(0, 704)
[node name="RowTest10" parent="Rows" instance=ExtResource("14_ogg0j")]
position = Vector2(0, 640)
[node name="RowTest11" parent="Rows" instance=ExtResource("14_ogg0j")]
position = Vector2(0, 576)
[node name="RowTest12" parent="Rows" instance=ExtResource("14_ogg0j")]
position = Vector2(0, 512)
[node name="RowTest13" parent="Rows" instance=ExtResource("14_ogg0j")]
position = Vector2(0, 448)
[node name="RowTest14" parent="Rows" instance=ExtResource("14_ogg0j")]
position = Vector2(0, 384)
[node name="RowTest15" parent="Rows" instance=ExtResource("14_ogg0j")]
position = Vector2(0, 320)
[node name="RowTest16" parent="Rows" instance=ExtResource("14_ogg0j")]
position = Vector2(0, 256)
[node name="RowTest17" parent="Rows" instance=ExtResource("14_ogg0j")]
position = Vector2(0, 192)
[node name="RowTest18" parent="Rows" instance=ExtResource("14_ogg0j")]
position = Vector2(0, 128)
[node name="RowTest19" parent="Rows" instance=ExtResource("14_ogg0j")]
position = Vector2(0, 64)
[node name="RowTest20" parent="Rows" instance=ExtResource("14_ogg0j")]
[node name="TestTimer" type="Timer" parent="."]
one_shot = true
[connection signal="timeout" from="GameTimer" to="." method="_on_game_timer_timeout"]
[connection signal="pressed" from="Camera2D/CanvasLayer/Control/HBoxContainer3/left_Button" to="Camera2D/CanvasLayer/Control" method="_on_left_button_pressed"]
[connection signal="pressed" from="Camera2D/CanvasLayer/Control/HBoxContainer3/right_Button" to="Camera2D/CanvasLayer/Control" method="_on_right_button_pressed"]
@ -300,7 +252,4 @@ autoplay = true
[connection signal="pressed" from="Camera2D/CanvasLayer/Control/HBoxContainer4/rotate_right_Button" to="Camera2D/CanvasLayer/Control" method="_on_rotate_right_button_pressed"]
[connection signal="button_down" from="Camera2D/CanvasLayer/Control/HBoxContainer5/down_Button" to="Camera2D/CanvasLayer/Control" method="_on_down_button_button_down"]
[connection signal="button_up" from="Camera2D/CanvasLayer/Control/HBoxContainer5/down_Button" to="Camera2D/CanvasLayer/Control" method="_on_down_button_button_up"]
[editable path="Borders/Border"]
[editable path="Borders/Border2"]
[editable path="Bottom"]
[connection signal="timeout" from="TestTimer" to="." method="_on_test_timer_timeout"]

View file

@ -1,5 +0,0 @@
[gd_scene format=3 uid="uid://d2m5xvw4ucwfw"]
[node name="LoseArea" type="Area2D"]
collision_layer = 64
collision_mask = 2

View file

@ -1,22 +1,33 @@
extends Area2D
extends Node2D
#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()
static var rowRemoved = false
func getRow():
return get_overlapping_areas()
func isFull():
var full = true
for i in get_children():
i.force_raycast_update()
#print(i.get_collider())
if not i.is_colliding():
full = false
return full
func isCompleted():
var amount = 0
for i in get_overlapping_areas():
if i.get_scale() == Vector2(2,2):
amount += 2
else:
amount += 1
if amount >= 10:
return true
else:
return false
func check():
if not GLOBAL.rowRemoved:
rowRemoved = false
if isFull():
GLOBAL.rowRemoved = true
var blocksSplit = []
var removeBlock = []
for i in get_children():
i.force_raycast_update()
if i.get_collider() != null:
blocksSplit.append(i.get_collider().get_parent().get_parent())
if GLOBAL.currentMode == GLOBAL.MODES.TIME:
GLOBAL.time += i.get_collider().get_parent().get_parent().type
if i.get_collider().get_parent().get_parent().expand:
GLOBAL.points += i.get_collider().get_parent().get_parent().type * 2
else:
GLOBAL.points += i.get_collider().get_parent().get_parent().type
i.get_collider().free()
for j in blocksSplit:
j.splitParts()

View file

@ -1,15 +1,66 @@
[gd_scene load_steps=3 format=3 uid="uid://duubii5uu3lgq"]
[gd_scene load_steps=2 format=3 uid="uid://ibyhtfpc52vc"]
[ext_resource type="Script" path="res://scenes/Grid/row_test.gd" id="1_a8m2k"]
[ext_resource type="Script" path="res://scenes/Grid/row_test.gd" id="1_2nxxe"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_rkqoc"]
size = Vector2(640, 20)
[node name="RowTest" type="Node2D"]
script = ExtResource("1_2nxxe")
[node name="rowTest" type="Area2D"]
collision_layer = 4
collision_mask = 2
script = ExtResource("1_a8m2k")
[node name="RayCast2D" type="RayCast2D" parent="."]
position = Vector2(32, 24)
target_position = Vector2(0, 16)
collision_mask = 24
hit_from_inside = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(320, 0)
shape = SubResource("RectangleShape2D_rkqoc")
[node name="RayCast2D2" type="RayCast2D" parent="."]
position = Vector2(96, 24)
target_position = Vector2(0, 16)
collision_mask = 24
hit_from_inside = true
[node name="RayCast2D3" type="RayCast2D" parent="."]
position = Vector2(160, 24)
target_position = Vector2(0, 16)
collision_mask = 24
hit_from_inside = true
[node name="RayCast2D4" type="RayCast2D" parent="."]
position = Vector2(224, 24)
target_position = Vector2(0, 16)
collision_mask = 24
hit_from_inside = true
[node name="RayCast2D5" type="RayCast2D" parent="."]
position = Vector2(288, 24)
target_position = Vector2(0, 16)
collision_mask = 24
hit_from_inside = true
[node name="RayCast2D6" type="RayCast2D" parent="."]
position = Vector2(352, 24)
target_position = Vector2(0, 16)
collision_mask = 24
hit_from_inside = true
[node name="RayCast2D7" type="RayCast2D" parent="."]
position = Vector2(416, 24)
target_position = Vector2(0, 16)
collision_mask = 24
hit_from_inside = true
[node name="RayCast2D8" type="RayCast2D" parent="."]
position = Vector2(480, 24)
target_position = Vector2(0, 16)
collision_mask = 24
hit_from_inside = true
[node name="RayCast2D9" type="RayCast2D" parent="."]
position = Vector2(544, 24)
target_position = Vector2(0, 16)
collision_mask = 24
hit_from_inside = true
[node name="RayCast2D10" type="RayCast2D" parent="."]
position = Vector2(608, 24)
target_position = Vector2(0, 16)
collision_mask = 24
hit_from_inside = true

View file

@ -1,9 +0,0 @@
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