This commit is contained in:
adrienmalin 2019-01-01 20:50:27 +01:00
parent 233c07d1b3
commit 5111958ddc
7 changed files with 418 additions and 66 deletions

42
Main.gd
View File

@ -42,9 +42,10 @@ var autoshift_action = ""
var playing = true
var level = 0
var goal = 0
var score = 0
var level
var goal
var score
var time
func random_piece():
if not random_bag:
@ -59,6 +60,13 @@ func random_piece():
return piece
func _ready():
new_game()
func new_game():
level = 0
goal = 0
score = 0
time = 0
resume()
new_level()
new_piece()
@ -69,7 +77,8 @@ func new_level():
$DropTimer.wait_time = pow(0.8 - ((level - 1) * 0.007), level - 1)
if level > 15:
$LockDelay.wait_time = 0.5 * pow(0.9, level-15)
print("LEVEL ", level, " Goal ", goal)
$Stats/HBC/VBC1/Level.text = str(level)
$Stats/HBC/VBC1/Goal.text = str(goal)
func new_piece():
current_piece = next_piece
@ -156,8 +165,8 @@ func lock():
var s = SCORES[lines_cleared][current_piece.t_spin]
score += 100 * s
goal -= s
print(T_SPIN_NAMES[current_piece.t_spin], ' ', LINES_CLEARED_NAMES[lines_cleared], " Score ", score)
print_temp(T_SPIN_NAMES[current_piece.t_spin] + ' ' + LINES_CLEARED_NAMES[lines_cleared] + "\nScore " + str(score))
$Stats/HBC/VBC1/Score.text = str(score)
if lines_cleared == Tetromino.NB_MINOES:
for channel in LINE_CLEAR_MIDI_CHANNELS:
$MidiPlayer.channel_status[channel].vomume = 127
@ -191,20 +200,24 @@ func resume():
playing = true
$DropTimer.start()
$LockDelay.start()
$Clock.start()
time = OS.get_system_time_secs() - time
$MidiPlayer.resume()
$MidiPlayer.mute_channels(LINE_CLEAR_MIDI_CHANNELS)
print("RESUME")
print_temp("RESUME")
func pause():
playing = false
$DropTimer.stop()
$LockDelay.stop()
$Clock.stop()
time = OS.get_system_time_secs() - time
$MidiPlayer.stop()
print("PAUSE")
print_temp("PAUSE")
func game_over():
pause()
print("GAME OVER")
print_temp("GAME OVER")
func _notification(what):
if what == MainLoop.NOTIFICATION_WM_FOCUS_OUT:
@ -214,3 +227,14 @@ 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)
func _on_Clock_timeout():
var time_elapsed = OS.get_system_time_secs() - time
var seconds = time_elapsed % 60
var minutes = int(time_elapsed/60) % 60
var hours = int(time_elapsed/3600)
$Stats/HBC/VBC1/Time.text = str(hours) + ":%02d"%minutes + ":%02d"%seconds

301
Stats.tscn Normal file
View File

@ -0,0 +1,301 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://impact.ttf" type="DynamicFontData" id=1]
[sub_resource type="DynamicFont" id=1]
size = 12
use_mipmaps = false
use_filter = false
font_data = ExtResource( 1 )
_sections_unfolded = [ "Font", "Settings" ]
[node name="Stats" type="MarginContainer"]
anchor_left = 0.0
anchor_top = 1.0
anchor_right = 0.0
anchor_bottom = 1.0
margin_left = 20.0
margin_top = -132.0
margin_right = 78.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 0
size_flags_vertical = 0
_sections_unfolded = [ "Anchor", "Margin", "Size Flags" ]
[node name="HBC" type="HBoxContainer" parent="." index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 16.0
margin_right = 112.0
margin_bottom = 112.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 0
size_flags_vertical = 0
alignment = 0
_sections_unfolded = [ "Anchor", "Margin", "Size Flags", "Theme" ]
[node name="VBC0" type="VBoxContainer" parent="HBC" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 54.0
margin_bottom = 112.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 0
size_flags_vertical = 0
alignment = 0
_sections_unfolded = [ "Anchor", "Margin", "Size Flags" ]
[node name="Label" type="Label" parent="HBC/VBC0" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 54.0
margin_bottom = 16.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.517647, 0.756863, 1, 1 )
text = "Score:"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Label2" type="Label" parent="HBC/VBC0" index="1"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_top = 24.0
margin_right = 54.0
margin_bottom = 40.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.517647, 0.756863, 1, 1 )
text = "High score:"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Label3" type="Label" parent="HBC/VBC0" index="2"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_top = 48.0
margin_right = 54.0
margin_bottom = 64.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.517647, 0.756863, 1, 1 )
text = "Time"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Label4" type="Label" parent="HBC/VBC0" index="3"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_top = 72.0
margin_right = 54.0
margin_bottom = 88.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.517647, 0.756863, 1, 1 )
text = "Level:"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Label5" type="Label" parent="HBC/VBC0" index="4"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_top = 96.0
margin_right = 54.0
margin_bottom = 112.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.517647, 0.756863, 1, 1 )
text = "Goal:"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="VBC1" type="VBoxContainer" parent="HBC" index="1"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 62.0
margin_right = 96.0
margin_bottom = 112.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 0
size_flags_vertical = 0
alignment = 0
_sections_unfolded = [ "Anchor", "Grow Direction", "Margin", "Size Flags", "Visibility" ]
[node name="Score" type="Label" parent="HBC/VBC1" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 34.0
margin_bottom = 16.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.517647, 0.756863, 1, 1 )
text = "0"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="HighScore" type="Label" parent="HBC/VBC1" index="1"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_top = 24.0
margin_right = 34.0
margin_bottom = 40.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.517647, 0.756863, 1, 1 )
text = "0"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Time" type="Label" parent="HBC/VBC1" index="2"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_top = 48.0
margin_right = 34.0
margin_bottom = 64.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.517647, 0.756863, 1, 1 )
text = "0:00:00"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Level" type="Label" parent="HBC/VBC1" index="3"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_top = 72.0
margin_right = 34.0
margin_bottom = 88.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.517647, 0.756863, 1, 1 )
text = "0"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Goal" type="Label" parent="HBC/VBC1" index="4"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_top = 96.0
margin_right = 34.0
margin_bottom = 112.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.517647, 0.756863, 1, 1 )
text = "0"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1

View File

@ -0,0 +1,12 @@
[gd_resource type="DynamicFont" load_steps=2 format=2]
[ext_resource path="res://impact.ttf" type="DynamicFontData" id=1]
[resource]
size = 14
use_mipmaps = false
use_filter = false
font_data = ExtResource( 1 )
_sections_unfolded = [ "Font", "Settings" ]

View File

@ -203,7 +203,7 @@ _sections_unfolded = [ "Draw Passes", "Drawing", "Geometry", "LOD", "Process Mat
[node name="SpotLight" type="SpotLight" parent="." index="2"]
transform = Transform( 1, 0, 0, 0, -4.37114e-008, 1, 0, -1, -4.37114e-008, 0, 0, 1 )
transform = Transform( 1, 0, 0, 0, -4.37114e-008, 1, 0, -1, -4.37114e-008, 0, 0, 0.5 )
layers = 1
light_color = Color( 1, 1, 1, 1 )
light_energy = 4.0

View File

@ -128,3 +128,4 @@ func emit_trail(emit):
trail = mino.get_node("Trail")
trail.emitting = emit
trail.restart()
mino.get_node("SpotLight").visible = emit

View File

@ -1,10 +1,11 @@
[gd_scene load_steps=11 format=2]
[gd_scene load_steps=13 format=2]
[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://Tetrominos/Mino/MinoLibrary.tres" type="MeshLibrary" id=3]
[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]
[sub_resource type="PanoramaSky" id=1]
@ -92,7 +93,7 @@ adjustment_contrast = 1.0
adjustment_saturation = 0.34
_sections_unfolded = [ "Adjustments", "Ambient Light", "Background", "Fog", "Resource" ]
[sub_resource type="SpatialMaterial" id=4]
[sub_resource type="SpatialMaterial" id=3]
render_priority = 0
flags_transparent = true
@ -145,45 +146,37 @@ proximity_fade_distance = 1.0
distance_fade_enable = false
_sections_unfolded = [ "Albedo", "Emission", "Metallic", "NormalMap", "Proximity Fade" ]
[sub_resource type="CubeMesh" id=4]
material = SubResource( 3 )
custom_aabb = AABB( 0, 0, 0, 0, 0, 0 )
size = Vector3( 1, 1, 1 )
subdivide_width = 0
subdivide_height = 0
subdivide_depth = 0
[sub_resource type="CubeMesh" id=5]
material = SubResource( 4 )
material = SubResource( 3 )
custom_aabb = AABB( 0, 0, 0, 0, 0, 0 )
size = Vector3( 1, 1, 1 )
subdivide_width = 0
subdivide_height = 0
subdivide_depth = 0
[sub_resource type="CubeMesh" id=3]
[sub_resource type="Animation" id=6]
material = SubResource( 4 )
custom_aabb = AABB( 0, 0, 0, 0, 0, 0 )
size = Vector3( 1, 1, 1 )
subdivide_width = 0
subdivide_height = 0
subdivide_depth = 0
resource_name = "Nouvelle animation"
length = 1.0
loop = false
step = 0.1
[node name="Main" type="WorldEnvironment"]
environment = SubResource( 2 )
script = ExtResource( 2 )
[node name="HUD" type="Control" parent="." index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 40.0
margin_bottom = 40.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="Camera" type="Camera" parent="." index="1"]
[node name="Camera" type="Camera" parent="." index="0"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 4.5, 10, 12 )
keep_aspect = 1
@ -200,7 +193,7 @@ near = 0.05
far = -1.22275e+007
_sections_unfolded = [ "Transform" ]
[node name="DirectionalLight" type="DirectionalLight" parent="." index="2"]
[node name="DirectionalLight" type="DirectionalLight" parent="." index="1"]
transform = Transform( 1, 0, 0, 0, 0.999391, -0.0348995, 0, 0.0348995, 0.999391, 0, 0, 50 )
layers = 1
@ -228,7 +221,7 @@ directional_shadow_depth_range = 0
directional_shadow_max_distance = 200.0
_sections_unfolded = [ "Light", "Transform" ]
[node name="GridMap" type="GridMap" parent="." index="3"]
[node name="GridMap" type="GridMap" parent="." index="2"]
theme = ExtResource( 3 )
cell_size = Vector3( 1, 1, 1 )
@ -251,7 +244,7 @@ __meta__ = {
NB_LINES = 20
NB_COLLUMNS = 10
[node name="GridBack" type="MeshInstance" parent="." index="4"]
[node name="GridBack" type="MeshInstance" parent="." index="3"]
transform = Transform( 10, 0, 0, 0, 20, 0, 0, 0, 0.1, 4.5, 9.5, -1 )
layers = 1
@ -263,29 +256,29 @@ lod_min_distance = 0.0
lod_min_hysteresis = 0.0
lod_max_distance = 0.0
lod_max_hysteresis = 0.0
mesh = SubResource( 4 )
skeleton = NodePath("..")
material/0 = null
_sections_unfolded = [ "Transform" ]
[node name="HoldBack" type="MeshInstance" parent="." index="4"]
transform = Transform( 7, 0, 0, 0, 7, 0, 0, 0, 0.1, -5, 16, -1 )
layers = 1
material_override = null
cast_shadow = 1
extra_cull_margin = 0.0
use_in_baked_light = false
lod_min_distance = 0.0
lod_min_hysteresis = 0.0
lod_max_distance = 0.0
lod_max_hysteresis = 0.0
mesh = SubResource( 5 )
skeleton = NodePath("..")
material/0 = null
_sections_unfolded = [ "Transform" ]
[node name="HoldBack" type="MeshInstance" parent="." index="5"]
transform = Transform( 7, 0, 0, 0, 7, 0, 0, 0, 0.1, -5, 16, -1 )
layers = 1
material_override = null
cast_shadow = 1
extra_cull_margin = 0.0
use_in_baked_light = false
lod_min_distance = 0.0
lod_min_hysteresis = 0.0
lod_max_distance = 0.0
lod_max_hysteresis = 0.0
mesh = SubResource( 3 )
skeleton = NodePath("..")
material/0 = null
_sections_unfolded = [ "Transform" ]
[node name="NextBack" type="MeshInstance" parent="." index="6"]
[node name="NextBack" type="MeshInstance" parent="." index="5"]
transform = Transform( 7, 0, 0, 0, 7, 0, 0, 0, 0.1, 14, 16, -1 )
layers = 1
@ -297,47 +290,47 @@ lod_min_distance = 0.0
lod_min_hysteresis = 0.0
lod_max_distance = 0.0
lod_max_hysteresis = 0.0
mesh = SubResource( 3 )
mesh = SubResource( 5 )
skeleton = NodePath("..")
material/0 = null
_sections_unfolded = [ "Transform" ]
[node name="DropTimer" type="Timer" parent="." index="7"]
[node name="DropTimer" type="Timer" parent="." index="6"]
process_mode = 1
wait_time = 1.0
one_shot = false
autostart = false
[node name="LockDelay" type="Timer" parent="." index="8"]
[node name="LockDelay" type="Timer" parent="." index="7"]
process_mode = 1
wait_time = 0.5
one_shot = true
autostart = false
[node name="AutoShiftDelay" type="Timer" parent="." index="9"]
[node name="AutoShiftDelay" type="Timer" parent="." index="8"]
process_mode = 1
wait_time = 0.17
one_shot = true
autostart = false
[node name="AutoShiftTimer" type="Timer" parent="." index="10"]
[node name="AutoShiftTimer" type="Timer" parent="." index="9"]
process_mode = 1
wait_time = 0.03
one_shot = false
autostart = false
[node name="LineCLearTimer" type="Timer" parent="." index="11"]
[node name="LineCLearTimer" type="Timer" parent="." index="10"]
process_mode = 1
wait_time = 1.41
one_shot = true
autostart = false
[node name="MidiPlayer" parent="." index="12" instance=ExtResource( 5 )]
[node name="MidiPlayer" parent="." index="11" instance=ExtResource( 5 )]
file = "res://midi/Tetris - Song A.mid"
volume_db = -24
@ -345,6 +338,25 @@ loop = true
loop_start = 1.81
soundfont = "res://midi/TimGM6mb.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="Clock" type="Timer" parent="." index="14"]
process_mode = 1
wait_time = 1.0
one_shot = false
autostart = false
[connection signal="timeout" from="DropTimer" to="." method="_on_DropTimer_timeout"]
[connection signal="timeout" from="LockDelay" to="." method="_on_LockDelay_timeout"]
@ -355,4 +367,6 @@ soundfont = "res://midi/TimGM6mb.sf2"
[connection signal="timeout" from="LineCLearTimer" to="." method="_on_LineCLearTimer_timeout"]
[connection signal="timeout" from="Clock" to="." method="_on_Clock_timeout"]

BIN
impact.ttf Normal file

Binary file not shown.