This commit is contained in:
adrienmalin 2019-01-15 14:56:29 +01:00
parent e45c31a2c6
commit 2b86cdec5c
3 changed files with 14 additions and 20 deletions

View File

@ -83,10 +83,12 @@ func random_piece():
add_child(piece)
return piece
func _on_Stats_level_up():
$DropTimer.wait_time = pow(0.8 - (($Stats.level - 1) * 0.007), $Stats.level - 1)
if $Stats.level > 15:
$LockDelay.wait_time = 0.5 * pow(0.9, $Stats.level-15)
func _on_Stats_level_up(level):
if level <= 15:
$DropTimer.wait_time = pow(0.8 - ((level - 1) * 0.007), level - 1)
else:
$DropTimer.wait_time = 0.01
$LockDelay.wait_time = 0.5 * pow(0.9, level-15)
func _unhandled_input(event):
if event.is_action_pressed("pause"):
@ -95,7 +97,7 @@ func _unhandled_input(event):
elif $controls_ui.enable_resume:
resume()
if event.is_action_pressed("toggle_fullscreen"):
OS.window_fullscreen = !OS.window_fullscreen
OS.window_fullscreen = not OS.window_fullscreen
if playing:
if autoshift_action and event.is_action_released(autoshift_action):
$AutoShiftDelay.stop()
@ -134,17 +136,15 @@ func _on_AutoShiftTimer_timeout():
process_autoshift()
func process_autoshift():
if move(movements[autoshift_action]):
$MidiPlayer.move()
if autoshift_action == "soft_drop":
$Stats.piece_dropped(1)
var moved = move(movements[autoshift_action])
if moved and (autoshift_action == "soft_drop"):
$Stats.piece_dropped(1)
func hard_drop():
var score = 0
while move(movements["soft_drop"]):
score += 2
$Stats.piece_dropped(score)
$MidiPlayer.move()
$LockDelay.stop()
lock()
@ -157,7 +157,6 @@ func move(movement):
func rotate(direction):
if current_piece.rotate(direction):
$LockDelay.start()
$MidiPlayer.move()
func _on_DropTimer_timeout():
move(movements["soft_drop"])
@ -236,7 +235,7 @@ func _notification(what):
match what:
MainLoop.NOTIFICATION_WM_FOCUS_OUT:
if playing:
pause($controls_ui.visible)
pause($controls_ui)
MainLoop.NOTIFICATION_WM_QUIT_REQUEST:
save_user_data()
get_tree().quit()

View File

@ -3,13 +3,12 @@ extends "midi/MidiPlayer.gd"
const Tetromino = preload("res://Tetrominos/Tetromino.gd")
const LINE_CLEAR_CHANNELS = [2, 6]
const MOVE_CHANNELS = []
var muted_events = []
func _ready():
._ready()
mute_channels(LINE_CLEAR_CHANNELS+MOVE_CHANNELS)
mute_channels(LINE_CLEAR_CHANNELS)
func _init_channel( ):
._init_channel()
@ -51,8 +50,4 @@ func piece_locked(lines):
$LineCLearTimer.start()
func _on_LineCLearTimer_timeout():
mute_channels(LINE_CLEAR_CHANNELS)
func move():
unmute_channels(MOVE_CHANNELS)
mute_channels(MOVE_CHANNELS)
mute_channels(LINE_CLEAR_CHANNELS)

View File

@ -18,7 +18,7 @@ var time
var combos
signal flash_text(text)
signal level_up
signal level_up(level)
func new_game(start_level):
level = start_level - 1