graphism
This commit is contained in:
parent
5111958ddc
commit
f1c355b528
52
Main.gd
52
Main.gd
@ -42,11 +42,6 @@ var autoshift_action = ""
|
||||
|
||||
var playing = true
|
||||
|
||||
var level
|
||||
var goal
|
||||
var score
|
||||
var time
|
||||
|
||||
func random_piece():
|
||||
if not random_bag:
|
||||
random_bag = [
|
||||
@ -63,22 +58,15 @@ func _ready():
|
||||
new_game()
|
||||
|
||||
func new_game():
|
||||
level = 0
|
||||
goal = 0
|
||||
score = 0
|
||||
time = 0
|
||||
$Stats.visible = true
|
||||
$Stats.new_game()
|
||||
resume()
|
||||
new_level()
|
||||
new_piece()
|
||||
|
||||
func new_level():
|
||||
level += 1
|
||||
goal += 5 * 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)
|
||||
$Stats/HBC/VBC1/Level.text = str(level)
|
||||
$Stats/HBC/VBC1/Goal.text = str(goal)
|
||||
$Stats.new_level()
|
||||
$DropTimer.wait_time = pow(0.8 - (($Stats.level - 1) * 0.007), $Stats.level - 1)
|
||||
|
||||
func new_piece():
|
||||
current_piece = next_piece
|
||||
@ -162,11 +150,8 @@ func lock():
|
||||
remove_child(current_piece)
|
||||
var lines_cleared = $GridMap.clear_lines()
|
||||
if lines_cleared or current_piece.t_spin:
|
||||
var s = SCORES[lines_cleared][current_piece.t_spin]
|
||||
score += 100 * s
|
||||
goal -= s
|
||||
print_temp(T_SPIN_NAMES[current_piece.t_spin] + ' ' + LINES_CLEARED_NAMES[lines_cleared] + "\nScore " + str(score))
|
||||
$Stats/HBC/VBC1/Score.text = str(score)
|
||||
$Stats.update_score(SCORES[lines_cleared][current_piece.t_spin])
|
||||
print_temp(T_SPIN_NAMES[current_piece.t_spin] + ' ' + LINES_CLEARED_NAMES[lines_cleared])
|
||||
if lines_cleared == Tetromino.NB_MINOES:
|
||||
for channel in LINE_CLEAR_MIDI_CHANNELS:
|
||||
$MidiPlayer.channel_status[channel].vomume = 127
|
||||
@ -177,7 +162,7 @@ func lock():
|
||||
$LineCLearTimer.wait_time = 0.43
|
||||
$MidiPlayer.unmute_channels(LINE_CLEAR_MIDI_CHANNELS)
|
||||
$LineCLearTimer.start()
|
||||
if goal <= 0:
|
||||
if $Stats.goal <= 0:
|
||||
new_level()
|
||||
new_piece()
|
||||
|
||||
@ -200,8 +185,8 @@ func resume():
|
||||
playing = true
|
||||
$DropTimer.start()
|
||||
$LockDelay.start()
|
||||
$Clock.start()
|
||||
time = OS.get_system_time_secs() - time
|
||||
$Stats.time = OS.get_system_time_secs() - $Stats.time
|
||||
$Stats/Clock.start()
|
||||
$MidiPlayer.resume()
|
||||
$MidiPlayer.mute_channels(LINE_CLEAR_MIDI_CHANNELS)
|
||||
print_temp("RESUME")
|
||||
@ -210,8 +195,8 @@ func pause():
|
||||
playing = false
|
||||
$DropTimer.stop()
|
||||
$LockDelay.stop()
|
||||
$Clock.stop()
|
||||
time = OS.get_system_time_secs() - time
|
||||
$Stats/Clock.stop()
|
||||
$Stats.time = OS.get_system_time_secs() - $Stats.time
|
||||
$MidiPlayer.stop()
|
||||
print_temp("PAUSE")
|
||||
|
||||
@ -220,10 +205,10 @@ func game_over():
|
||||
print_temp("GAME OVER")
|
||||
|
||||
func _notification(what):
|
||||
if what == MainLoop.NOTIFICATION_WM_FOCUS_OUT:
|
||||
pause()
|
||||
if what == MainLoop.NOTIFICATION_WM_FOCUS_IN:
|
||||
resume()
|
||||
if what == MainLoop.NOTIFICATION_WM_FOCUS_OUT:
|
||||
pause()
|
||||
#if what == MainLoop.NOTIFICATION_WM_FOCUS_IN:
|
||||
# resume()
|
||||
|
||||
func _on_LineCLearTimer_timeout():
|
||||
$MidiPlayer.mute_channels(LINE_CLEAR_MIDI_CHANNELS)
|
||||
@ -231,10 +216,3 @@ func _on_LineCLearTimer_timeout():
|
||||
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
|
||||
|
58
Stats.gd
Normal file
58
Stats.gd
Normal file
@ -0,0 +1,58 @@
|
||||
extends MarginContainer
|
||||
|
||||
const password= "TETRIS 3000"
|
||||
|
||||
var level
|
||||
var goal
|
||||
var score
|
||||
var high_score
|
||||
var time
|
||||
|
||||
func _ready():
|
||||
var save_game = File.new()
|
||||
if not save_game.file_exists("user://high_score.save"):
|
||||
high_score = 0
|
||||
else:
|
||||
save_game.open_encrypted_with_pass("user://high_score.save", File.READ, password)
|
||||
high_score = int(save_game.get_line())
|
||||
$HBC/VBC1/HighScore.text = str(high_score)
|
||||
save_game.close()
|
||||
|
||||
func new_game():
|
||||
level = 0
|
||||
goal = 0
|
||||
score = 0
|
||||
time = 0
|
||||
|
||||
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)
|
||||
|
||||
func update_score(new_score):
|
||||
score += 100 * new_score
|
||||
$HBC/VBC1/Score.text = str(score)
|
||||
goal -= new_score
|
||||
$HBC/VBC1/Goal.text = str(goal)
|
||||
if score > high_score:
|
||||
high_score = score
|
||||
$HBC/VBC1/HighScore.text = str(high_score)
|
||||
|
||||
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)
|
||||
$HBC/VBC1/Time.text = str(hours) + ":%02d"%minutes + ":%02d"%seconds
|
||||
|
||||
|
||||
func _notification(what):
|
||||
if what == MainLoop.NOTIFICATION_WM_QUIT_REQUEST:
|
||||
var save_game = File.new()
|
||||
save_game.open_encrypted_with_pass("user://high_score.save", File.WRITE, password)
|
||||
save_game.store_line(str(high_score))
|
||||
save_game.close()
|
||||
get_tree().quit()
|
118
Stats.tscn
118
Stats.tscn
@ -1,30 +1,40 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://impact.ttf" type="DynamicFontData" id=1]
|
||||
[ext_resource path="res://Stats.gd" type="Script" id=1]
|
||||
[ext_resource path="res://impact.ttf" type="DynamicFontData" id=2]
|
||||
|
||||
[sub_resource type="DynamicFont" id=2]
|
||||
|
||||
size = 16
|
||||
use_mipmaps = false
|
||||
use_filter = false
|
||||
font_data = ExtResource( 2 )
|
||||
_sections_unfolded = [ "Font", "Settings" ]
|
||||
|
||||
[sub_resource type="DynamicFont" id=1]
|
||||
|
||||
size = 12
|
||||
size = 14
|
||||
use_mipmaps = false
|
||||
use_filter = false
|
||||
font_data = ExtResource( 1 )
|
||||
font_data = ExtResource( 2 )
|
||||
_sections_unfolded = [ "Font", "Settings" ]
|
||||
|
||||
[node name="Stats" type="MarginContainer"]
|
||||
[node name="Stats" type="MarginContainer" index="0"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 1.0
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 1.0
|
||||
anchor_bottom = 0.5
|
||||
margin_left = 20.0
|
||||
margin_top = -132.0
|
||||
margin_right = 78.0
|
||||
margin_right = 134.0
|
||||
margin_bottom = 51.5
|
||||
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
|
||||
script = ExtResource( 1 )
|
||||
_sections_unfolded = [ "Anchor", "Margin", "Size Flags" ]
|
||||
|
||||
[node name="HBC" type="HBoxContainer" parent="." index="0"]
|
||||
@ -34,8 +44,8 @@ anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_left = 16.0
|
||||
margin_right = 112.0
|
||||
margin_bottom = 112.0
|
||||
margin_right = 134.0
|
||||
margin_bottom = 93.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 1
|
||||
@ -51,16 +61,17 @@ anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_right = 54.0
|
||||
margin_bottom = 112.0
|
||||
margin_right = 64.0
|
||||
margin_bottom = 93.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
|
||||
custom_constants/separation = 0
|
||||
alignment = 0
|
||||
_sections_unfolded = [ "Anchor", "Margin", "Size Flags" ]
|
||||
_sections_unfolded = [ "Anchor", "Margin", "Size Flags", "custom_constants" ]
|
||||
|
||||
[node name="Label" type="Label" parent="HBC/VBC0" index="0"]
|
||||
|
||||
@ -68,15 +79,15 @@ anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_right = 54.0
|
||||
margin_bottom = 16.0
|
||||
margin_right = 64.0
|
||||
margin_bottom = 21.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_fonts/font = SubResource( 2 )
|
||||
custom_colors/font_color = Color( 0.517647, 0.756863, 1, 1 )
|
||||
text = "Score:"
|
||||
percent_visible = 1.0
|
||||
@ -89,9 +100,9 @@ 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
|
||||
margin_top = 21.0
|
||||
margin_right = 64.0
|
||||
margin_bottom = 39.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 2
|
||||
@ -111,9 +122,9 @@ 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
|
||||
margin_top = 39.0
|
||||
margin_right = 64.0
|
||||
margin_bottom = 57.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 2
|
||||
@ -133,9 +144,9 @@ 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
|
||||
margin_top = 57.0
|
||||
margin_right = 64.0
|
||||
margin_bottom = 75.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 2
|
||||
@ -155,9 +166,9 @@ 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
|
||||
margin_top = 75.0
|
||||
margin_right = 64.0
|
||||
margin_bottom = 93.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 2
|
||||
@ -177,17 +188,18 @@ 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
|
||||
margin_left = 72.0
|
||||
margin_right = 118.0
|
||||
margin_bottom = 93.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
|
||||
custom_constants/separation = 0
|
||||
alignment = 0
|
||||
_sections_unfolded = [ "Anchor", "Grow Direction", "Margin", "Size Flags", "Visibility" ]
|
||||
_sections_unfolded = [ "Anchor", "Grow Direction", "Margin", "Size Flags", "Visibility", "custom_constants" ]
|
||||
|
||||
[node name="Score" type="Label" parent="HBC/VBC1" index="0"]
|
||||
|
||||
@ -195,15 +207,15 @@ anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_right = 34.0
|
||||
margin_bottom = 16.0
|
||||
margin_right = 46.0
|
||||
margin_bottom = 21.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_fonts/font = SubResource( 2 )
|
||||
custom_colors/font_color = Color( 0.517647, 0.756863, 1, 1 )
|
||||
text = "0"
|
||||
percent_visible = 1.0
|
||||
@ -216,9 +228,9 @@ 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
|
||||
margin_top = 21.0
|
||||
margin_right = 46.0
|
||||
margin_bottom = 39.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 2
|
||||
@ -238,9 +250,9 @@ 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
|
||||
margin_top = 39.0
|
||||
margin_right = 46.0
|
||||
margin_bottom = 57.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 2
|
||||
@ -260,9 +272,9 @@ 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
|
||||
margin_top = 57.0
|
||||
margin_right = 46.0
|
||||
margin_bottom = 75.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 2
|
||||
@ -282,9 +294,9 @@ 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
|
||||
margin_top = 75.0
|
||||
margin_right = 46.0
|
||||
margin_bottom = 93.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 2
|
||||
@ -297,5 +309,15 @@ text = "0"
|
||||
percent_visible = 1.0
|
||||
lines_skipped = 0
|
||||
max_lines_visible = -1
|
||||
_sections_unfolded = [ "custom_fonts" ]
|
||||
|
||||
[node name="Clock" type="Timer" parent="." index="1"]
|
||||
|
||||
process_mode = 1
|
||||
wait_time = 1.0
|
||||
one_shot = false
|
||||
autostart = false
|
||||
|
||||
[connection signal="timeout" from="Clock" to="." method="_on_Clock_timeout"]
|
||||
|
||||
|
||||
|
@ -1,12 +0,0 @@
|
||||
[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" ]
|
||||
|
@ -162,8 +162,9 @@ subdivide_width = 0
|
||||
subdivide_height = 0
|
||||
subdivide_depth = 0
|
||||
|
||||
[node name="Mino" type="Spatial" index="0"]
|
||||
[node name="Mino" type="Spatial"]
|
||||
|
||||
transform = Transform( 0.997027, 0, 0, 0, 0.997027, 0, 0, 0, 0.997027, 0, 0, 0 )
|
||||
_sections_unfolded = [ "Pause", "Transform", "Visibility" ]
|
||||
|
||||
[node name="MinoMesh" parent="." index="0" instance=ExtResource( 1 )]
|
||||
|
@ -1,4 +1,6 @@
|
||||
[gd_resource type="SpatialMaterial" format=2]
|
||||
[gd_resource type="SpatialMaterial" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://Tetrominos/Mino/glass.jpg" type="Texture" id=1]
|
||||
|
||||
[resource]
|
||||
|
||||
@ -24,9 +26,10 @@ params_billboard_mode = 0
|
||||
params_grow = false
|
||||
params_use_alpha_scissor = false
|
||||
albedo_color = Color( 0.601563, 0.775878, 1, 0.162157 )
|
||||
metallic = 0.4
|
||||
metallic = 1.0
|
||||
metallic_specular = 1.0
|
||||
metallic_texture_channel = 0
|
||||
metallic_texture = ExtResource( 1 )
|
||||
metallic_texture_channel = 4
|
||||
roughness = 0.46
|
||||
roughness_texture_channel = 0
|
||||
emission_enabled = true
|
||||
@ -55,5 +58,5 @@ uv2_triplanar_sharpness = 1.0
|
||||
proximity_fade_enable = true
|
||||
proximity_fade_distance = 1.0
|
||||
distance_fade_enable = false
|
||||
_sections_unfolded = [ "Albedo", "Emission", "NormalMap", "Proximity Fade" ]
|
||||
_sections_unfolded = [ "Albedo", "Emission", "Metallic", "NormalMap", "Proximity Fade" ]
|
||||
|
||||
|
BIN
Tetrominos/Mino/glass.jpg
Normal file
BIN
Tetrominos/Mino/glass.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 153 KiB |
30
Tetrominos/Mino/glass.jpg.import
Normal file
30
Tetrominos/Mino/glass.jpg.import
Normal file
@ -0,0 +1,30 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path.s3tc="res://.import/glass.jpg-80b6305d22902972419fc8ecbe408eb8.s3tc.stex"
|
||||
path.etc2="res://.import/glass.jpg-80b6305d22902972419fc8ecbe408eb8.etc2.stex"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Tetrominos/Mino/glass.jpg"
|
||||
dest_files=[ "res://.import/glass.jpg-80b6305d22902972419fc8ecbe408eb8.s3tc.stex", "res://.import/glass.jpg-80b6305d22902972419fc8ecbe408eb8.etc2.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=true
|
||||
flags/filter=true
|
||||
flags/mipmaps=true
|
||||
flags/anisotropic=false
|
||||
flags/srgb=1
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
svg/scale=1.0
|
@ -350,12 +350,7 @@ 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
|
||||
visible = false
|
||||
|
||||
[connection signal="timeout" from="DropTimer" to="." method="_on_DropTimer_timeout"]
|
||||
|
||||
@ -367,6 +362,4 @@ autostart = false
|
||||
|
||||
[connection signal="timeout" from="LineCLearTimer" to="." method="_on_LineCLearTimer_timeout"]
|
||||
|
||||
[connection signal="timeout" from="Clock" to="." method="_on_Clock_timeout"]
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user