compatibility with Godot 3.1
This commit is contained in:
@ -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)
|
||||
],
|
||||
},
|
||||
]
|
@ -1,5 +1,5 @@
|
||||
extends "Tetromino.gd"
|
||||
|
||||
func rotate(direction):
|
||||
func turn(direction):
|
||||
return false
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user