diff --git a/source/Main.gd b/source/Main.gd index 8a17841..1bd54d4 100644 --- a/source/Main.gd +++ b/source/Main.gd @@ -55,6 +55,7 @@ func _on_Start_start(level): remove_child(held_piece) held_piece = null current_piece_held = false + autoshift_action = "" next_piece = random_piece() new_piece() $MidiPlayer.position = 0 @@ -68,7 +69,6 @@ func new_piece(): current_piece = next_piece current_piece.translation = START_POSITION current_piece.emit_trail(true) - autoshift_action = "" next_piece = random_piece() next_piece.translation = NEXT_POSITION if move(THERE): @@ -126,9 +126,11 @@ func _unhandled_input(event): if event.is_action_pressed("hard_drop"): hard_drop() if event.is_action_pressed("rotate_clockwise"): - rotate(Tetromino.CLOCKWISE) + if rotate(Tetromino.CLOCKWISE): + $MidiPlayer.move() if event.is_action_pressed("rotate_counterclockwise"): - rotate(Tetromino.COUNTERCLOCKWISE) + if rotate(Tetromino.COUNTERCLOCKWISE): + $MidiPlayer.move() if event.is_action_pressed("hold"): hold() @@ -142,8 +144,10 @@ func _on_AutoShiftTimer_timeout(): process_autoshift() func process_autoshift(): - if move(movements[autoshift_action]) and autoshift_action == "soft_drop": - emit_signal("piece_dropped", 1) + if move(movements[autoshift_action]): + $MidiPlayer.move() + if autoshift_action == "soft_drop": + emit_signal("piece_dropped", 1) func hard_drop(): var score = 0 diff --git a/source/MidiPlayer.gd b/source/MidiPlayer.gd index 9f37715..8a7937d 100644 --- a/source/MidiPlayer.gd +++ b/source/MidiPlayer.gd @@ -3,12 +3,13 @@ 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) + mute_channels(LINE_CLEAR_CHANNELS+MOVE_CHANNELS) func _init_channel( ): ._init_channel() @@ -51,4 +52,8 @@ func _on_Main_piece_locked(lines, t_spin): $LineCLearTimer.start() func _on_LineCLearTimer_timeout(): - mute_channels(LINE_CLEAR_CHANNELS) \ No newline at end of file + mute_channels(LINE_CLEAR_CHANNELS) + +func move(): + unmute_channels(MOVE_CHANNELS) + mute_channels(MOVE_CHANNELS) \ No newline at end of file