FlashText3
This commit is contained in:
parent
792db2f0c8
commit
e40dd9305f
13
FlashText.gd
Normal file
13
FlashText.gd
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
extends Control
|
||||||
|
|
||||||
|
var texts = PoolStringArray()
|
||||||
|
|
||||||
|
func print(text):
|
||||||
|
texts.append(text)
|
||||||
|
if texts.size() > 2:
|
||||||
|
texts.remove(0)
|
||||||
|
$Label.text = texts.join("\n")
|
||||||
|
$AnimationPlayer.play("Flash")
|
||||||
|
|
||||||
|
func _on_AnimationPlayer_animation_finished(anim_name):
|
||||||
|
texts.resize(0)
|
46
Main.gd
46
Main.gd
@ -66,7 +66,7 @@ func new_game():
|
|||||||
|
|
||||||
func new_level():
|
func new_level():
|
||||||
$Stats.new_level()
|
$Stats.new_level()
|
||||||
flash_print("Level\n%d"%$Stats.level)
|
$FlashText.print("Level\n%d"%$Stats.level)
|
||||||
$DropTimer.wait_time = pow(0.8 - (($Stats.level - 1) * 0.007), $Stats.level - 1)
|
$DropTimer.wait_time = pow(0.8 - (($Stats.level - 1) * 0.007), $Stats.level - 1)
|
||||||
if $Stats.level > 15:
|
if $Stats.level > 15:
|
||||||
$LockDelay.wait_time = 0.5 * pow(0.9, $Stats.level-15)
|
$LockDelay.wait_time = 0.5 * pow(0.9, $Stats.level-15)
|
||||||
@ -158,17 +158,31 @@ func _on_LockDelay_timeout():
|
|||||||
lock()
|
lock()
|
||||||
|
|
||||||
func lock():
|
func lock():
|
||||||
|
var score
|
||||||
$GridMap.lock(current_piece)
|
$GridMap.lock(current_piece)
|
||||||
remove_child(current_piece)
|
remove_child(current_piece)
|
||||||
var lines_cleared = $GridMap.clear_lines()
|
var lines_cleared = $GridMap.clear_lines()
|
||||||
if lines_cleared or current_piece.t_spin:
|
if lines_cleared or current_piece.t_spin:
|
||||||
var new_score = SCORES[lines_cleared][current_piece.t_spin]
|
score = SCORES[lines_cleared][current_piece.t_spin]
|
||||||
$Stats.update_score(new_score)
|
$Stats.update_score(score)
|
||||||
if current_piece.t_spin:
|
if current_piece.t_spin:
|
||||||
flash_print(T_SPIN_NAMES[current_piece.t_spin])
|
$FlashText.print(T_SPIN_NAMES[current_piece.t_spin])
|
||||||
if lines_cleared:
|
if lines_cleared:
|
||||||
flash_print(LINES_CLEARED_NAMES[lines_cleared])
|
$FlashText.print(LINES_CLEARED_NAMES[lines_cleared])
|
||||||
flash_print(str(100*new_score))
|
$FlashText.print(str(100*score))
|
||||||
|
|
||||||
|
# Combos
|
||||||
|
if lines_cleared:
|
||||||
|
$Stats.combos += 1
|
||||||
|
if $Stats.combos > 0:
|
||||||
|
$Stats.score += (20 if lines_cleared==1 else 50) * $Stats.combos * $Stats.level
|
||||||
|
$Stats/HBC/VBC1/Score.text = str($Stats.score)
|
||||||
|
if $Stats.combos == 1:
|
||||||
|
$FlashText.print("COMBO")
|
||||||
|
else:
|
||||||
|
$FlashText.print("COMBO x%d"%$Stats.combos)
|
||||||
|
|
||||||
|
# SFX
|
||||||
if lines_cleared == Tetromino.NB_MINOES:
|
if lines_cleared == Tetromino.NB_MINOES:
|
||||||
for channel in LINE_CLEAR_MIDI_CHANNELS:
|
for channel in LINE_CLEAR_MIDI_CHANNELS:
|
||||||
$MidiPlayer.channel_status[channel].vomume = 127
|
$MidiPlayer.channel_status[channel].vomume = 127
|
||||||
@ -179,10 +193,15 @@ func lock():
|
|||||||
$LineCLearTimer.wait_time = 0.43
|
$LineCLearTimer.wait_time = 0.43
|
||||||
$MidiPlayer.unmute_channels(LINE_CLEAR_MIDI_CHANNELS)
|
$MidiPlayer.unmute_channels(LINE_CLEAR_MIDI_CHANNELS)
|
||||||
$LineCLearTimer.start()
|
$LineCLearTimer.start()
|
||||||
|
else:
|
||||||
|
$Stats.combos = -1
|
||||||
if $Stats.goal <= 0:
|
if $Stats.goal <= 0:
|
||||||
new_level()
|
new_level()
|
||||||
new_piece()
|
new_piece()
|
||||||
|
|
||||||
|
func _on_LineCLearTimer_timeout():
|
||||||
|
$MidiPlayer.mute_channels(LINE_CLEAR_MIDI_CHANNELS)
|
||||||
|
|
||||||
func hold():
|
func hold():
|
||||||
if not current_piece_held:
|
if not current_piece_held:
|
||||||
current_piece_held = true
|
current_piece_held = true
|
||||||
@ -211,7 +230,7 @@ func resume():
|
|||||||
current_piece.visible = true
|
current_piece.visible = true
|
||||||
if held_piece:
|
if held_piece:
|
||||||
held_piece.visible = true
|
held_piece.visible = true
|
||||||
flash_print("GO!")
|
$FlashText.print("GO!")
|
||||||
|
|
||||||
func pause(text = "PAUSE"):
|
func pause(text = "PAUSE"):
|
||||||
playing = false
|
playing = false
|
||||||
@ -226,7 +245,7 @@ func pause(text = "PAUSE"):
|
|||||||
if held_piece:
|
if held_piece:
|
||||||
held_piece.visible = false
|
held_piece.visible = false
|
||||||
$MidiPlayer.stop()
|
$MidiPlayer.stop()
|
||||||
flash_print(text)
|
$FlashText.print(text)
|
||||||
|
|
||||||
func game_over():
|
func game_over():
|
||||||
pause("GAME OVER")
|
pause("GAME OVER")
|
||||||
@ -234,14 +253,3 @@ func game_over():
|
|||||||
func _notification(what):
|
func _notification(what):
|
||||||
if what == MainLoop.NOTIFICATION_WM_FOCUS_OUT:
|
if what == MainLoop.NOTIFICATION_WM_FOCUS_OUT:
|
||||||
pause()
|
pause()
|
||||||
|
|
||||||
func _on_LineCLearTimer_timeout():
|
|
||||||
$MidiPlayer.mute_channels(LINE_CLEAR_MIDI_CHANNELS)
|
|
||||||
|
|
||||||
func flash_print(text):
|
|
||||||
$FlashText/Label.text += text + "\n"
|
|
||||||
if not $FlashText/AnimationPlayer.is_playing():
|
|
||||||
$FlashText/AnimationPlayer.play("Flash")
|
|
||||||
|
|
||||||
func _on_AnimationPlayer_animation_finished(anim_name):
|
|
||||||
$FlashText/Label.text = ""
|
|
||||||
|
10
Main.tscn
10
Main.tscn
@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=15 format=2]
|
[gd_scene load_steps=16 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://starmap_g8k.jpg" type="Texture" id=1]
|
[ext_resource path="res://starmap_g8k.jpg" type="Texture" id=1]
|
||||||
[ext_resource path="res://Main.gd" type="Script" id=2]
|
[ext_resource path="res://Main.gd" type="Script" id=2]
|
||||||
@ -6,7 +6,8 @@
|
|||||||
[ext_resource path="res://GridMap.gd" type="Script" id=4]
|
[ext_resource path="res://GridMap.gd" type="Script" id=4]
|
||||||
[ext_resource path="res://midi/MidiPlayer.tscn" type="PackedScene" id=5]
|
[ext_resource path="res://midi/MidiPlayer.tscn" type="PackedScene" id=5]
|
||||||
[ext_resource path="res://Stats.tscn" type="PackedScene" id=6]
|
[ext_resource path="res://Stats.tscn" type="PackedScene" id=6]
|
||||||
[ext_resource path="res://fonts/525-ROUN.TTF" type="DynamicFontData" id=7]
|
[ext_resource path="res://FlashText.gd" type="Script" id=7]
|
||||||
|
[ext_resource path="res://fonts/525-ROUN.TTF" type="DynamicFontData" id=8]
|
||||||
|
|
||||||
[sub_resource type="PanoramaSky" id=1]
|
[sub_resource type="PanoramaSky" id=1]
|
||||||
|
|
||||||
@ -170,7 +171,7 @@ subdivide_depth = 0
|
|||||||
size = 50
|
size = 50
|
||||||
use_mipmaps = true
|
use_mipmaps = true
|
||||||
use_filter = false
|
use_filter = false
|
||||||
font_data = ExtResource( 7 )
|
font_data = ExtResource( 8 )
|
||||||
_sections_unfolded = [ "Font", "Settings" ]
|
_sections_unfolded = [ "Font", "Settings" ]
|
||||||
|
|
||||||
[sub_resource type="Animation" id=7]
|
[sub_resource type="Animation" id=7]
|
||||||
@ -401,6 +402,7 @@ mouse_filter = 0
|
|||||||
mouse_default_cursor_shape = 0
|
mouse_default_cursor_shape = 0
|
||||||
size_flags_horizontal = 1
|
size_flags_horizontal = 1
|
||||||
size_flags_vertical = 1
|
size_flags_vertical = 1
|
||||||
|
script = ExtResource( 7 )
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="FlashText" index="0"]
|
[node name="Label" type="Label" parent="FlashText" index="0"]
|
||||||
|
|
||||||
@ -448,8 +450,6 @@ _sections_unfolded = [ "Playback Options" ]
|
|||||||
|
|
||||||
[connection signal="timeout" from="LineCLearTimer" to="." method="_on_LineCLearTimer_timeout"]
|
[connection signal="timeout" from="LineCLearTimer" to="." method="_on_LineCLearTimer_timeout"]
|
||||||
|
|
||||||
[connection signal="animation_finished" from="FlashText/AnimationPlayer" to="." method="_on_AnimationPlayer_animation_finished"]
|
|
||||||
|
|
||||||
[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"]
|
||||||
|
|
||||||
|
|
||||||
|
2
Stats.gd
2
Stats.gd
@ -7,6 +7,7 @@ var goal
|
|||||||
var score
|
var score
|
||||||
var high_score
|
var high_score
|
||||||
var time
|
var time
|
||||||
|
var combos
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
var save_game = File.new()
|
var save_game = File.new()
|
||||||
@ -23,6 +24,7 @@ func new_game():
|
|||||||
goal = 0
|
goal = 0
|
||||||
score = 0
|
score = 0
|
||||||
time = 0
|
time = 0
|
||||||
|
combos = -1
|
||||||
|
|
||||||
func new_level():
|
func new_level():
|
||||||
level += 1
|
level += 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user