diff --git a/FlashText.gd b/FlashText.gd new file mode 100644 index 0000000..38cd336 --- /dev/null +++ b/FlashText.gd @@ -0,0 +1,4 @@ +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 new file mode 100644 index 0000000..4d36fe2 --- /dev/null +++ b/FlashText.tscn @@ -0,0 +1,112 @@ +[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 da9b1fc..b212e4d 100644 --- a/Main.gd +++ b/Main.gd @@ -8,6 +8,7 @@ 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) @@ -26,8 +27,13 @@ const SCORES = [ [5, 16], [8] ] -const LINES_CLEARED_NAMES = ["", "SINGLE", "DOUBLE", "TRIPLE", "TETRIS"] -const T_SPIN_NAMES = ["", "T-SPIN", "MINI T-SPIN"] +const SCORE_NAMES = [ + ["", "T-SPIN", "MINI T-SPIN"], + ["SINGLE", "T-SPIN SINGLE", "MINI T-SPIN SINGLE"], + ["DOUBLE", "T-SPIN DOUBLE"], + ["TRIPLE", "T-SPIN TRIPLE"], + ["TETRIS"], +] const LINE_CLEAR_MIDI_CHANNELS = [2, 6] @@ -66,6 +72,7 @@ func new_game(): func new_level(): $Stats.new_level() + flash_print("\n\nLevel\n%d"%$Stats.level) $DropTimer.wait_time = pow(0.8 - (($Stats.level - 1) * 0.007), $Stats.level - 1) func new_piece(): @@ -150,8 +157,9 @@ func lock(): remove_child(current_piece) var lines_cleared = $GridMap.clear_lines() if lines_cleared or current_piece.t_spin: - $Stats.update_score(SCORES[lines_cleared][current_piece.t_spin]) - print_temp(T_SPIN_NAMES[current_piece.t_spin] + ' ' + LINES_CLEARED_NAMES[lines_cleared]) + 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)) if lines_cleared == Tetromino.NB_MINOES: for channel in LINE_CLEAR_MIDI_CHANNELS: $MidiPlayer.channel_status[channel].vomume = 127 @@ -189,7 +197,6 @@ func resume(): $Stats/Clock.start() $MidiPlayer.resume() $MidiPlayer.mute_channels(LINE_CLEAR_MIDI_CHANNELS) - print_temp("RESUME") func pause(): playing = false @@ -198,11 +205,11 @@ func pause(): $Stats/Clock.stop() $Stats.time = OS.get_system_time_secs() - $Stats.time $MidiPlayer.stop() - print_temp("PAUSE") + flash_print("PAUSE") func game_over(): pause() - print_temp("GAME OVER") + flash_print("GAME OVER") func _notification(what): if what == MainLoop.NOTIFICATION_WM_FOCUS_OUT: @@ -213,6 +220,8 @@ func _notification(what): func _on_LineCLearTimer_timeout(): $MidiPlayer.mute_channels(LINE_CLEAR_MIDI_CHANNELS) -func print_temp(text): - #$HUD/HBC/TempText.text = text - print(text) \ No newline at end of file +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 diff --git a/WorldEnvironment.tscn b/Main.tscn similarity index 94% rename from WorldEnvironment.tscn rename to Main.tscn index f4fc010..bf0992d 100644 --- a/WorldEnvironment.tscn +++ b/Main.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=13 format=2] +[gd_scene load_steps=12 format=2] [ext_resource path="res://starmap_g8k.jpg" type="Texture" id=1] [ext_resource path="res://Main.gd" type="Script" id=2] @@ -164,13 +164,6 @@ subdivide_width = 0 subdivide_height = 0 subdivide_depth = 0 -[sub_resource type="Animation" id=6] - -resource_name = "Nouvelle animation" -length = 1.0 -loop = false -step = 0.1 - [node name="Main" type="WorldEnvironment"] environment = SubResource( 2 ) @@ -335,20 +328,10 @@ autostart = false file = "res://midi/Tetris - Song A.mid" volume_db = -24 loop = true -loop_start = 1.81 -soundfont = "res://midi/TimGM6mb.sf2" +loop_start = 1.71 +soundfont = "res://midi/FluidR3 GM.sf2" -[node name="AnimationPlayer" type="AnimationPlayer" parent="." index="12"] - -root_node = NodePath("..") -autoplay = "" -playback_process_mode = 1 -playback_default_blend_time = 0.0 -playback_speed = 1.0 -"anims/Nouvelle animation" = SubResource( 6 ) -blend_times = [ ] - -[node name="Stats" parent="." index="13" instance=ExtResource( 6 )] +[node name="Stats" parent="." index="12" instance=ExtResource( 6 )] visible = false diff --git a/Stats.tscn b/Stats.tscn index e20a584..d4d8b15 100644 --- a/Stats.tscn +++ b/Stats.tscn @@ -1,11 +1,11 @@ [gd_scene load_steps=5 format=2] [ext_resource path="res://Stats.gd" type="Script" id=1] -[ext_resource path="res://impact.ttf" type="DynamicFontData" id=2] +[ext_resource path="res://fonts/Gamer.ttf" type="DynamicFontData" id=2] [sub_resource type="DynamicFont" id=2] -size = 16 +size = 18 use_mipmaps = false use_filter = false font_data = ExtResource( 2 ) @@ -13,7 +13,7 @@ _sections_unfolded = [ "Font", "Settings" ] [sub_resource type="DynamicFont" id=1] -size = 14 +size = 16 use_mipmaps = false use_filter = false font_data = ExtResource( 2 ) @@ -44,8 +44,8 @@ anchor_top = 0.0 anchor_right = 0.0 anchor_bottom = 0.0 margin_left = 16.0 -margin_right = 134.0 -margin_bottom = 93.0 +margin_right = 119.0 +margin_bottom = 67.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false mouse_filter = 1 @@ -61,8 +61,8 @@ anchor_left = 0.0 anchor_top = 0.0 anchor_right = 0.0 anchor_bottom = 0.0 -margin_right = 64.0 -margin_bottom = 93.0 +margin_right = 59.0 +margin_bottom = 67.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false mouse_filter = 1 @@ -79,8 +79,8 @@ anchor_left = 0.0 anchor_top = 0.0 anchor_right = 0.0 anchor_bottom = 0.0 -margin_right = 64.0 -margin_bottom = 21.0 +margin_right = 59.0 +margin_bottom = 15.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false mouse_filter = 2 @@ -88,11 +88,12 @@ mouse_default_cursor_shape = 0 size_flags_horizontal = 1 size_flags_vertical = 4 custom_fonts/font = SubResource( 2 ) -custom_colors/font_color = Color( 0.517647, 0.756863, 1, 1 ) +custom_colors/font_color = Color( 0.443137, 0.709804, 0.819608, 0.533333 ) text = "Score:" percent_visible = 1.0 lines_skipped = 0 max_lines_visible = -1 +_sections_unfolded = [ "custom_fonts" ] [node name="Label2" type="Label" parent="HBC/VBC0" index="1"] @@ -100,9 +101,9 @@ anchor_left = 0.0 anchor_top = 0.0 anchor_right = 0.0 anchor_bottom = 0.0 -margin_top = 21.0 -margin_right = 64.0 -margin_bottom = 39.0 +margin_top = 15.0 +margin_right = 59.0 +margin_bottom = 28.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false mouse_filter = 2 @@ -110,11 +111,12 @@ mouse_default_cursor_shape = 0 size_flags_horizontal = 1 size_flags_vertical = 4 custom_fonts/font = SubResource( 1 ) -custom_colors/font_color = Color( 0.517647, 0.756863, 1, 1 ) +custom_colors/font_color = Color( 0.443137, 0.709804, 0.819608, 0.533333 ) text = "High score:" percent_visible = 1.0 lines_skipped = 0 max_lines_visible = -1 +_sections_unfolded = [ "custom_fonts" ] [node name="Label3" type="Label" parent="HBC/VBC0" index="2"] @@ -122,9 +124,9 @@ anchor_left = 0.0 anchor_top = 0.0 anchor_right = 0.0 anchor_bottom = 0.0 -margin_top = 39.0 -margin_right = 64.0 -margin_bottom = 57.0 +margin_top = 28.0 +margin_right = 59.0 +margin_bottom = 41.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false mouse_filter = 2 @@ -132,7 +134,7 @@ mouse_default_cursor_shape = 0 size_flags_horizontal = 1 size_flags_vertical = 4 custom_fonts/font = SubResource( 1 ) -custom_colors/font_color = Color( 0.517647, 0.756863, 1, 1 ) +custom_colors/font_color = Color( 0.443137, 0.709804, 0.819608, 0.533333 ) text = "Time" percent_visible = 1.0 lines_skipped = 0 @@ -144,9 +146,9 @@ anchor_left = 0.0 anchor_top = 0.0 anchor_right = 0.0 anchor_bottom = 0.0 -margin_top = 57.0 -margin_right = 64.0 -margin_bottom = 75.0 +margin_top = 41.0 +margin_right = 59.0 +margin_bottom = 54.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false mouse_filter = 2 @@ -154,7 +156,7 @@ mouse_default_cursor_shape = 0 size_flags_horizontal = 1 size_flags_vertical = 4 custom_fonts/font = SubResource( 1 ) -custom_colors/font_color = Color( 0.517647, 0.756863, 1, 1 ) +custom_colors/font_color = Color( 0.443137, 0.709804, 0.819608, 0.533333 ) text = "Level:" percent_visible = 1.0 lines_skipped = 0 @@ -166,9 +168,9 @@ anchor_left = 0.0 anchor_top = 0.0 anchor_right = 0.0 anchor_bottom = 0.0 -margin_top = 75.0 -margin_right = 64.0 -margin_bottom = 93.0 +margin_top = 54.0 +margin_right = 59.0 +margin_bottom = 67.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false mouse_filter = 2 @@ -176,7 +178,7 @@ mouse_default_cursor_shape = 0 size_flags_horizontal = 1 size_flags_vertical = 4 custom_fonts/font = SubResource( 1 ) -custom_colors/font_color = Color( 0.517647, 0.756863, 1, 1 ) +custom_colors/font_color = Color( 0.443137, 0.709804, 0.819608, 0.533333 ) text = "Goal:" percent_visible = 1.0 lines_skipped = 0 @@ -188,9 +190,9 @@ anchor_left = 0.0 anchor_top = 0.0 anchor_right = 0.0 anchor_bottom = 0.0 -margin_left = 72.0 -margin_right = 118.0 -margin_bottom = 93.0 +margin_left = 67.0 +margin_right = 103.0 +margin_bottom = 67.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false mouse_filter = 1 @@ -207,8 +209,8 @@ anchor_left = 0.0 anchor_top = 0.0 anchor_right = 0.0 anchor_bottom = 0.0 -margin_right = 46.0 -margin_bottom = 21.0 +margin_right = 36.0 +margin_bottom = 15.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false mouse_filter = 2 @@ -216,11 +218,12 @@ mouse_default_cursor_shape = 0 size_flags_horizontal = 1 size_flags_vertical = 4 custom_fonts/font = SubResource( 2 ) -custom_colors/font_color = Color( 0.517647, 0.756863, 1, 1 ) +custom_colors/font_color = Color( 0.443137, 0.709804, 0.819608, 0.533333 ) text = "0" percent_visible = 1.0 lines_skipped = 0 max_lines_visible = -1 +_sections_unfolded = [ "custom_fonts" ] [node name="HighScore" type="Label" parent="HBC/VBC1" index="1"] @@ -228,9 +231,9 @@ anchor_left = 0.0 anchor_top = 0.0 anchor_right = 0.0 anchor_bottom = 0.0 -margin_top = 21.0 -margin_right = 46.0 -margin_bottom = 39.0 +margin_top = 15.0 +margin_right = 36.0 +margin_bottom = 28.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false mouse_filter = 2 @@ -238,7 +241,7 @@ mouse_default_cursor_shape = 0 size_flags_horizontal = 1 size_flags_vertical = 4 custom_fonts/font = SubResource( 1 ) -custom_colors/font_color = Color( 0.517647, 0.756863, 1, 1 ) +custom_colors/font_color = Color( 0.443137, 0.709804, 0.819608, 0.533333 ) text = "0" percent_visible = 1.0 lines_skipped = 0 @@ -250,9 +253,9 @@ anchor_left = 0.0 anchor_top = 0.0 anchor_right = 0.0 anchor_bottom = 0.0 -margin_top = 39.0 -margin_right = 46.0 -margin_bottom = 57.0 +margin_top = 28.0 +margin_right = 36.0 +margin_bottom = 41.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false mouse_filter = 2 @@ -260,7 +263,7 @@ mouse_default_cursor_shape = 0 size_flags_horizontal = 1 size_flags_vertical = 4 custom_fonts/font = SubResource( 1 ) -custom_colors/font_color = Color( 0.517647, 0.756863, 1, 1 ) +custom_colors/font_color = Color( 0.443137, 0.709804, 0.819608, 0.533333 ) text = "0:00:00" percent_visible = 1.0 lines_skipped = 0 @@ -272,9 +275,9 @@ anchor_left = 0.0 anchor_top = 0.0 anchor_right = 0.0 anchor_bottom = 0.0 -margin_top = 57.0 -margin_right = 46.0 -margin_bottom = 75.0 +margin_top = 41.0 +margin_right = 36.0 +margin_bottom = 54.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false mouse_filter = 2 @@ -282,7 +285,7 @@ mouse_default_cursor_shape = 0 size_flags_horizontal = 1 size_flags_vertical = 4 custom_fonts/font = SubResource( 1 ) -custom_colors/font_color = Color( 0.517647, 0.756863, 1, 1 ) +custom_colors/font_color = Color( 0.443137, 0.709804, 0.819608, 0.533333 ) text = "0" percent_visible = 1.0 lines_skipped = 0 @@ -294,9 +297,9 @@ anchor_left = 0.0 anchor_top = 0.0 anchor_right = 0.0 anchor_bottom = 0.0 -margin_top = 75.0 -margin_right = 46.0 -margin_bottom = 93.0 +margin_top = 54.0 +margin_right = 36.0 +margin_bottom = 67.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false mouse_filter = 2 @@ -304,7 +307,7 @@ mouse_default_cursor_shape = 0 size_flags_horizontal = 1 size_flags_vertical = 4 custom_fonts/font = SubResource( 1 ) -custom_colors/font_color = Color( 0.517647, 0.756863, 1, 1 ) +custom_colors/font_color = Color( 0.443137, 0.709804, 0.819608, 0.533333 ) text = "0" percent_visible = 1.0 lines_skipped = 0 diff --git a/fonts/525-ROUN.TTF b/fonts/525-ROUN.TTF new file mode 100644 index 0000000..529599a Binary files /dev/null and b/fonts/525-ROUN.TTF differ diff --git a/fonts/Gamer.ttf b/fonts/Gamer.ttf new file mode 100644 index 0000000..3821290 Binary files /dev/null and b/fonts/Gamer.ttf differ diff --git a/fonts/impact.ttf b/fonts/impact.ttf new file mode 100644 index 0000000..2675688 Binary files /dev/null and b/fonts/impact.ttf differ diff --git a/project.godot b/project.godot index 89f24fc..a1fd6f3 100644 --- a/project.godot +++ b/project.godot @@ -11,7 +11,7 @@ config_version=3 [application] config/name="TETRIS 3000" -run/main_scene="res://WorldEnvironment.tscn" +run/main_scene="res://Main.tscn" config/icon="res://icon.png" [display]