Signal fix

This commit is contained in:
adrienmalin 2019-01-02 13:40:01 +01:00
parent 17a4804f1a
commit 63e99f4ef3
6 changed files with 24 additions and 19 deletions

View File

@ -4,7 +4,7 @@ var texts = PoolStringArray()
func print(text):
texts.append(text)
if texts.size() > 5:
if texts.size() > 4:
texts.remove(0)
$Label.text = texts.join("\n")
$AnimationPlayer.play("Flash")

View File

@ -21,7 +21,7 @@ const movements = {
var random_bag = []
var next_piece = random_piece()
var next_piece
var current_piece
var held_piece
var current_piece_held = false
@ -50,10 +50,10 @@ func _ready():
func new_game():
$Stats.visible = true
$Stats.new_game()
next_piece = random_piece()
new_piece()
$Stats.new_game()
resume()
$Stats.new_level()
func new_piece():
current_piece = next_piece
@ -173,7 +173,6 @@ func resume():
current_piece.visible = true
if held_piece:
held_piece.visible = true
$FlashText.print("GO!")
func pause(text = "PAUSE"):
playing = false

View File

@ -373,7 +373,9 @@ autostart = false
[node name="MidiPlayer" parent="." index="10" instance=ExtResource( 5 )]
script = ExtResource( 6 )
file = "res://midi/Tetris - Song A.mid"
loop_start = 1.81
soundfont = "res://midi/TimGM6mb.sf2"
[node name="LineCLearTimer" type="Timer" parent="MidiPlayer" index="1"]

View File

@ -16,4 +16,4 @@ func _on_Main_piece_locked(lines, t_spin):
$LineCLearTimer.start()
func _on_LineCLearTimer_timeout():
mute_channels(LINE_CLEAR_MIDI_CHANNELS
mute_channels(LINE_CLEAR_MIDI_CHANNELS)

View File

@ -38,13 +38,14 @@ func new_game():
score = 0
time = 0
combos = -1
new_level()
func new_level():
level += 1
goal += 5 * level
$HBC/VBC1/Level.text = str(level)
$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")
func _on_Clock_timeout():
@ -63,17 +64,18 @@ func _notification(what):
save_game.close()
get_tree().quit()
func _on_Main_piece_dropped(score):
score += lines
func _on_Main_piece_dropped(ds):
score += ds
$HBC/VBC1/Score.text = str(score)
func _on_Main_piece_locked(lines, t_spin):
var ds
if lines or 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:
$FlashText.print(LINES_CLEARED_NAMES[lines_cleared])
var ds = SCORES[lines_cleared][current_piece.t_spin]
emit_signal("flash_text", LINES_CLEARED_NAMES[lines])
ds = SCORES[lines][t_spin]
goal -= ds
$HBC/VBC1/Goal.text = str(goal)
ds *= 100
@ -87,13 +89,15 @@ func _on_Main_piece_locked(lines, t_spin):
if lines:
combos += 1
if combos > 0:
score += (20 if lines==1 else 50) * combos * level
$HBC/VBC1/Score.text = str(score)
if $Stats.combos == 1:
if combos == 1:
emit_signal("flash_text", "COMBO")
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:
$Stats.combos = -1
if $Stats.goal <= 0:
combos = -1
if goal <= 0:
new_level()

View File

@ -421,4 +421,4 @@ func unmute_channels(channels):
for channel_id in channels:
channel_mute[channel_id] = false
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])