Fixed Expand Block Bug

This commit is contained in:
Exobyt 2024-08-20 13:48:28 +02:00
parent 6d71780f36
commit e7d50232b2
4 changed files with 52 additions and 72 deletions

View file

@ -7,7 +7,6 @@ extends Node2D
@onready var turnTickTimer = $TurnTick
@onready var loseArea = $LoseArea
@onready var gameTimer = $GameTimer
@onready var coyoteTimer = $CoyoteTimer
var nextBlocks = []
@ -186,6 +185,7 @@ func getNewPatterns():
newPatterns[0].type = GLOBAL.BLOCKTYPES.HEAVY
newPatterns.shuffle()
newPatterns[0].expand = true
newPatterns.shuffle()
patternsArray.append_array(newPatterns)
@ -204,16 +204,25 @@ func _on_turn_tick_timeout() -> void:
turnBlocks()
func _on_ticker_timeout() -> void:
stopped = true
if getBlockedDirection(GLOBAL.Direction.BOTTOM, GLOBAL.currentUID):
coyoteTimer.start(0.08)
stopped = true
test()
for i in getBlockGroupsList():
moveUidGroup(GLOBAL.Direction.BOTTOM, i)
tickerTimer.start(blockSpeed)
stopped = false
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:
@ -224,72 +233,47 @@ func _on_game_timer_timeout() -> void:
gameTimer.start(1)
func _on_coyote_timer_timeout() -> void:
if loseArea.get_overlapping_areas() != []:
GLOBAL.lose()
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]:
print(i.name)
if i.turningPoint:
currentPattern.set_scale(Vector2(2,2))
currentPattern.moveToPosition(i.global_position-spawnpoint.position - Vector2(64,64*4))
#if await currentPattern.getCollidingBorder() != []:
for i in await currentPattern.getCollidingBorder():
#if i.is_in_group("Floor"):
#for j in range(1,3):
#if not await currentPattern.getCollidingBorder() == []:
#break
#currentPattern.position.y -= 64
if i.is_in_group("LeftBorder"):
for j in range(1,8):
currentPattern.moveToPosition(i.global_position-spawnpoint.position)
#currentPattern.position.x - 64
#if i.is_in_group("Block"):
for j in await currentPattern.getCollidingBorder():
if j.is_in_group("Floor"):
currentPattern.position.y -= GLOBAL.GRID
if await currentPattern.getCollidingBorder() == []:
break
currentPattern.position.x += 64
elif i.is_in_group("RightBorder"):
for j in range(1,8):
if await currentPattern.getCollidingBorder() == []:
break
currentPattern.position.x -= 64
#for i in range(1,8):
#print(await currentPattern.getCollidingBorder())
#if await currentPattern.getCollidingBorder() == []:
#break
#currentPattern.position.x -= 64
#currentPattern.position.x = 0
#for i in range(1,8):
#if await currentPattern.getCollidingBorder() == []:
#break
#currentPattern.position.x += 64
#if await currentPattern.getCollidingBorder() != []:
#currentPattern.position.y += 64
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() != []:
#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))
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()
#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():
if i.isCompleted():
@ -297,12 +281,14 @@ func _on_coyote_timer_timeout() -> void:
splitOphansUID(j.UID)
if j.expand:
GLOBAL.points += j.type * 2
GLOBAL.time += j.type * 2
GLOBAL.time += j.type * 4
elif not j.expand:
GLOBAL.points += j.type
GLOBAL.time += j.type
GLOBAL.time += j.type * 2
j.queue_free()
for j in getBlockGroupsList():
if j != GLOBAL.currentUID:
moveUidGroup(GLOBAL.Direction.BOTTOM, j)
PlacePattern()