Fixed the game timer

This commit is contained in:
Delta-key 2020-07-07 00:39:03 -03:00
parent cf01f940d5
commit aaedef04e0
4 changed files with 49 additions and 91 deletions

View file

@ -17,7 +17,24 @@ var stage_list=[
"res://Scenes/stages/1.tscn",
"res://Scenes/stages/2.tscn",
"res://Scenes/stages/3.tscn",
"res://Scenes/stages/4.tscn"
"res://Scenes/stages/4.tscn",
"res://Scenes/stages/5.tscn",
"res://Scenes/stages/6.tscn",
"res://Scenes/stages/7.tscn",
"res://Scenes/stages/8.tscn",
"res://Scenes/stages/9.tscn",
"res://Scenes/stages/10.tscn",
"res://Scenes/stages/11.tscn",
"res://Scenes/stages/12.tscn",
"res://Scenes/stages/13.tscn",
"res://Scenes/stages/14.tscn",
"res://Scenes/stages/15.tscn",
"res://Scenes/stages/16.tscn",
"res://Scenes/stages/17.tscn",
"res://Scenes/stages/18.tscn",
"res://Scenes/stages/19.tscn",
"res://Scenes/stages/20.tscn",
"res://Scenes/stages/21.tscn"
]
var stage_index=0
var twn
@ -71,15 +88,20 @@ func _ready():
l.wait_time=60
l.autostart=false
l.one_shot=false
l.connect("timeout", global, 'add_to_minutes')
l.connect("timeout",global,'add_to_minutes')
add_child(l)
#print_debug('Global: Done! Timer added.')
#print_debug('Global: Ready! Hope you have fun!')
func add_to_minutes(): minutes+=1
func add_to_minutes():
print_debug("Min add")
minutes+=1
func startTimer(): $timer.start()
func _process(delta):
if Input.is_action_just_pressed("ui_debug") and not OS.has_feature("standalone"):
next_stage()
# change_stage("res://Scenes/stages/20.tscn")
if Input.is_action_just_pressed('ui_mute'):
AudioServer.set_bus_mute(AudioServer.get_bus_index('Master'), !AudioServer.is_bus_mute(AudioServer.get_bus_index('Master')))
OS.set_window_title('DIVER DOWN - FPS: ' + str(Engine.get_frames_per_second()))
@ -98,6 +120,7 @@ func change_stage(stage):
# var i=stage.instance()
# i.add_child(stage_fadein.instance())
if stage.instance().get_node('stage/str_stagename').text=='Stage 2: Going up':
print_debug("Started timer")
startTimer()
if stage.instance().get_node('stage/str_stagename').text=='Stage 4: Walls are only a suggestion':
$music.fade()
@ -110,8 +133,8 @@ func change_stage(stage):
var k=music1.instance()
k.name='music1'
add_child(k)
$timer.stop()
seconds=round($timer.time_left)
$timer.stop()
get_tree().change_scene_to(stage)
changeFromLowPassMusic()

View file

@ -35,7 +35,8 @@ func _ready():
$twn_fade.interpolate_property(self, 'modulate:a', 0, 1, 1.5, Tween.TRANS_QUART, Tween.EASE_IN, 0.5+extra_delay)
$twn_fade.start()
$twn_goup.interpolate_property(self, 'rect_global_position:y', self.rect_global_position.y, self.rect_global_position.y-16, 2.0, Tween.TRANS_QUART, Tween.EASE_IN_OUT, 0.5+extra_delay)
$twn_goup.start()"
$twn_goup.start()
"
[node name="21" type="Node2D"]
script = SubResource( 1 )
@ -43,8 +44,11 @@ script = SubResource( 1 )
[node name="stage" type="Control" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
margin_right = 320.0
margin_bottom = 152.0
margin_right = 384.0
margin_bottom = 216.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="str_tutorial" parent="stage" instance=ExtResource( 1 )]
anchor_right = 1.0
@ -85,6 +89,9 @@ custom_colors/font_color_shadow = Color( 0.33, 0.33, 0.33, 1 )
text = "<<Time here>>"
align = 1
script = SubResource( 3 )
__meta__ = {
"_edit_use_anchors_": false
}
extra_delay = 1.5
[node name="twn_fade" type="Tween" parent="stage/str_tutorial4"]

View file

@ -3,15 +3,10 @@
[ext_resource path="res://Resources/Fonts/protracker.ttf" type="DynamicFontData" id=1]
[sub_resource type="DynamicFont" id=1]
size = 8
use_mipmaps = false
use_filter = false
font_data = ExtResource( 1 )
_sections_unfolded = [ "Extra Spacing", "Font", "Settings" ]
[sub_resource type="GDScript" id=2]
script/source = "extends Label
export (float) var extra_delay=0
func _ready():
@ -19,50 +14,19 @@ func _ready():
$twn_fade.interpolate_property(self, 'modulate:a', 0, 1, 1.5, Tween.TRANS_QUART, Tween.EASE_IN, 0.5+extra_delay)
$twn_fade.start()
$twn_goup.interpolate_property(self, 'rect_global_position:y', self.rect_global_position.y, self.rect_global_position.y-16, 2.0, Tween.TRANS_QUART, Tween.EASE_IN_OUT, 0.5+extra_delay)
$twn_goup.start()"
$twn_goup.start()
"
[node name="str_stagename" type="Label"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 8.0
margin_top = 216.0
margin_right = 218.0
margin_bottom = 236.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_shadow = Color( 0.33, 0.33, 0.33, 1 )
text = "Stage 1: First steps"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
script = SubResource( 2 )
_sections_unfolded = [ "Rect", "custom_colors", "custom_constants", "custom_fonts" ]
extra_delay = 0
[node name="twn_fade" type="Tween" parent="." index="0"]
repeat = false
playback_process_mode = 1
playback_speed = 1.0
playback/active = false
playback/repeat = false
playback/speed = 1.0
[node name="twn_goup" type="Tween" parent="." index="1"]
repeat = false
playback_process_mode = 1
playback_speed = 1.0
playback/active = false
playback/repeat = false
playback/speed = 1.0
[node name="twn_fade" type="Tween" parent="."]
[node name="twn_goup" type="Tween" parent="."]

View file

@ -2,16 +2,11 @@
[ext_resource path="res://Resources/Fonts/protracker.ttf" type="DynamicFontData" id=1]
[sub_resource type="DynamicFont" id=2]
[sub_resource type="DynamicFont" id=1]
size = 8
use_mipmaps = false
use_filter = false
font_data = ExtResource( 1 )
_sections_unfolded = [ "Extra Spacing", "Font", "Settings" ]
[sub_resource type="GDScript" id=3]
[sub_resource type="GDScript" id=2]
script/source = "extends Label
export (float) var extra_delay=0
func _ready():
@ -19,48 +14,17 @@ func _ready():
$twn_fade.interpolate_property(self, 'modulate:a', 0, 1, 1.5, Tween.TRANS_QUART, Tween.EASE_IN, 0.5+extra_delay)
$twn_fade.start()
$twn_goup.interpolate_property(self, 'rect_global_position:y', self.rect_global_position.y, self.rect_global_position.y-16, 2.0, Tween.TRANS_QUART, Tween.EASE_IN_OUT, 0.5+extra_delay)
$twn_goup.start()"
$twn_goup.start()
"
[node name="str_tutorial" type="Label"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 210.0
margin_bottom = 20.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( 2 )
custom_fonts/font = SubResource( 1 )
custom_colors/font_color_shadow = Color( 0.33, 0.33, 0.33, 1 )
text = "Tutorial info here"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
script = SubResource( 3 )
_sections_unfolded = [ "Rect", "custom_colors", "custom_constants", "custom_fonts" ]
extra_delay = 0
[node name="twn_fade" type="Tween" parent="." index="0"]
repeat = false
playback_process_mode = 1
playback_speed = 1.0
playback/active = false
playback/repeat = false
playback/speed = 1.0
[node name="twn_goup" type="Tween" parent="." index="1"]
repeat = false
playback_process_mode = 1
playback_speed = 1.0
playback/active = false
playback/repeat = false
playback/speed = 1.0
script = SubResource( 2 )
[node name="twn_fade" type="Tween" parent="."]
[node name="twn_goup" type="Tween" parent="."]