prepare rotate to be moved in main class
This commit is contained in:
parent
c338885d67
commit
a8dced21f1
@ -1,5 +1,5 @@
|
|||||||
extends "Tetromino.gd"
|
extends "Tetromino.gd"
|
||||||
|
|
||||||
func rotate(direction):
|
const CLOCKWISE = -1
|
||||||
return false
|
const COUNTERCLOCKWISE = 1
|
||||||
|
const SUPER_ROTATION_SYSTEM = [{CLOCKWISE: [], COUNTERCLOCKWISE: []}]
|
||||||
|
@ -101,20 +101,20 @@ func move(movement):
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
func rotate(direction):
|
func rotate(direction):
|
||||||
var t = get_translations()
|
var rotations = SUPER_ROTATION_SYSTEM[orientation][direction]
|
||||||
var rotated_translations = [t[0]]
|
if rotations:
|
||||||
|
var translations = get_translations()
|
||||||
|
var rotated_translations = [translations[0]]
|
||||||
for i in range(1, NB_MINOES):
|
for i in range(1, NB_MINOES):
|
||||||
var v = t[i]
|
var rotated_translation = translations[i] - translations[0]
|
||||||
v -= t[0]
|
rotated_translation = Vector3(-1*direction*rotated_translation.y, direction*rotated_translation.x, 0)
|
||||||
v = Vector3(-1*direction*v.y, direction*v.x, 0)
|
rotated_translation += translations[0]
|
||||||
v += t[0]
|
rotated_translations.append(rotated_translation)
|
||||||
rotated_translations.append(v)
|
for i in range(rotations.size()):
|
||||||
var movements = SUPER_ROTATION_SYSTEM[orientation][direction]
|
if grid_map.possible_positions(rotated_translations, rotations[i]):
|
||||||
for i in range(movements.size()):
|
|
||||||
if grid_map.possible_positions(rotated_translations, movements[i]):
|
|
||||||
orientation = (orientation - direction) % NB_MINOES
|
orientation = (orientation - direction) % NB_MINOES
|
||||||
set_translations(rotated_translations)
|
set_translations(rotated_translations)
|
||||||
translate(movements[i])
|
translate(rotations[i])
|
||||||
lock_delay.start()
|
lock_delay.start()
|
||||||
if i == 4:
|
if i == 4:
|
||||||
rotation_point_5_used = true
|
rotation_point_5_used = true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user