Fixed Bugs; Added Mobile Support
This commit is contained in:
parent
956b719e62
commit
fdfb6a7d39
35 changed files with 709 additions and 150 deletions
|
|
@ -5,6 +5,10 @@ extends Node2D
|
|||
@onready var tickerTimer = $Ticker
|
||||
@onready var patterns = $Patterns
|
||||
@onready var turnTickTimer = $TurnTick
|
||||
@onready var loseArea = $LoseArea
|
||||
@onready var gameTimer = $GameTimer
|
||||
@onready var coyoteTimer = $CoyoteTimer
|
||||
|
||||
|
||||
var nextBlocks = []
|
||||
|
||||
|
|
@ -16,6 +20,7 @@ var blockSpeed = 0.5
|
|||
|
||||
var stopped = false
|
||||
|
||||
|
||||
func spawnBlock() -> void:
|
||||
var block = nextBlocks[0]
|
||||
GLOBAL.currentBlock = block
|
||||
|
|
@ -31,18 +36,18 @@ func _ready() -> void:
|
|||
|
||||
func _physics_process(delta: float) -> void:
|
||||
|
||||
#for i in $Borders.get_children():
|
||||
#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)
|
||||
for i in getBlockGroupsList():
|
||||
if i != GLOBAL.currentUID:
|
||||
moveUidGroup(GLOBAL.Direction.BOTTOM, i)
|
||||
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]:
|
||||
|
|
@ -54,7 +59,6 @@ func _physics_process(delta: float) -> void:
|
|||
print(5*delta)
|
||||
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]:
|
||||
|
|
@ -181,8 +185,11 @@ func getNewPatterns():
|
|||
newPatterns.append(load(GLOBAL.BLOCKSPATTERS[i]).instantiate())
|
||||
newPatterns.shuffle()
|
||||
newPatterns[0].type = GLOBAL.BLOCKTYPES.HEAVY
|
||||
newPatterns.shuffle()
|
||||
newPatterns[0].expand = true
|
||||
newPatterns.shuffle()
|
||||
for i in newPatterns:
|
||||
i.expand = true
|
||||
patternsArray.append_array(newPatterns)
|
||||
|
||||
func turnBlocks():
|
||||
|
|
@ -202,60 +209,92 @@ func _on_turn_tick_timeout() -> void:
|
|||
func _on_ticker_timeout() -> void:
|
||||
stopped = true
|
||||
if getBlockedDirection(GLOBAL.Direction.BOTTOM, GLOBAL.currentUID):
|
||||
coyoteTimer.start(0.1)
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
#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():
|
||||
if i.isCompleted():
|
||||
for j in i.getRow():
|
||||
splitOphansUID(j.UID)
|
||||
GLOBAL.points += j.type
|
||||
j.queue_free()
|
||||
PlacePattern()
|
||||
|
||||
for i in getBlockGroupsList():
|
||||
moveUidGroup(GLOBAL.Direction.BOTTOM, i)
|
||||
|
||||
tickerTimer.start(blockSpeed)
|
||||
stopped = false
|
||||
|
||||
|
||||
func _on_game_timer_timeout() -> void:
|
||||
if GLOBAL.time + 1 > 0:
|
||||
GLOBAL.time += 1
|
||||
#else:
|
||||
#GLOBAL.lose()
|
||||
gameTimer.start(1)
|
||||
|
||||
|
||||
func _on_coyote_timer_timeout() -> void:
|
||||
for i in $RowTests.get_children():
|
||||
for j in getBlockGroupsList():
|
||||
if j != GLOBAL.currentUID:
|
||||
moveUidGroup(GLOBAL.Direction.BOTTOM, i)
|
||||
stopped = true
|
||||
if loseArea.get_overlapping_areas() != []:
|
||||
GLOBAL.lose()
|
||||
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() != []:
|
||||
for i in await currentPattern.getCollidingBorder():
|
||||
if i.is_in_group("Floor"):
|
||||
currentPattern.position.y -= 64
|
||||
elif i.is_in_group("LeftBorder"):
|
||||
for j in range(1,8):
|
||||
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
|
||||
|
||||
#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():
|
||||
if i.isCompleted():
|
||||
for j in i.getRow():
|
||||
splitOphansUID(j.UID)
|
||||
GLOBAL.points += j.type
|
||||
j.queue_free()
|
||||
PlacePattern()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue