Signal fix
This commit is contained in:
parent
17a4804f1a
commit
63e99f4ef3
@ -4,7 +4,7 @@ var texts = PoolStringArray()
|
|||||||
|
|
||||||
func print(text):
|
func print(text):
|
||||||
texts.append(text)
|
texts.append(text)
|
||||||
if texts.size() > 5:
|
if texts.size() > 4:
|
||||||
texts.remove(0)
|
texts.remove(0)
|
||||||
$Label.text = texts.join("\n")
|
$Label.text = texts.join("\n")
|
||||||
$AnimationPlayer.play("Flash")
|
$AnimationPlayer.play("Flash")
|
||||||
|
7
Main.gd
7
Main.gd
@ -21,7 +21,7 @@ const movements = {
|
|||||||
|
|
||||||
var random_bag = []
|
var random_bag = []
|
||||||
|
|
||||||
var next_piece = random_piece()
|
var next_piece
|
||||||
var current_piece
|
var current_piece
|
||||||
var held_piece
|
var held_piece
|
||||||
var current_piece_held = false
|
var current_piece_held = false
|
||||||
@ -50,10 +50,10 @@ func _ready():
|
|||||||
|
|
||||||
func new_game():
|
func new_game():
|
||||||
$Stats.visible = true
|
$Stats.visible = true
|
||||||
$Stats.new_game()
|
next_piece = random_piece()
|
||||||
new_piece()
|
new_piece()
|
||||||
|
$Stats.new_game()
|
||||||
resume()
|
resume()
|
||||||
$Stats.new_level()
|
|
||||||
|
|
||||||
func new_piece():
|
func new_piece():
|
||||||
current_piece = next_piece
|
current_piece = next_piece
|
||||||
@ -173,7 +173,6 @@ func resume():
|
|||||||
current_piece.visible = true
|
current_piece.visible = true
|
||||||
if held_piece:
|
if held_piece:
|
||||||
held_piece.visible = true
|
held_piece.visible = true
|
||||||
$FlashText.print("GO!")
|
|
||||||
|
|
||||||
func pause(text = "PAUSE"):
|
func pause(text = "PAUSE"):
|
||||||
playing = false
|
playing = false
|
||||||
|
@ -373,7 +373,9 @@ autostart = false
|
|||||||
[node name="MidiPlayer" parent="." index="10" instance=ExtResource( 5 )]
|
[node name="MidiPlayer" parent="." index="10" instance=ExtResource( 5 )]
|
||||||
|
|
||||||
script = ExtResource( 6 )
|
script = ExtResource( 6 )
|
||||||
|
file = "res://midi/Tetris - Song A.mid"
|
||||||
loop_start = 1.81
|
loop_start = 1.81
|
||||||
|
soundfont = "res://midi/TimGM6mb.sf2"
|
||||||
|
|
||||||
[node name="LineCLearTimer" type="Timer" parent="MidiPlayer" index="1"]
|
[node name="LineCLearTimer" type="Timer" parent="MidiPlayer" index="1"]
|
||||||
|
|
||||||
|
@ -16,4 +16,4 @@ func _on_Main_piece_locked(lines, t_spin):
|
|||||||
$LineCLearTimer.start()
|
$LineCLearTimer.start()
|
||||||
|
|
||||||
func _on_LineCLearTimer_timeout():
|
func _on_LineCLearTimer_timeout():
|
||||||
mute_channels(LINE_CLEAR_MIDI_CHANNELS
|
mute_channels(LINE_CLEAR_MIDI_CHANNELS)
|
||||||
|
28
Stats.gd
28
Stats.gd
@ -38,13 +38,14 @@ func new_game():
|
|||||||
score = 0
|
score = 0
|
||||||
time = 0
|
time = 0
|
||||||
combos = -1
|
combos = -1
|
||||||
|
new_level()
|
||||||
|
|
||||||
func new_level():
|
func new_level():
|
||||||
level += 1
|
level += 1
|
||||||
goal += 5 * level
|
goal += 5 * level
|
||||||
$HBC/VBC1/Level.text = str(level)
|
$HBC/VBC1/Level.text = str(level)
|
||||||
$HBC/VBC1/Goal.text = str(goal)
|
$HBC/VBC1/Goal.text = str(goal)
|
||||||
emit_signal("flash_text", "Level\n%d"%$level)
|
emit_signal("flash_text", "Level\n%d"%level)
|
||||||
emit_signal("level_up")
|
emit_signal("level_up")
|
||||||
|
|
||||||
func _on_Clock_timeout():
|
func _on_Clock_timeout():
|
||||||
@ -63,17 +64,18 @@ func _notification(what):
|
|||||||
save_game.close()
|
save_game.close()
|
||||||
get_tree().quit()
|
get_tree().quit()
|
||||||
|
|
||||||
func _on_Main_piece_dropped(score):
|
func _on_Main_piece_dropped(ds):
|
||||||
score += lines
|
score += ds
|
||||||
$HBC/VBC1/Score.text = str(score)
|
$HBC/VBC1/Score.text = str(score)
|
||||||
|
|
||||||
func _on_Main_piece_locked(lines, t_spin):
|
func _on_Main_piece_locked(lines, t_spin):
|
||||||
|
var ds
|
||||||
if lines or t_spin:
|
if lines or t_spin:
|
||||||
if t_spin:
|
if t_spin:
|
||||||
$FlashText.print(T_SPIN_NAMES[current_piece.t_spin])
|
emit_signal("flash_text", T_SPIN_NAMES[t_spin])
|
||||||
if lines:
|
if lines:
|
||||||
$FlashText.print(LINES_CLEARED_NAMES[lines_cleared])
|
emit_signal("flash_text", LINES_CLEARED_NAMES[lines])
|
||||||
var ds = SCORES[lines_cleared][current_piece.t_spin]
|
ds = SCORES[lines][t_spin]
|
||||||
goal -= ds
|
goal -= ds
|
||||||
$HBC/VBC1/Goal.text = str(goal)
|
$HBC/VBC1/Goal.text = str(goal)
|
||||||
ds *= 100
|
ds *= 100
|
||||||
@ -87,13 +89,15 @@ func _on_Main_piece_locked(lines, t_spin):
|
|||||||
if lines:
|
if lines:
|
||||||
combos += 1
|
combos += 1
|
||||||
if combos > 0:
|
if combos > 0:
|
||||||
score += (20 if lines==1 else 50) * combos * level
|
if combos == 1:
|
||||||
$HBC/VBC1/Score.text = str(score)
|
|
||||||
if $Stats.combos == 1:
|
|
||||||
emit_signal("flash_text", "COMBO")
|
emit_signal("flash_text", "COMBO")
|
||||||
else:
|
else:
|
||||||
emit_signal("flash_text", "COMBO x%d"%$Stats.combos)
|
emit_signal("flash_text", "COMBO x%d"%combos)
|
||||||
|
ds = (20 if lines==1 else 50) * combos * level
|
||||||
|
emit_signal("flash_text", str(ds))
|
||||||
|
score += ds
|
||||||
|
$HBC/VBC1/Score.text = str(score)
|
||||||
else:
|
else:
|
||||||
$Stats.combos = -1
|
combos = -1
|
||||||
if $Stats.goal <= 0:
|
if goal <= 0:
|
||||||
new_level()
|
new_level()
|
||||||
|
@ -421,4 +421,4 @@ func unmute_channels(channels):
|
|||||||
for channel_id in channels:
|
for channel_id in channels:
|
||||||
channel_mute[channel_id] = false
|
channel_mute[channel_id] = false
|
||||||
for note in muted_events[channel_id]:
|
for note in muted_events[channel_id]:
|
||||||
_process_track_event_note_on(channel_status[channel_id], muted_events[channel_id][note]))
|
_process_track_event_note_on(channel_status[channel_id], muted_events[channel_id][note])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user