From b2c8ecdbb7bd3b616f7be032f3d601c7d515cf22 Mon Sep 17 00:00:00 2001 From: adrienmalin <41926238+adrienmalin@users.noreply.github.com> Date: Wed, 2 Jan 2019 01:41:16 +0100 Subject: [PATCH] flash text 2 --- FlashText.gd | 4 -- FlashText.tscn | 112 ------------------------------------------------ Main.gd | 17 +++++--- Main.tscn | 113 ++++++++++++++++++++++++++++++++++++++++++++++++- Stats.gd | 2 - 5 files changed, 121 insertions(+), 127 deletions(-) delete mode 100644 FlashText.gd delete mode 100644 FlashText.tscn diff --git a/FlashText.gd b/FlashText.gd deleted file mode 100644 index 38cd336..0000000 --- a/FlashText.gd +++ /dev/null @@ -1,4 +0,0 @@ -extends Control - -func _on_AnimationPlayer_animation_finished(anim_name): - get_parent().remove_child(self) \ No newline at end of file diff --git a/FlashText.tscn b/FlashText.tscn deleted file mode 100644 index 4d36fe2..0000000 --- a/FlashText.tscn +++ /dev/null @@ -1,112 +0,0 @@ -[gd_scene load_steps=5 format=2] - -[ext_resource path="res://FlashText.gd" type="Script" id=1] -[ext_resource path="res://fonts/525-ROUN.TTF" type="DynamicFontData" id=2] - -[sub_resource type="DynamicFont" id=1] - -size = 50 -use_mipmaps = true -use_filter = false -font_data = ExtResource( 2 ) -_sections_unfolded = [ "Font", "Settings" ] - -[sub_resource type="Animation" id=2] - -resource_name = "Flash" -length = 1.0 -loop = false -step = 0.1 -tracks/0/type = "value" -tracks/0/path = NodePath("Label:custom_fonts/font:size") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/keys = { -"times": PoolRealArray( 0, 0.1, 0.8, 1 ), -"transitions": PoolRealArray( 1, 0, 1, 1 ), -"update": 0, -"values": [ 20, 20, 20, 50 ] -} -tracks/1/type = "value" -tracks/1/path = NodePath("Label:custom_colors/font_color") -tracks/1/interp = 1 -tracks/1/loop_wrap = true -tracks/1/imported = false -tracks/1/enabled = true -tracks/1/keys = { -"times": PoolRealArray( 0, 0.1, 0.8, 1 ), -"transitions": PoolRealArray( 1, 1, 1, 1 ), -"update": 0, -"values": [ Color( 0.445404, 0.710476, 0.820313, 0 ), Color( 0.445404, 0.710476, 0.820313, 0.533765 ), Color( 0.445404, 0.710476, 0.820313, 0.533765 ), Color( 0.445404, 0.710476, 0.820313, 0 ) ] -} -tracks/2/type = "value" -tracks/2/path = NodePath("Label:rect_position") -tracks/2/interp = 1 -tracks/2/loop_wrap = true -tracks/2/imported = false -tracks/2/enabled = true -tracks/2/keys = { -"times": PoolRealArray( 0, 0.1, 0.8, 1 ), -"transitions": PoolRealArray( 1, 1, 1, 1 ), -"update": 0, -"values": [ Vector2( 0, 110 ), Vector2( 0, -50 ), Vector2( 0, -60 ), Vector2( 0, -100 ) ] -} - -[node name="FlashText" type="Control" index="0"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_right = 500.0 -margin_bottom = 500.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 0 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 -script = ExtResource( 1 ) - -[node name="Label" type="Label" parent="." index="0"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_top = -100.0 -margin_right = 500.0 -margin_bottom = 400.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 2 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 4 -custom_fonts/font = SubResource( 1 ) -custom_colors/font_color = Color( 0.445404, 0.710476, 0.820313, 0 ) -text = "TETRIS -3000" -align = 1 -valign = 1 -percent_visible = 1.0 -lines_skipped = 0 -max_lines_visible = -1 -_sections_unfolded = [ "Rect", "custom_colors", "custom_fonts" ] - -[node name="AnimationPlayer" type="AnimationPlayer" parent="." index="1"] - -root_node = NodePath("..") -autoplay = "" -playback_process_mode = 1 -playback_default_blend_time = 0.0 -playback_speed = 1.0 -anims/Flash = SubResource( 2 ) -blend_times = [ ] -_sections_unfolded = [ "Playback Options" ] - -[connection signal="animation_finished" from="AnimationPlayer" to="." method="_on_AnimationPlayer_animation_finished"] - - diff --git a/Main.gd b/Main.gd index b212e4d..99e3db8 100644 --- a/Main.gd +++ b/Main.gd @@ -8,7 +8,6 @@ const TetroO = preload("res://Tetrominos/TetroO.tscn") const TetroS = preload("res://Tetrominos/TetroS.tscn") const TetroT = preload("res://Tetrominos/TetroT.tscn") const TetroZ = preload("res://Tetrominos/TetroZ.tscn") -const FlashText = preload("res://FlashText.tscn") const NEXT_POSITION = Vector3(13, 16, 0) const START_POSITION = Vector3(5, 20, 0) @@ -72,8 +71,10 @@ func new_game(): func new_level(): $Stats.new_level() - flash_print("\n\nLevel\n%d"%$Stats.level) + flash_print("Level\n%d"%$Stats.level) $DropTimer.wait_time = pow(0.8 - (($Stats.level - 1) * 0.007), $Stats.level - 1) + if $Stats.level > 15: + $LockDelay.wait_time = 0.5 * pow(0.9, $Stats.level-15) func new_piece(): current_piece = next_piece @@ -159,7 +160,7 @@ func lock(): if lines_cleared or current_piece.t_spin: var new_score = SCORES[lines_cleared][current_piece.t_spin] $Stats.update_score(new_score) - flash_print(SCORE_NAMES[lines_cleared][current_piece.t_spin] + "\n%d\n\n"%(100*new_score)) + flash_print(SCORE_NAMES[lines_cleared][current_piece.t_spin] + "\n%d"%(100*new_score)) if lines_cleared == Tetromino.NB_MINOES: for channel in LINE_CLEAR_MIDI_CHANNELS: $MidiPlayer.channel_status[channel].vomume = 127 @@ -221,7 +222,9 @@ func _on_LineCLearTimer_timeout(): $MidiPlayer.mute_channels(LINE_CLEAR_MIDI_CHANNELS) func flash_print(text): - var flash_text = FlashText.instance() - add_child(flash_text) - flash_text.get_node("Label").text = text - flash_text.get_node("AnimationPlayer").play("Flash") \ No newline at end of file + $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 = "" diff --git a/Main.tscn b/Main.tscn index bf0992d..886eb29 100644 --- a/Main.tscn +++ b/Main.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=12 format=2] +[gd_scene load_steps=15 format=2] [ext_resource path="res://starmap_g8k.jpg" type="Texture" id=1] [ext_resource path="res://Main.gd" type="Script" id=2] @@ -6,6 +6,7 @@ [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://Stats.tscn" type="PackedScene" id=6] +[ext_resource path="res://fonts/525-ROUN.TTF" type="DynamicFontData" id=7] [sub_resource type="PanoramaSky" id=1] @@ -164,7 +165,58 @@ subdivide_width = 0 subdivide_height = 0 subdivide_depth = 0 -[node name="Main" type="WorldEnvironment"] +[sub_resource type="DynamicFont" id=6] + +size = 50 +use_mipmaps = true +use_filter = false +font_data = ExtResource( 7 ) +_sections_unfolded = [ "Font", "Settings" ] + +[sub_resource type="Animation" id=7] + +resource_name = "Flash" +length = 1.0 +loop = false +step = 0.1 +tracks/0/type = "value" +tracks/0/path = NodePath("Label:custom_fonts/font:size") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0, 0.1, 0.8, 1 ), +"transitions": PoolRealArray( 1, 0, 1, 1 ), +"update": 0, +"values": [ 20, 20, 20, 50 ] +} +tracks/1/type = "value" +tracks/1/path = NodePath("Label:custom_colors/font_color") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/keys = { +"times": PoolRealArray( 0, 0.1, 0.8, 1 ), +"transitions": PoolRealArray( 1, 1, 1, 1 ), +"update": 0, +"values": [ Color( 0.445404, 0.710476, 0.820313, 0 ), Color( 0.445404, 0.710476, 0.820313, 0.533765 ), Color( 0.445404, 0.710476, 0.820313, 0.533765 ), Color( 0.445404, 0.710476, 0.820313, 0 ) ] +} +tracks/2/type = "value" +tracks/2/path = NodePath("Label:rect_position") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/keys = { +"times": PoolRealArray( 0, 0.1, 0.8, 1 ), +"transitions": PoolRealArray( 1, 1, 1, 1 ), +"update": 0, +"values": [ Vector2( 0, 110 ), Vector2( 0, -50 ), Vector2( 0, -60 ), Vector2( 0, -100 ) ] +} + +[node name="Main" type="WorldEnvironment" index="0"] environment = SubResource( 2 ) script = ExtResource( 2 ) @@ -335,6 +387,59 @@ soundfont = "res://midi/FluidR3 GM.sf2" visible = false +[node name="FlashText" type="Control" parent="." index="13"] + +anchor_left = 0.0 +anchor_top = 0.0 +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_right = 500.0 +margin_bottom = 500.0 +rect_pivot_offset = Vector2( 0, 0 ) +rect_clip_content = false +mouse_filter = 0 +mouse_default_cursor_shape = 0 +size_flags_horizontal = 1 +size_flags_vertical = 1 + +[node name="Label" type="Label" parent="FlashText" index="0"] + +anchor_left = 0.0 +anchor_top = 0.0 +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_left = 1.0 +margin_top = -100.0 +margin_right = 501.0 +margin_bottom = 400.0 +rect_pivot_offset = Vector2( 0, 0 ) +rect_clip_content = false +mouse_filter = 2 +mouse_default_cursor_shape = 0 +size_flags_horizontal = 1 +size_flags_vertical = 4 +custom_fonts/font = SubResource( 6 ) +custom_colors/font_color = Color( 0.445404, 0.710476, 0.820313, 0 ) +text = "TETRIS +3000" +align = 1 +valign = 1 +percent_visible = 1.0 +lines_skipped = 0 +max_lines_visible = -1 +_sections_unfolded = [ "Rect", "custom_colors", "custom_fonts" ] + +[node name="AnimationPlayer" type="AnimationPlayer" parent="FlashText" index="1"] + +root_node = NodePath("..") +autoplay = "" +playback_process_mode = 1 +playback_default_blend_time = 0.0 +playback_speed = 1.0 +anims/Flash = SubResource( 7 ) +blend_times = [ ] +_sections_unfolded = [ "Playback Options" ] + [connection signal="timeout" from="DropTimer" to="." method="_on_DropTimer_timeout"] [connection signal="timeout" from="LockDelay" to="." method="_on_LockDelay_timeout"] @@ -345,4 +450,8 @@ visible = false [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"] + diff --git a/Stats.gd b/Stats.gd index 070c8e3..bf3a5c3 100644 --- a/Stats.gd +++ b/Stats.gd @@ -27,8 +27,6 @@ func new_game(): func new_level(): level += 1 goal += 5 * level - if level > 15: - $LockDelay.wait_time = 0.5 * pow(0.9, level-15) $HBC/VBC1/Level.text = str(level) $HBC/VBC1/Goal.text = str(goal)