compatibility with Godot 3.1

This commit is contained in:
adrienmalin 2019-01-21 16:59:47 +01:00
parent 1b5cccd8c9
commit f220739ffc
5 changed files with 76 additions and 76 deletions

View File

@ -100,9 +100,9 @@ func _unhandled_input(event):
if event.is_action_pressed("hard_drop"): if event.is_action_pressed("hard_drop"):
hard_drop() hard_drop()
if event.is_action_pressed("rotate_clockwise"): if event.is_action_pressed("rotate_clockwise"):
current_piece.rotate(Tetromino.CLOCKWISE) current_piece.turn(Tetromino.CLOCKWISE)
if event.is_action_pressed("rotate_counterclockwise"): if event.is_action_pressed("rotate_counterclockwise"):
current_piece.rotate(Tetromino.COUNTERCLOCKWISE) current_piece.turn(Tetromino.COUNTERCLOCKWISE)
if event.is_action_pressed("hold"): if event.is_action_pressed("hold"):
hold() hold()

View File

@ -1,70 +1,69 @@
extends "Tetromino.gd" extends "Tetromino.gd"
const CLOCKWISE = -1 func _init():
const COUNTERCLOCKWISE = 1 super_rotation_system = [
const SUPER_ROTATION_SYSTEM = [ {
{ COUNTERCLOCKWISE: [
COUNTERCLOCKWISE: [ Vector3(0, -1, 0),
Vector3(0, -1, 0), Vector3(-1, -1, 0),
Vector3(-1, -1, 0), Vector3(2, -1, 0),
Vector3(2, -1, 0), Vector3(-1, 1, 0),
Vector3(-1, 1, 0), Vector3(2, -2, 0)
Vector3(2, -2, 0) ],
], CLOCKWISE: [
CLOCKWISE: [ Vector3(1, 0, 0),
Vector3(1, 0, 0), Vector3(-1, 0, 0),
Vector3(-1, 0, 0), Vector3(2, 0, 0),
Vector3(2, 0, 0), Vector3(-1, -1, 0),
Vector3(-1, -1, 0), Vector3(2, 2, 0)
Vector3(2, 2, 0) ],
], },
}, {
{ COUNTERCLOCKWISE: [
COUNTERCLOCKWISE: [ Vector3(-1, 0, 0),
Vector3(-1, 0, 0), Vector3(1, 0, 0),
Vector3(1, 0, 0), Vector3(-2, 0, 0),
Vector3(-2, 0, 0), Vector3(1, 1, 0),
Vector3(1, 1, 0), Vector3(-2, -2, 0)
Vector3(-2, -2, 0) ],
], CLOCKWISE: [
CLOCKWISE: [ Vector3(0, -1, 0),
Vector3(0, -1, 0), Vector3(-1, -1, 0),
Vector3(-1, -1, 0), Vector3(2, -1, 0),
Vector3(2, -1, 0), Vector3(-1, 1, 0),
Vector3(-1, 1, 0), Vector3(2, -2, 0)
Vector3(2, -2, 0) ],
], },
}, {
{ COUNTERCLOCKWISE: [
COUNTERCLOCKWISE: [ Vector3(0, 1, 0),
Vector3(0, 1, 0), Vector3(1, 1, 0),
Vector3(1, 1, 0), Vector3(-2, 1, 0),
Vector3(-2, 1, 0), Vector3(1, -1, 0),
Vector3(1, -1, 0), Vector3(-2, 2, 0)
Vector3(-2, 2, 0) ],
], CLOCKWISE: [
CLOCKWISE: [ Vector3(-1, 0, 0),
Vector3(-1, 0, 0), Vector3(1, 0, 0),
Vector3(1, 0, 0), Vector3(-2, 0, 0),
Vector3(-2, 0, 0), Vector3(1, 1, 0),
Vector3(1, 1, 0), Vector3(-2, -2, 0)
Vector3(-2, -2, 0) ],
], },
}, {
{ COUNTERCLOCKWISE: [
COUNTERCLOCKWISE: [ Vector3(1, 0, 0),
Vector3(1, 0, 0), Vector3(-1, 0, 0),
Vector3(-1, 0, 0), Vector3(2, 0, 0),
Vector3(2, 0, 0), Vector3(-1, -1, 0),
Vector3(-1, -1, 0), Vector3(2, 2, 0)
Vector3(2, 2, 0) ],
], CLOCKWISE: [
CLOCKWISE: [ Vector3(0, 1, 0),
Vector3(0, 1, 0), Vector3(1, 1, 0),
Vector3(1, 1, 0), Vector3(-2, 1, 0),
Vector3(-2, 1, 0), Vector3(1, -1, 0),
Vector3(1, -1, 0), Vector3(-2, 2, 0)
Vector3(-2, 2, 0) ],
], },
}, ]
]

View File

@ -1,5 +1,5 @@
extends "Tetromino.gd" extends "Tetromino.gd"
func rotate(direction): func turn(direction):
return false return false

View File

@ -3,7 +3,8 @@ extends Spatial
const NB_MINOES = 4 const NB_MINOES = 4
const CLOCKWISE = -1 const CLOCKWISE = -1
const COUNTERCLOCKWISE = 1 const COUNTERCLOCKWISE = 1
const SUPER_ROTATION_SYSTEM = [
var super_rotation_system = [
{ {
COUNTERCLOCKWISE: [ COUNTERCLOCKWISE: [
Vector3(0, 0, 0), Vector3(0, 0, 0),
@ -101,7 +102,7 @@ func move(movement):
return true return true
return false return false
func rotate(direction): func turn(direction):
var translations = get_translations() var translations = get_translations()
var rotated_translations = [translations[0]] var rotated_translations = [translations[0]]
var center = translations[0] var center = translations[0]
@ -110,7 +111,7 @@ func rotate(direction):
rt = Vector3(-1*direction*rt.y, direction*rt.x, 0) rt = Vector3(-1*direction*rt.y, direction*rt.x, 0)
rt += center rt += center
rotated_translations.append(rt) rotated_translations.append(rt)
var movements = SUPER_ROTATION_SYSTEM[orientation][direction] var movements = super_rotation_system[orientation][direction]
for i in range(movements.size()): for i in range(movements.size()):
if grid_map.possible_positions(rotated_translations, movements[i]): if grid_map.possible_positions(rotated_translations, movements[i]):
orientation = (orientation - direction) % NB_MINOES orientation = (orientation - direction) % NB_MINOES

View File

@ -36,13 +36,13 @@ func set_instrument( instrument ):
self.ads_state = instrument.ads_state self.ads_state = instrument.ads_state
self.release_state = instrument.release_state self.release_state = instrument.release_state
func play( ): func play( from_position=0.0 ):
self.releasing = false self.releasing = false
self.timer = 0.0 self.timer = 0.0
self.using_timer = 0.0 self.using_timer = 0.0
self.current_volume = self.ads_state[0].volume self.current_volume = self.ads_state[0].volume
self.stream.mix_rate = round( self.mix_rate * ( 1.0 + self.pitch_bend * 0.5 ) ) self.stream.mix_rate = round( self.mix_rate * ( 1.0 + self.pitch_bend * 0.5 ) )
.play( 0.0 ) .play( from_position )
self._update_volume( ) self._update_volume( )
func start_release( ): func start_release( ):