Fixed many Bugy and added Labels for Time and Score

This commit is contained in:
Exobyt 2024-08-20 00:34:24 +02:00
parent 632eeddc64
commit ee5e17c3e0
14 changed files with 430 additions and 179 deletions

6
Theme/label.tres Normal file
View file

@ -0,0 +1,6 @@
[gd_resource type="LabelSettings" format=3 uid="uid://cd783ubpcytc8"]
[resource]
font_size = 64
outline_size = 10
outline_color = Color(0, 0, 0, 1)

View file

@ -14,7 +14,7 @@ config/name="GmtkGameJam2024"
config/tags=PackedStringArray("game_jam") config/tags=PackedStringArray("game_jam")
run/main_scene="res://scenes/Main/main.tscn" run/main_scene="res://scenes/Main/main.tscn"
config/features=PackedStringArray("4.3", "GL Compatibility") config/features=PackedStringArray("4.3", "GL Compatibility")
run/max_fps=120 run/max_fps=60
config/icon="res://icon.svg" config/icon="res://icon.svg"
[autoload] [autoload]
@ -24,10 +24,11 @@ GLOBAL="*res://scenes/Globals/global.gd"
[display] [display]
window/size/viewport_width=440 window/size/viewport_width=1080
window/size/viewport_height=1080 window/size/viewport_height=1080
window/stretch/aspect="keep_height" window/stretch/mode="viewport"
window/stretch/scale=0.5 window/stretch/aspect="expand"
window/stretch/scale=0.8
window/handheld/orientation=1 window/handheld/orientation=1
[editor] [editor]
@ -42,6 +43,7 @@ enabled=PackedStringArray("res://addons/debug_menu/plugin.cfg")
[global_group] [global_group]
Block="Block" Block="Block"
ExpandBlock=""
[input] [input]
@ -95,6 +97,8 @@ locale/locale_filter_mode=0
2d_physics/layer_2="block" 2d_physics/layer_2="block"
2d_physics/layer_3="rowTest" 2d_physics/layer_3="rowTest"
2d_physics/layer_4="TurnTest" 2d_physics/layer_4="TurnTest"
2d_physics/layer_5="oneBlock"
2d_physics/layer_6="expandBlock"
[rendering] [rendering]

View file

@ -7,6 +7,7 @@
[node name="BlockPattern" instance=ExtResource("1_sj41y")] [node name="BlockPattern" instance=ExtResource("1_sj41y")]
[node name="PositionMarker" parent="Positions" index="0" instance=ExtResource("2_csenr")] [node name="PositionMarker" parent="Positions" index="0" instance=ExtResource("2_csenr")]
turningPoint = true
[node name="PositionMarker2" parent="Positions" index="1" instance=ExtResource("2_csenr")] [node name="PositionMarker2" parent="Positions" index="1" instance=ExtResource("2_csenr")]
position = Vector2(0, -64) position = Vector2(0, -64)

View file

@ -5,66 +5,112 @@ extends Node2D
var lastDirection = null var lastDirection = null
var type = GLOBAL.BLOCKTYPES.LIGHT
var expand = false
func getPositions(): func getPositions():
return positions.get_children() return positions.get_children()
func checkDirection(): func checkDirection():
var leftCollision = true print("xfsdfdsfd")
var rightCollision = true var leftCollision = false
positions.position.x = 0 var rightCollision = false
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): movePattern(GLOBAL.Direction.RIGHT)
positions.position.x = 0 print("0: ", await isColliding())
collision.position.x = 0 if await isColliding():
movePattern(GLOBAL.Direction.LEFT)
print("1: ", await isColliding())
#if await isColliding():
#movePattern(GLOBAL.Direction.RIGHT, 2)
#print("2: ", await isColliding())
#if await isColliding():
#movePattern(GLOBAL.Direction.LEFT, 2)
#print("3: ", await isColliding())
#if await isColliding():
#resetPosition()
#print("4: ", await isColliding())
#if await isColliding():
#rightCollision = true
#resetPosition()
#movePattern(GLOBAL.Direction.LEFT)
#if await isColliding():
#leftCollision = true
#print(" LEFT: ", leftCollision, "\n RIGHT: ", rightCollision)
#resetPosition()
#if await getCollidingAreas() != []:
#rightCollision = true
#resetPosition()
#movePattern(GLOBAL.Direction.LEFT)
#if await getCollidingAreas() != []:
#leftCollision = true
#resetPosition()
#
#if leftCollision:
#movePattern(GLOBAL.Direction.RIGHT)
#elif rightCollision:
#movePattern(GLOBAL.Direction.LEFT)
#else:
#resetPosition()
func moveToPosition(newPosition):
resetPosition()
position = newPosition 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: func turn(direction, newPosition):
positions.rotation_degrees -= 90 reset(newPosition)
collision.rotation_degrees -= 90 #moveToPosition(newPosition)
if await getCollidingAreas() != []: rotatePattern(direction)
checkDirection()
if await getCollidingAreas() != []: #if await isColliding():
positions.rotation_degrees -= 90 #print(1)
collision.rotation_degrees -= 90 #movePattern(GLOBAL.Direction.RIGHT, 1)
#positions.rotation_degrees += 90 #if await isColliding():
#collision.rotation_degrees += 90 #print(2)
#movePattern(GLOBAL.Direction.LEFT,2)
#if await isColliding():
#print(3)
#movePattern(GLOBAL.Direction.RIGHT, 3)
#if await isColliding():
#print(4)
#movePattern(GLOBAL.Direction.LEFT, 4)
#if await isColliding():
#print(1)
#movePattern(GLOBAL.Direction.RIGHT, 2)
#if await isColliding():
#print(2)
#movePattern(GLOBAL.Direction.LEFT,4)
#
if await isColliding():
movePattern(GLOBAL.Direction.RIGHT, 1)
if await isColliding():
movePattern(GLOBAL.Direction.RIGHT, 1)
if await isColliding():
movePattern(GLOBAL.Direction.LEFT,3)
if await isColliding():
movePattern(GLOBAL.Direction.LEFT,1)
#if await isColliding():
#print(2)
#movePattern(GLOBAL.Direction.RIGHT, 1)
#if await isColliding():
#print(3)
#movePattern(GLOBAL.Direction.LEFT,3)
#if await isColliding():
#print(4)
#movePattern(GLOBAL.Direction.LEFT,1)
#if await isColliding():
#print(3)
#movePattern(GLOBAL.Direction.LEFT, 1)
#movePattern(GLOBAL.Direction.RIGHT, 3)
#if await isColliding():
#movePattern(GLOBAL.Direction.LEFT, 2)
if await isColliding():
resetPosition()
@ -82,6 +128,30 @@ func getCollidingAreas():
collidingAreas.append(i) collidingAreas.append(i)
return collidingAreas return collidingAreas
func isColliding():
return await getCollidingAreas() != []
func getCollidingBorder():
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 not i.is_in_group("Block"):
collidingAreas.append(i)
return collidingAreas
func getCollidingBlocks():
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)
return collidingAreas
#func _on_collision_test_area_entered(area: Area2D) -> void: #func _on_collision_test_area_entered(area: Area2D) -> void:
#if lastDirection == null: #if lastDirection == null:
@ -102,3 +172,30 @@ func reset(newPosition):
positions.position.x = 0 positions.position.x = 0
collision.position.x = 0 collision.position.x = 0
rotation_degrees = 0 rotation_degrees = 0
func movePattern(direction, steps = 1):
match direction:
GLOBAL.Direction.LEFT:
positions.position.x -= GLOBAL.GRID * steps
collision.position.x -= GLOBAL.GRID * steps
#print("Left")
#print(positions.position)
GLOBAL.Direction.RIGHT:
positions.position.x += GLOBAL.GRID * steps
collision.position.x += GLOBAL.GRID * steps
#print("Right")
#print(positions.position)
func resetPosition():
#print("RESET")
positions.position.x = 0
collision.position.x = 0
func rotatePattern(direction):
match direction:
GLOBAL.Direction.LEFT:
positions.rotation_degrees += 90
collision.rotation_degrees += 90
GLOBAL.Direction.RIGHT:
positions.rotation_degrees -= 90
collision.rotation_degrees -= 90

View file

@ -3,6 +3,7 @@ extends Area2D
@onready var floorRaycast = $RaycastFloor @onready var floorRaycast = $RaycastFloor
@onready var raycastLeft = $RaycastLeft @onready var raycastLeft = $RaycastLeft
@onready var raycastRight = $RaycastRight @onready var raycastRight = $RaycastRight
@onready var raycastTop = $RaycastTop
@export var UID = 1 @export var UID = 1
@ -15,40 +16,6 @@ var type = GLOBAL.BLOCKTYPES.LIGHT
func _ready() -> void: func _ready() -> void:
secretPosition = position 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): func getCollider(direction : GLOBAL.Direction):
match direction: match direction:
GLOBAL.Direction.BOTTOM: GLOBAL.Direction.BOTTOM:
@ -57,7 +24,8 @@ func getCollider(direction : GLOBAL.Direction):
return raycastLeft.get_collider() return raycastLeft.get_collider()
GLOBAL.Direction.RIGHT: GLOBAL.Direction.RIGHT:
return raycastRight.get_collider() return raycastRight.get_collider()
GLOBAL.Direction.TOP:
return raycastTop.get_collider()
func getNeighbours(): func getNeighbours():
var neighbours = [] var neighbours = []

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=4 format=3 uid="uid://do8gr42oq2a0y"] [gd_scene load_steps=5 format=3 uid="uid://do8gr42oq2a0y"]
[ext_resource type="Script" path="res://scenes/Blocks/block.gd" id="1_t1hpt"] [ext_resource type="Script" path="res://scenes/Blocks/block.gd" id="1_t1hpt"]
@ -7,6 +7,9 @@
[sub_resource type="RectangleShape2D" id="RectangleShape2D_gvev2"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_gvev2"]
size = Vector2(80, 80) size = Vector2(80, 80)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_ti23g"]
size = Vector2(48, 48)
[node name="Block" type="Area2D" groups=["Block"]] [node name="Block" type="Area2D" groups=["Block"]]
collision_layer = 2 collision_layer = 2
collision_mask = 14 collision_mask = 14
@ -19,21 +22,28 @@ mesh = SubResource("QuadMesh_lsuac")
[node name="RaycastFloor" type="RayCast2D" parent="."] [node name="RaycastFloor" type="RayCast2D" parent="."]
position = Vector2(32, 72) position = Vector2(32, 72)
target_position = Vector2(0, 32) target_position = Vector2(0, 8)
collision_mask = 3 collision_mask = 3
hit_from_inside = true hit_from_inside = true
collide_with_areas = true collide_with_areas = true
[node name="RaycastLeft" type="RayCast2D" parent="."] [node name="RaycastLeft" type="RayCast2D" parent="."]
position = Vector2(-8, 32) position = Vector2(-8, 32)
target_position = Vector2(-32, 0) target_position = Vector2(-8, 0)
collision_mask = 3 collision_mask = 3
hit_from_inside = true hit_from_inside = true
collide_with_areas = true collide_with_areas = true
[node name="RaycastRight" type="RayCast2D" parent="."] [node name="RaycastRight" type="RayCast2D" parent="."]
position = Vector2(72, 32) position = Vector2(72, 32)
target_position = Vector2(32, 0) target_position = Vector2(8, 0)
collision_mask = 3
hit_from_inside = true
collide_with_areas = true
[node name="RaycastTop" type="RayCast2D" parent="."]
position = Vector2(32, -8)
target_position = Vector2(0, -8)
collision_mask = 3 collision_mask = 3
hit_from_inside = true hit_from_inside = true
collide_with_areas = true collide_with_areas = true
@ -41,3 +51,10 @@ collide_with_areas = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(32, 32) position = Vector2(32, 32)
shape = SubResource("RectangleShape2D_gvev2") shape = SubResource("RectangleShape2D_gvev2")
[node name="Area2D" type="Area2D" parent="." groups=["Block"]]
collision_layer = 16
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
position = Vector2(32, 32)
shape = SubResource("RectangleShape2D_ti23g")

View file

@ -10,7 +10,7 @@ var hasSelectedSpeed = false
const GRID := 64 const GRID := 64
enum BLOCKTYPES {LIGHT, HEAVY} enum BLOCKTYPES {LIGHT=1, HEAVY=3}
const BLOCKSPATTERS : Dictionary = { const BLOCKSPATTERS : Dictionary = {
"Z": "res://scenes/Blocks/Patterns/Z/Z_block_pattern.tscn", "Z": "res://scenes/Blocks/Patterns/Z/Z_block_pattern.tscn",
@ -22,12 +22,14 @@ const BLOCKSPATTERS : Dictionary = {
"I": "res://scenes/Blocks/Patterns/I/I_block_pattern.tscn", "I": "res://scenes/Blocks/Patterns/I/I_block_pattern.tscn",
"1x3": "res://scenes/Blocks/Patterns/1x3/1x3_block_pattern.tscn" "1x3": "res://scenes/Blocks/Patterns/1x3/1x3_block_pattern.tscn"
} }
enum Direction {BOTTOM, LEFT, RIGHT} enum Direction {BOTTOM, LEFT, RIGHT, TOP}
var lastUID = 1 var lastUID = 1
var currentUID = lastUID var currentUID = lastUID
var time = 0
func getNewUID() -> int: func getNewUID() -> int:
lastUID += 1 lastUID += 1
return lastUID return lastUID

View file

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

View file

@ -12,7 +12,9 @@ var currentPattern = null
var patternsArray = [] var patternsArray = []
var blockSpeed = 0.4 var blockSpeed = 0.5
var stopped = false
func spawnBlock() -> void: func spawnBlock() -> void:
var block = nextBlocks[0] var block = nextBlocks[0]
@ -28,26 +30,39 @@ func _ready() -> void:
PlacePattern() PlacePattern()
func _physics_process(delta: float) -> void: func _physics_process(delta: float) -> void:
for i in getBlockGroupsList():
if i != GLOBAL.currentUID: #for i in $Borders.get_children():
moveUidGroup(GLOBAL.Direction.BOTTOM, i) #for j in i.get_overlapping_areas():
#if j.is_in_group("Block"):
#if j.get_parent().UID == GLOBAL.currentUID:
#for s in getBlockGroupsList()[j.get_parent().UID]:
#s.queue_free()
#else:
#j.get_parent().queue_free()
#for i in getBlockGroupsList():
#if i != GLOBAL.currentUID:
#moveUidGroup(GLOBAL.Direction.BOTTOM, i)
var blockGroups = getBlockGroupsList() var blockGroups = getBlockGroupsList()
if Input.is_action_just_pressed("rotate_right"): if Input.is_action_just_pressed("rotate_right") and not stopped:
if blockGroups.has(GLOBAL.currentUID):
for i in blockGroups[GLOBAL.currentUID]: for i in blockGroups[GLOBAL.currentUID]:
if i.turningPoint: if i.turningPoint:
if currentPattern != null: if currentPattern != null:
currentPattern.turn(GLOBAL.Direction.RIGHT,i.position + Vector2(GLOBAL.GRID/2, GLOBAL.GRID/2)) currentPattern.turn(GLOBAL.Direction.RIGHT,i.position-spawnpoint.position + Vector2(GLOBAL.GRID/2, GLOBAL.GRID/2))
#turnBlocks()
if turnTickTimer.is_stopped(): if turnTickTimer.is_stopped():
turnTickTimer.start(0.18) turnTickTimer.start(0.3)
if Input.is_action_just_pressed("rotate_left"): if Input.is_action_just_pressed("rotate_left") and not stopped:
if blockGroups.has(GLOBAL.currentUID):
for i in blockGroups[GLOBAL.currentUID]: for i in blockGroups[GLOBAL.currentUID]:
if i.turningPoint: if i.turningPoint:
if currentPattern != null: if currentPattern != null:
currentPattern.turn(GLOBAL.Direction.LEFT,i.position + Vector2(GLOBAL.GRID/2, GLOBAL.GRID/2)) currentPattern.turn(GLOBAL.Direction.LEFT,i.position-spawnpoint.position + Vector2(GLOBAL.GRID/2, GLOBAL.GRID/2))
#turnBlocks()
if turnTickTimer.is_stopped(): if turnTickTimer.is_stopped():
turnTickTimer.start(0.18) turnTickTimer.start(0.3)
if Input.is_action_just_pressed("left"): if Input.is_action_just_pressed("left"):
moveUidGroup(GLOBAL.Direction.LEFT, GLOBAL.currentUID) moveUidGroup(GLOBAL.Direction.LEFT, GLOBAL.currentUID)
@ -67,9 +82,6 @@ func fillNextBlocks():
newBlocks.shuffle() newBlocks.shuffle()
nextBlocks.append_array(newBlocks) nextBlocks.append_array(newBlocks)
## returns a Dictionary with the UIDs as the Key and a List of the Blocks as the content ## returns a Dictionary with the UIDs as the Key and a List of the Blocks as the content
func getBlockGroupsList(): func getBlockGroupsList():
var blockLists : Dictionary = {} var blockLists : Dictionary = {}
@ -121,6 +133,7 @@ func splitOphansUID(uid):
j.UID = newUID j.UID = newUID
func moveUidGroup(direction, uid): func moveUidGroup(direction, uid):
if getBlockGroupsList().has(uid):
match direction: match direction:
GLOBAL.Direction.BOTTOM: GLOBAL.Direction.BOTTOM:
for i in getBlockGroupsList()[uid]: for i in getBlockGroupsList()[uid]:
@ -139,9 +152,10 @@ func PlacePattern():
patternsArray.pop_at(0) patternsArray.pop_at(0)
for child in patterns.get_children(): for child in patterns.get_children():
child.queue_free() child.queue_free()
if patternsArray.size() <= 1:
getNewPatterns()
currentPattern = patternsArray[0] currentPattern = patternsArray[0]
patterns.add_child(currentPattern) patterns.add_child(currentPattern)
getNewPatterns()
var newUID = GLOBAL.getNewUID() var newUID = GLOBAL.getNewUID()
GLOBAL.currentUID = newUID GLOBAL.currentUID = newUID
var newColor = Color.from_hsv((randi() % 12) / 12.0, 1, 1) var newColor = Color.from_hsv((randi() % 12) / 12.0, 1, 1)
@ -153,7 +167,7 @@ func PlacePattern():
block.UID = newUID block.UID = newUID
block.modulate = newColor block.modulate = newColor
block.position = spawnpoint.position + i.position block.position = spawnpoint.position + i.position
block.type = currentPattern.type
if i.turningPoint: if i.turningPoint:
block.turningPoint = true block.turningPoint = true
blocks.add_child(block) blocks.add_child(block)
@ -162,10 +176,10 @@ func PlacePattern():
func getNewPatterns(): func getNewPatterns():
var newPatterns = [] var newPatterns = []
for i in GLOBAL.BLOCKSPATTERS: for i in GLOBAL.BLOCKSPATTERS:
print(i)
newPatterns.append(load(GLOBAL.BLOCKSPATTERS[i]).instantiate()) newPatterns.append(load(GLOBAL.BLOCKSPATTERS[i]).instantiate())
newPatterns.shuffle() newPatterns.shuffle()
#newPatterns[0].type = GLOBAL.BLOCKTYPES.HEAVY newPatterns[0].type = GLOBAL.BLOCKTYPES.HEAVY
newPatterns[0].expand = true
newPatterns.shuffle() newPatterns.shuffle()
patternsArray.append_array(newPatterns) patternsArray.append_array(newPatterns)
@ -184,24 +198,57 @@ func _on_turn_tick_timeout() -> void:
turnBlocks() turnBlocks()
func _on_ticker_timeout() -> void: func _on_ticker_timeout() -> void:
stopped = true
if getBlockedDirection(GLOBAL.Direction.BOTTOM, GLOBAL.currentUID):
if currentPattern.expand:
if currentPattern.get_scale() != Vector2(2,2):
for i in getBlockGroupsList()[GLOBAL.currentUID]:
if i.turningPoint:
currentPattern.set_scale(Vector2(2,2))
currentPattern.moveToPosition(i.global_position-spawnpoint.position - Vector2(64,64*4))
if await currentPattern.getCollidingBorder() != []:
currentPattern.position.y -= 64
for i in range(1,8):
if await currentPattern.getCollidingBorder() == []:
break
currentPattern.position.x -= 64
#if await currentPattern.getCollidingBorder() != []:
#currentPattern.position.y += 64
#if await currentPattern.getCollidingBorder() != []:
#currentPattern.position.x -= 64
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()
#for i in blocks.get_children():
#if i.get_scale() != Vector2(2,2):
#i.set_scale(Vector2(2,2))
#i.move(-64,-64)
#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)
#if i.turningPoint:
#currentPattern.global_position = i.global_position- Vector2(32,32)
for i in $RowTests.get_children(): for i in $RowTests.get_children():
#print(i.getRow()) if i.isCompleted():
#print(i.get_name(), ": ", i.getRow().size(), ": ",i.getRow())
if i.getRow().size() >= 10:
for j in i.getRow(): for j in i.getRow():
splitOphansUID(j.UID) splitOphansUID(j.UID)
GLOBAL.points += j.type GLOBAL.points += j.type
j.queue_free() j.queue_free()
#for i in getBlockGroupsList():
# splitOphansUID(i)
if getBlockedDirection(GLOBAL.Direction.BOTTOM, GLOBAL.currentUID):
PlacePattern() PlacePattern()
#print(getBlockGroupsList())
#print(getBlockGroupsList()[3])
#for i in getBlockGroupsList():
# splitOphansUID(i)
for i in getBlockGroupsList(): for i in getBlockGroupsList():
moveUidGroup(GLOBAL.Direction.BOTTOM, i) moveUidGroup(GLOBAL.Direction.BOTTOM, i)
tickerTimer.start(blockSpeed) tickerTimer.start(blockSpeed)
stopped = false

View file

@ -11,7 +11,7 @@
size = Vector2(128, 1536) size = Vector2(128, 1536)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_rxd0s"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_rxd0s"]
size = Vector2(896, 64) size = Vector2(896, 128)
[node name="Grid" type="Node2D"] [node name="Grid" type="Node2D"]
script = ExtResource("1_vie5m") script = ExtResource("1_vie5m")
@ -28,25 +28,6 @@ mesh = SubResource("QuadMesh_qfjsc")
[node name="Blocks" type="Node2D" parent="."] [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_mask = 2
[node name="CollisionShape2D" parent="Bottom" index="0"]
shape = SubResource("RectangleShape2D_rxd0s")
[node name="Spawnpoint" type="Marker2D" parent="."] [node name="Spawnpoint" type="Marker2D" parent="."]
position = Vector2(256, -128) position = Vector2(256, -128)
@ -115,14 +96,37 @@ position = Vector2(0, 32)
[node name="Ticker" type="Timer" parent="."] [node name="Ticker" type="Timer" parent="."]
[node name="Patterns" type="Node2D" parent="."] [node name="Patterns" type="Node2D" parent="."]
position = Vector2(256, -128)
[node name="TurnTick" type="Timer" parent="."] [node name="TurnTick" type="Timer" parent="."]
wait_time = 0.1 wait_time = 0.1
one_shot = true one_shot = true
[node name="Borders" type="Node2D" parent="."]
[node name="Border" parent="Borders" instance=ExtResource("4_3j08q")]
[node name="CollisionShape2D" parent="Borders/Border" index="0"]
position = Vector2(-64, 512)
shape = SubResource("RectangleShape2D_flipi")
[node name="Border2" parent="Borders" instance=ExtResource("4_3j08q")]
[node name="CollisionShape2D" parent="Borders/Border2" index="0"]
position = Vector2(704, 512)
shape = SubResource("RectangleShape2D_flipi")
[node name="Bottom" parent="." 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")
[connection signal="timeout" from="Ticker" to="." method="_on_ticker_timeout"] [connection signal="timeout" from="Ticker" to="." method="_on_ticker_timeout"]
[connection signal="timeout" from="TurnTick" to="." method="_on_turn_tick_timeout"] [connection signal="timeout" from="TurnTick" to="." method="_on_turn_tick_timeout"]
[editable path="Border"] [editable path="Borders/Border"]
[editable path="Border2"] [editable path="Borders/Border2"]
[editable path="Bottom"] [editable path="Bottom"]

View file

@ -8,3 +8,16 @@ extends Area2D
func getRow(): func getRow():
return get_overlapping_areas() return get_overlapping_areas()
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

17
scenes/Main/main.gd Normal file
View file

@ -0,0 +1,17 @@
extends Node
@onready var gameTimer = $GameTimer
@onready var scoreLabel = $Camera2D/CanvasLayer/Control/HBoxContainer/ScoreValue
@onready var timeLabel = $Camera2D/CanvasLayer/Control/HBoxContainer2/TimeValue
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
func _physics_process(delta: float) -> void:
scoreLabel.text = str(GLOBAL.points)
timeLabel.text = str(GLOBAL.time)
func _on_game_timer_timeout() -> void:
GLOBAL.time += 1
gameTimer.start(1)

View file

@ -1,9 +1,13 @@
[gd_scene load_steps=3 format=3 uid="uid://bq5hrqgv0f6hp"] [gd_scene load_steps=6 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://dwl4lotl1d3ij" path="res://scenes/Grid/grid.tscn" id="1_88eap"]
[ext_resource type="Script" path="res://scenes/Main/main.gd" id="1_dtde6"]
[ext_resource type="PackedScene" uid="uid://c03h0nwewolfx" path="res://scenes/Grid/SpeedScale.tscn" id="2_mnoeo"] [ext_resource type="PackedScene" uid="uid://c03h0nwewolfx" path="res://scenes/Grid/SpeedScale.tscn" id="2_mnoeo"]
[ext_resource type="LabelSettings" uid="uid://cd783ubpcytc8" path="res://Theme/label.tres" id="3_jopb4"]
[ext_resource type="Script" path="res://scenes/Main/score_value.gd" id="3_vtvng"]
[node name="main" type="Node"] [node name="main" type="Node"]
script = ExtResource("1_dtde6")
[node name="Grid" parent="." instance=ExtResource("1_88eap")] [node name="Grid" parent="." instance=ExtResource("1_88eap")]
position = Vector2(128, 256) position = Vector2(128, 256)
@ -13,4 +17,63 @@ visible = false
position = Vector2(960, 896) position = Vector2(960, 896)
[node name="Camera2D" type="Camera2D" parent="."] [node name="Camera2D" type="Camera2D" parent="."]
position = Vector2(448, 800) position = Vector2(448, 896)
[node name="CanvasLayer" type="CanvasLayer" parent="Camera2D"]
[node name="Control" type="Control" parent="Camera2D/CanvasLayer"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="HBoxContainer" type="HBoxContainer" parent="Camera2D/CanvasLayer/Control"]
layout_mode = 1
offset_left = 56.0
offset_top = 64.0
offset_right = 266.0
offset_bottom = 152.0
[node name="Score" type="Label" parent="Camera2D/CanvasLayer/Control/HBoxContainer"]
layout_mode = 2
text = "Score: "
label_settings = ExtResource("3_jopb4")
horizontal_alignment = 1
vertical_alignment = 1
[node name="ScoreValue" type="Label" parent="Camera2D/CanvasLayer/Control/HBoxContainer"]
layout_mode = 2
label_settings = ExtResource("3_jopb4")
horizontal_alignment = 1
script = ExtResource("3_vtvng")
[node name="HBoxContainer2" type="HBoxContainer" parent="Camera2D/CanvasLayer/Control"]
layout_mode = 1
anchors_preset = 1
anchor_left = 1.0
anchor_right = 1.0
offset_left = -376.0
offset_top = 64.0
offset_right = -128.0
offset_bottom = 152.0
grow_horizontal = 0
[node name="Time" type="Label" parent="Camera2D/CanvasLayer/Control/HBoxContainer2"]
layout_mode = 2
text = "Time: "
label_settings = ExtResource("3_jopb4")
horizontal_alignment = 1
vertical_alignment = 1
[node name="TimeValue" type="Label" parent="Camera2D/CanvasLayer/Control/HBoxContainer2"]
layout_mode = 2
label_settings = ExtResource("3_jopb4")
horizontal_alignment = 1
vertical_alignment = 1
[node name="GameTimer" type="Timer" parent="."]
autostart = true
[connection signal="timeout" from="GameTimer" to="." method="_on_game_timer_timeout"]

View file

@ -0,0 +1,11 @@
extends Label
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
text = str(GLOBAL.points)