test t-spin only on lock
This commit is contained in:
parent
d7768f08ea
commit
2417bd5b56
@ -132,9 +132,10 @@ func _on_DropTimer_timeout():
|
|||||||
|
|
||||||
func lock():
|
func lock():
|
||||||
if $Matrix/GridMap.lock(current_piece):
|
if $Matrix/GridMap.lock(current_piece):
|
||||||
|
var t_spin = current_piece.t_spin()
|
||||||
var lines_cleared = $Matrix/GridMap.clear_lines()
|
var lines_cleared = $Matrix/GridMap.clear_lines()
|
||||||
$Stats.piece_locked(lines_cleared, current_piece.t_spin)
|
$Stats.piece_locked(lines_cleared, t_spin)
|
||||||
if lines_cleared or current_piece.t_spin:
|
if lines_cleared or t_spin:
|
||||||
$MidiPlayer.piece_locked(lines_cleared)
|
$MidiPlayer.piece_locked(lines_cleared)
|
||||||
remove_child(current_piece)
|
remove_child(current_piece)
|
||||||
new_piece()
|
new_piece()
|
||||||
|
@ -69,11 +69,12 @@ func piece_dropped(ds):
|
|||||||
func piece_locked(lines, t_spin):
|
func piece_locked(lines, t_spin):
|
||||||
var ds
|
var ds
|
||||||
if lines or t_spin:
|
if lines or t_spin:
|
||||||
var text = t_spin
|
|
||||||
if lines and t_spin:
|
if lines and t_spin:
|
||||||
text += " "
|
flash_text.print(t_spin + " " + LINES_CLEARED_NAMES[lines])
|
||||||
text += LINES_CLEARED_NAMES[lines]
|
elif lines:
|
||||||
flash_text.print(text)
|
flash_text.print(LINES_CLEARED_NAMES[lines])
|
||||||
|
elif t_spin:
|
||||||
|
flash_text.print(t_spin)
|
||||||
ds = SCORES[lines][t_spin]
|
ds = SCORES[lines][t_spin]
|
||||||
goal -= ds
|
goal -= ds
|
||||||
$VBC/Goal.text = str(goal)
|
$VBC/Goal.text = str(goal)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
extends "Tetromino.gd"
|
extends "Tetromino.gd"
|
||||||
|
|
||||||
func rotate(direction):
|
func rotate(direction):
|
||||||
return 0
|
return false
|
||||||
|
|
@ -3,8 +3,7 @@
|
|||||||
[ext_resource path="res://Tetrominos/TetroO.gd" type="Script" id=1]
|
[ext_resource path="res://Tetrominos/TetroO.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://Tetrominos/Mino/Mino.tscn" type="PackedScene" id=2]
|
[ext_resource path="res://Tetrominos/Mino/Mino.tscn" type="PackedScene" id=2]
|
||||||
|
|
||||||
|
[node name="TetroO" type="Spatial"]
|
||||||
[node name="TetroO" type="Spatial" index="0"]
|
|
||||||
|
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
|
@ -7,22 +7,15 @@ const T_SLOT = [
|
|||||||
Vector3(-1, -1, 0)
|
Vector3(-1, -1, 0)
|
||||||
]
|
]
|
||||||
|
|
||||||
var rotation_point_5_used = false
|
func t_spin():
|
||||||
|
var center = to_global(minoes[0].translation)
|
||||||
func rotate(direction):
|
var a = not grid_map.is_free_cell(center + T_SLOT[orientation])
|
||||||
var rotation_point = .rotate(direction)
|
var b = not grid_map.is_free_cell(center + T_SLOT[(1+orientation)%4])
|
||||||
if rotation_point:
|
var c = not grid_map.is_free_cell(center + T_SLOT[(3+orientation)%4])
|
||||||
var center = to_global(minoes[0].translation)
|
var d = not grid_map.is_free_cell(center + T_SLOT[(2+orientation)%4])
|
||||||
var a = not grid_map.is_free_cell(center + T_SLOT[orientation])
|
if rotation_point_5_used or (a and b and (c or d)):
|
||||||
var b = not grid_map.is_free_cell(center + T_SLOT[(1+orientation)%4])
|
return "T-SPIN"
|
||||||
var c = not grid_map.is_free_cell(center + T_SLOT[(2+orientation)%4])
|
elif c and d and (a or b):
|
||||||
var d = not grid_map.is_free_cell(center + T_SLOT[(3+orientation)%4])
|
return "MINI T-SPIN"
|
||||||
if a and b and (c or d) or rotation_point_5_used:
|
else:
|
||||||
t_spin = "T-SPIN"
|
return ""
|
||||||
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
|
|
@ -3,7 +3,7 @@
|
|||||||
[ext_resource path="res://Tetrominos/TetroT.gd" type="Script" id=1]
|
[ext_resource path="res://Tetrominos/TetroT.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://Tetrominos/Mino/Mino.tscn" type="PackedScene" id=2]
|
[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 )
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ var minoes = []
|
|||||||
var grid_map
|
var grid_map
|
||||||
var lock_delay
|
var lock_delay
|
||||||
var orientation = 0
|
var orientation = 0
|
||||||
var t_spin = ""
|
var rotation_point_5_used = false
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
randomize()
|
randomize()
|
||||||
@ -112,13 +112,17 @@ func rotate(direction):
|
|||||||
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 -= direction
|
orientation = (orientation - direction) % NB_MINOES
|
||||||
orientation %= NB_MINOES
|
|
||||||
set_translations(rotated_translations)
|
set_translations(rotated_translations)
|
||||||
translate(movements[i])
|
translate(movements[i])
|
||||||
lock_delay.start()
|
lock_delay.start()
|
||||||
return i+1
|
if i == 4:
|
||||||
return 0
|
rotation_point_5_used = true
|
||||||
|
return true
|
||||||
|
return false
|
||||||
|
|
||||||
|
func t_spin():
|
||||||
|
return ""
|
||||||
|
|
||||||
func emit_trail(visible):
|
func emit_trail(visible):
|
||||||
var trail
|
var trail
|
||||||
|
Loading…
x
Reference in New Issue
Block a user