T-Spin & stats

This commit is contained in:
adrienmalin 2019-01-16 16:31:24 +01:00
parent 05f61c76db
commit d7768f08ea
4 changed files with 24 additions and 26 deletions

View File

@ -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="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="level_up" from="Stats" to="." method="new_level"]
[connection signal="start" from="Start" to="." method="new_game"] [connection signal="start" from="Start" to="." method="new_game"]

View File

@ -1,14 +1,13 @@
extends MarginContainer extends MarginContainer
const SCORES = [ const SCORES = [
[0, 4, 1], {"": 0, "MINI T-SPIN": 1, "T-SPIN": 4},
[1, 8, 2], {"": 1, "MINI T-SPIN": 2, "T-SPIN": 8},
[3, 12], {"": 3, "T-SPIN": 12},
[5, 16], {"": 5, "T-SPIN": 16},
[8] {"": 8}
] ]
const LINES_CLEARED_NAMES = ["", "SINGLE", "DOUBLE", "TRIPLE", "TETRIS"] const LINES_CLEARED_NAMES = ["", "SINGLE", "DOUBLE", "TRIPLE", "TETRIS"]
const T_SPIN_NAMES = ["", "T-SPIN", "MINI T-SPIN"]
const password = "TETRIS 3000" const password = "TETRIS 3000"
var level var level
@ -17,12 +16,13 @@ var score
var high_score var high_score
var time var time
var combos var combos
var flash_text
signal flash_text(text)
signal level_up(level) signal level_up(level)
func _ready(): func _ready():
load_user_data() load_user_data()
flash_text = get_node("../FlashText")
func load_user_data(): func load_user_data():
var save_game = File.new() var save_game = File.new()
@ -49,7 +49,7 @@ func new_level():
goal += 5 * level goal += 5 * level
$VBC/Level.text = str(level) $VBC/Level.text = str(level)
$VBC/Goal.text = str(goal) $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) emit_signal("level_up", level)
func _on_Clock_timeout(): func _on_Clock_timeout():
@ -69,16 +69,16 @@ 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_NAMES[t_spin] var text = t_spin
if lines and t_spin: if lines and t_spin:
text += " " text += " "
text += LINES_CLEARED_NAMES[lines] text += LINES_CLEARED_NAMES[lines]
emit_signal("flash_text", text) flash_text.print(text)
ds = SCORES[lines][t_spin] ds = SCORES[lines][t_spin]
goal -= ds goal -= ds
$VBC/Goal.text = str(goal) $VBC/Goal.text = str(goal)
ds *= 100 * level ds *= 100 * level
emit_signal("flash_text", str(ds)) flash_text.print(str(ds))
score += ds score += ds
$VBC/Score.text = str(score) $VBC/Score.text = str(score)
if score > high_score: if score > high_score:
@ -89,9 +89,9 @@ func piece_locked(lines, t_spin):
combos += 1 combos += 1
if combos > 0: if combos > 0:
if combos == 1: if combos == 1:
emit_signal("flash_text", "COMBO") flash_text.print("COMBO")
else: 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 ds = (20 if lines==1 else 50) * combos * level
emit_signal("flash_text", str(ds)) emit_signal("flash_text", str(ds))
score += ds score += ds

View File

@ -7,19 +7,22 @@ const T_SLOT = [
Vector3(-1, -1, 0) Vector3(-1, -1, 0)
] ]
var rotation_point_5_used = false
func rotate(direction): func rotate(direction):
var rotation_point = .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 center = to_global(minoes[0].translation)
var a = not grid_map.is_free_cell(center + T_SLOT[orientation]) 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 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 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]) var d = not grid_map.is_free_cell(center + T_SLOT[(3+orientation)%4])
if a and b and (c or d): if a and b and (c or d) or rotation_point_5_used:
t_spin = T_SPIN t_spin = "T-SPIN"
elif c and d and (a or b): elif c and d and (a or b):
if rotation_point == 5: t_spin = "MINI T-SPIN"
t_spin = T_SPIN
else: else:
t_spin = MINI_T_SPIN t_spin = ""
if rotation_point == 5:
rotation_point_5_used = true
return rotation_point return rotation_point

View File

@ -3,9 +3,6 @@ extends Spatial
const NB_MINOES = 4 const NB_MINOES = 4
const CLOCKWISE = -1 const CLOCKWISE = -1
const COUNTERCLOCKWISE = 1 const COUNTERCLOCKWISE = 1
const NO_T_SPIN = 0
const T_SPIN = 1
const MINI_T_SPIN = 2
const SUPER_ROTATION_SYSTEM = [ const SUPER_ROTATION_SYSTEM = [
{ {
COUNTERCLOCKWISE: [ COUNTERCLOCKWISE: [
@ -77,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 = NO_T_SPIN var t_spin = ""
func _ready(): func _ready():
randomize() randomize()