diff --git a/source/Main.gd b/source/Main.gd index d4e1396..eae6356 100644 --- a/source/Main.gd +++ b/source/Main.gd @@ -100,9 +100,9 @@ func _unhandled_input(event): if event.is_action_pressed("hard_drop"): hard_drop() if event.is_action_pressed("rotate_clockwise"): - current_piece.rotate(Tetromino.CLOCKWISE) + current_piece.turn(Tetromino.CLOCKWISE) if event.is_action_pressed("rotate_counterclockwise"): - current_piece.rotate(Tetromino.COUNTERCLOCKWISE) + current_piece.turn(Tetromino.COUNTERCLOCKWISE) if event.is_action_pressed("hold"): hold() diff --git a/source/Tetrominos/TetroI.gd b/source/Tetrominos/TetroI.gd index 6f67498..86e3984 100644 --- a/source/Tetrominos/TetroI.gd +++ b/source/Tetrominos/TetroI.gd @@ -1,70 +1,69 @@ extends "Tetromino.gd" -const CLOCKWISE = -1 -const COUNTERCLOCKWISE = 1 -const SUPER_ROTATION_SYSTEM = [ - { - COUNTERCLOCKWISE: [ - Vector3(0, -1, 0), - Vector3(-1, -1, 0), - Vector3(2, -1, 0), - Vector3(-1, 1, 0), - Vector3(2, -2, 0) - ], - CLOCKWISE: [ - Vector3(1, 0, 0), - Vector3(-1, 0, 0), - Vector3(2, 0, 0), - Vector3(-1, -1, 0), - Vector3(2, 2, 0) - ], - }, - { - COUNTERCLOCKWISE: [ - Vector3(-1, 0, 0), - Vector3(1, 0, 0), - Vector3(-2, 0, 0), - Vector3(1, 1, 0), - Vector3(-2, -2, 0) - ], - CLOCKWISE: [ - Vector3(0, -1, 0), - Vector3(-1, -1, 0), - Vector3(2, -1, 0), - Vector3(-1, 1, 0), - Vector3(2, -2, 0) - ], - }, - { - COUNTERCLOCKWISE: [ - Vector3(0, 1, 0), - Vector3(1, 1, 0), - Vector3(-2, 1, 0), - Vector3(1, -1, 0), - Vector3(-2, 2, 0) - ], - CLOCKWISE: [ - Vector3(-1, 0, 0), - Vector3(1, 0, 0), - Vector3(-2, 0, 0), - Vector3(1, 1, 0), - Vector3(-2, -2, 0) - ], - }, - { - COUNTERCLOCKWISE: [ - Vector3(1, 0, 0), - Vector3(-1, 0, 0), - Vector3(2, 0, 0), - Vector3(-1, -1, 0), - Vector3(2, 2, 0) - ], - CLOCKWISE: [ - Vector3(0, 1, 0), - Vector3(1, 1, 0), - Vector3(-2, 1, 0), - Vector3(1, -1, 0), - Vector3(-2, 2, 0) - ], - }, -] \ No newline at end of file +func _init(): + super_rotation_system = [ + { + COUNTERCLOCKWISE: [ + Vector3(0, -1, 0), + Vector3(-1, -1, 0), + Vector3(2, -1, 0), + Vector3(-1, 1, 0), + Vector3(2, -2, 0) + ], + CLOCKWISE: [ + Vector3(1, 0, 0), + Vector3(-1, 0, 0), + Vector3(2, 0, 0), + Vector3(-1, -1, 0), + Vector3(2, 2, 0) + ], + }, + { + COUNTERCLOCKWISE: [ + Vector3(-1, 0, 0), + Vector3(1, 0, 0), + Vector3(-2, 0, 0), + Vector3(1, 1, 0), + Vector3(-2, -2, 0) + ], + CLOCKWISE: [ + Vector3(0, -1, 0), + Vector3(-1, -1, 0), + Vector3(2, -1, 0), + Vector3(-1, 1, 0), + Vector3(2, -2, 0) + ], + }, + { + COUNTERCLOCKWISE: [ + Vector3(0, 1, 0), + Vector3(1, 1, 0), + Vector3(-2, 1, 0), + Vector3(1, -1, 0), + Vector3(-2, 2, 0) + ], + CLOCKWISE: [ + Vector3(-1, 0, 0), + Vector3(1, 0, 0), + Vector3(-2, 0, 0), + Vector3(1, 1, 0), + Vector3(-2, -2, 0) + ], + }, + { + COUNTERCLOCKWISE: [ + Vector3(1, 0, 0), + Vector3(-1, 0, 0), + Vector3(2, 0, 0), + Vector3(-1, -1, 0), + Vector3(2, 2, 0) + ], + CLOCKWISE: [ + Vector3(0, 1, 0), + Vector3(1, 1, 0), + Vector3(-2, 1, 0), + Vector3(1, -1, 0), + Vector3(-2, 2, 0) + ], + }, + ] \ No newline at end of file diff --git a/source/Tetrominos/TetroO.gd b/source/Tetrominos/TetroO.gd index 90bfd8f..95c7a51 100644 --- a/source/Tetrominos/TetroO.gd +++ b/source/Tetrominos/TetroO.gd @@ -1,5 +1,5 @@ extends "Tetromino.gd" -func rotate(direction): +func turn(direction): return false \ No newline at end of file diff --git a/source/Tetrominos/Tetromino.gd b/source/Tetrominos/Tetromino.gd index 59a7f37..67ddf2a 100644 --- a/source/Tetrominos/Tetromino.gd +++ b/source/Tetrominos/Tetromino.gd @@ -3,7 +3,8 @@ extends Spatial const NB_MINOES = 4 const CLOCKWISE = -1 const COUNTERCLOCKWISE = 1 -const SUPER_ROTATION_SYSTEM = [ + +var super_rotation_system = [ { COUNTERCLOCKWISE: [ Vector3(0, 0, 0), @@ -101,7 +102,7 @@ func move(movement): return true return false -func rotate(direction): +func turn(direction): var translations = get_translations() var rotated_translations = [translations[0]] var center = translations[0] @@ -110,7 +111,7 @@ func rotate(direction): rt = Vector3(-1*direction*rt.y, direction*rt.x, 0) rt += center rotated_translations.append(rt) - var movements = SUPER_ROTATION_SYSTEM[orientation][direction] + var movements = super_rotation_system[orientation][direction] for i in range(movements.size()): if grid_map.possible_positions(rotated_translations, movements[i]): orientation = (orientation - direction) % NB_MINOES diff --git a/source/midi/ADSR.gd b/source/midi/ADSR.gd index a0ec35c..974218a 100644 --- a/source/midi/ADSR.gd +++ b/source/midi/ADSR.gd @@ -36,13 +36,13 @@ func set_instrument( instrument ): self.ads_state = instrument.ads_state self.release_state = instrument.release_state -func play( ): +func play( from_position=0.0 ): self.releasing = false self.timer = 0.0 self.using_timer = 0.0 self.current_volume = self.ads_state[0].volume self.stream.mix_rate = round( self.mix_rate * ( 1.0 + self.pitch_bend * 0.5 ) ) - .play( 0.0 ) + .play( from_position ) self._update_volume( ) func start_release( ):