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"):
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()

View File

@ -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)
],
},
]
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)
],
},
]

View File

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

View File

@ -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

View File

@ -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( ):