test t-spin only on lock

This commit is contained in:
adrienmalin
2019-01-16 18:15:56 +01:00
parent d7768f08ea
commit 2417bd5b56
7 changed files with 34 additions and 35 deletions

View File

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

View File

@ -3,8 +3,7 @@
[ext_resource path="res://Tetrominos/TetroO.gd" type="Script" id=1]
[ext_resource path="res://Tetrominos/Mino/Mino.tscn" type="PackedScene" id=2]
[node name="TetroO" type="Spatial" index="0"]
[node name="TetroO" type="Spatial"]
script = ExtResource( 1 )

View File

@ -6,23 +6,16 @@ const T_SLOT = [
Vector3(1, -1, 0),
Vector3(-1, -1, 0)
]
var rotation_point_5_used = false
func rotate(direction):
var rotation_point = .rotate(direction)
if rotation_point:
var center = to_global(minoes[0].translation)
var a = not grid_map.is_free_cell(center + T_SLOT[orientation])
var b = not grid_map.is_free_cell(center + T_SLOT[(1+orientation)%4])
var c = not grid_map.is_free_cell(center + T_SLOT[(2+orientation)%4])
var d = not grid_map.is_free_cell(center + T_SLOT[(3+orientation)%4])
if a and b and (c or d) or rotation_point_5_used:
t_spin = "T-SPIN"
elif c and d and (a or b):
t_spin = "MINI T-SPIN"
else:
t_spin = ""
if rotation_point == 5:
rotation_point_5_used = true
return rotation_point
func t_spin():
var center = to_global(minoes[0].translation)
var a = not grid_map.is_free_cell(center + T_SLOT[orientation])
var b = not grid_map.is_free_cell(center + T_SLOT[(1+orientation)%4])
var c = not grid_map.is_free_cell(center + T_SLOT[(3+orientation)%4])
var d = not grid_map.is_free_cell(center + T_SLOT[(2+orientation)%4])
if rotation_point_5_used or (a and b and (c or d)):
return "T-SPIN"
elif c and d and (a or b):
return "MINI T-SPIN"
else:
return ""

View File

@ -3,7 +3,7 @@
[ext_resource path="res://Tetrominos/TetroT.gd" type="Script" id=1]
[ext_resource path="res://Tetrominos/Mino/Mino.tscn" type="PackedScene" id=2]
[node name="TetroT" type="Spatial" index="0"]
[node name="TetroT" type="Spatial"]
script = ExtResource( 1 )

View File

@ -74,7 +74,7 @@ var minoes = []
var grid_map
var lock_delay
var orientation = 0
var t_spin = ""
var rotation_point_5_used = false
func _ready():
randomize()
@ -112,13 +112,17 @@ func rotate(direction):
var movements = SUPER_ROTATION_SYSTEM[orientation][direction]
for i in range(movements.size()):
if grid_map.possible_positions(rotated_translations, movements[i]):
orientation -= direction
orientation %= NB_MINOES
orientation = (orientation - direction) % NB_MINOES
set_translations(rotated_translations)
translate(movements[i])
lock_delay.start()
return i+1
return 0
if i == 4:
rotation_point_5_used = true
return true
return false
func t_spin():
return ""
func emit_trail(visible):
var trail