T-Spin & stats
This commit is contained in:
parent
05f61c76db
commit
d7768f08ea
@ -560,8 +560,6 @@ _sections_unfolded = [ "Margin", "custom_colors", "custom_fonts" ]
|
||||
|
||||
[connection signal="animation_finished" from="FlashText/AnimationPlayer" to="FlashText" method="_on_AnimationPlayer_animation_finished"]
|
||||
|
||||
[connection signal="flash_text" from="Stats" to="FlashText" method="print"]
|
||||
|
||||
[connection signal="level_up" from="Stats" to="." method="new_level"]
|
||||
|
||||
[connection signal="start" from="Start" to="." method="new_game"]
|
||||
|
@ -1,14 +1,13 @@
|
||||
extends MarginContainer
|
||||
|
||||
const SCORES = [
|
||||
[0, 4, 1],
|
||||
[1, 8, 2],
|
||||
[3, 12],
|
||||
[5, 16],
|
||||
[8]
|
||||
{"": 0, "MINI T-SPIN": 1, "T-SPIN": 4},
|
||||
{"": 1, "MINI T-SPIN": 2, "T-SPIN": 8},
|
||||
{"": 3, "T-SPIN": 12},
|
||||
{"": 5, "T-SPIN": 16},
|
||||
{"": 8}
|
||||
]
|
||||
const LINES_CLEARED_NAMES = ["", "SINGLE", "DOUBLE", "TRIPLE", "TETRIS"]
|
||||
const T_SPIN_NAMES = ["", "T-SPIN", "MINI T-SPIN"]
|
||||
const password = "TETRIS 3000"
|
||||
|
||||
var level
|
||||
@ -17,12 +16,13 @@ var score
|
||||
var high_score
|
||||
var time
|
||||
var combos
|
||||
var flash_text
|
||||
|
||||
signal flash_text(text)
|
||||
signal level_up(level)
|
||||
|
||||
func _ready():
|
||||
load_user_data()
|
||||
flash_text = get_node("../FlashText")
|
||||
|
||||
func load_user_data():
|
||||
var save_game = File.new()
|
||||
@ -49,7 +49,7 @@ func new_level():
|
||||
goal += 5 * level
|
||||
$VBC/Level.text = str(level)
|
||||
$VBC/Goal.text = str(goal)
|
||||
emit_signal("flash_text", "Level\n%d"%level)
|
||||
flash_text.print("Level\n%d"%level)
|
||||
emit_signal("level_up", level)
|
||||
|
||||
func _on_Clock_timeout():
|
||||
@ -69,16 +69,16 @@ func piece_dropped(ds):
|
||||
func piece_locked(lines, t_spin):
|
||||
var ds
|
||||
if lines or t_spin:
|
||||
var text = T_SPIN_NAMES[t_spin]
|
||||
var text = t_spin
|
||||
if lines and t_spin:
|
||||
text += " "
|
||||
text += LINES_CLEARED_NAMES[lines]
|
||||
emit_signal("flash_text", text)
|
||||
flash_text.print(text)
|
||||
ds = SCORES[lines][t_spin]
|
||||
goal -= ds
|
||||
$VBC/Goal.text = str(goal)
|
||||
ds *= 100 * level
|
||||
emit_signal("flash_text", str(ds))
|
||||
flash_text.print(str(ds))
|
||||
score += ds
|
||||
$VBC/Score.text = str(score)
|
||||
if score > high_score:
|
||||
@ -89,9 +89,9 @@ func piece_locked(lines, t_spin):
|
||||
combos += 1
|
||||
if combos > 0:
|
||||
if combos == 1:
|
||||
emit_signal("flash_text", "COMBO")
|
||||
flash_text.print("COMBO")
|
||||
else:
|
||||
emit_signal("flash_text", "COMBO x%d"%combos)
|
||||
flash_text.print("COMBO x%d"%combos)
|
||||
ds = (20 if lines==1 else 50) * combos * level
|
||||
emit_signal("flash_text", str(ds))
|
||||
score += ds
|
||||
|
@ -7,19 +7,22 @@ const T_SLOT = [
|
||||
Vector3(-1, -1, 0)
|
||||
]
|
||||
|
||||
var rotation_point_5_used = false
|
||||
|
||||
func rotate(direction):
|
||||
var rotation_point = .rotate(direction)
|
||||
if rotation_point and t_spin != T_SPIN:
|
||||
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):
|
||||
t_spin = T_SPIN
|
||||
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):
|
||||
if rotation_point == 5:
|
||||
t_spin = T_SPIN
|
||||
t_spin = "MINI T-SPIN"
|
||||
else:
|
||||
t_spin = MINI_T_SPIN
|
||||
t_spin = ""
|
||||
if rotation_point == 5:
|
||||
rotation_point_5_used = true
|
||||
return rotation_point
|
@ -3,9 +3,6 @@ extends Spatial
|
||||
const NB_MINOES = 4
|
||||
const CLOCKWISE = -1
|
||||
const COUNTERCLOCKWISE = 1
|
||||
const NO_T_SPIN = 0
|
||||
const T_SPIN = 1
|
||||
const MINI_T_SPIN = 2
|
||||
const SUPER_ROTATION_SYSTEM = [
|
||||
{
|
||||
COUNTERCLOCKWISE: [
|
||||
@ -77,7 +74,7 @@ var minoes = []
|
||||
var grid_map
|
||||
var lock_delay
|
||||
var orientation = 0
|
||||
var t_spin = NO_T_SPIN
|
||||
var t_spin = ""
|
||||
|
||||
func _ready():
|
||||
randomize()
|
||||
|
Loading…
x
Reference in New Issue
Block a user