time limit

This commit is contained in:
Page Asgardius 2023-10-24 09:36:49 -07:00
parent 72c135ca38
commit d84931a3d4
10 changed files with 105 additions and 71 deletions

6
backgounds/Label.gd Normal file
View file

@ -0,0 +1,6 @@
extends Label
func _process(delta: float) -> void:
if Global.time > Global.timelimit:
set_text("You are out of fuel");

View file

@ -3,17 +3,18 @@ extends Node2D
# Called when the node enters the scene tree for the first time.
var galaxy = load("res://levels/galaxy.tscn").instantiate()
var wait
func _ready():
get_tree().root.add_child.call_deferred(galaxy)
wait = Time.get_ticks_msec()
Global.wait = Time.get_ticks_msec()
#pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if (Time.get_ticks_msec() - wait) >= 1000 && (Input.is_key_pressed(KEY_ESCAPE) || Input.is_joy_button_pressed(0,JOY_BUTTON_X) || Input.is_joy_button_pressed(0,JOY_BUTTON_Y) || Input.is_joy_button_pressed(0,JOY_BUTTON_A) || Input.is_joy_button_pressed(0,JOY_BUTTON_B) || Input.is_joy_button_pressed(0,JOY_BUTTON_BACK) || Input.is_joy_button_pressed(0,JOY_BUTTON_START) || Input.is_joy_button_pressed(0,JOY_BUTTON_RIGHT_SHOULDER) || Input.is_joy_button_pressed(0,JOY_BUTTON_LEFT_SHOULDER)):
if Time.get_ticks_msec() - Global.wait > Global.timelimit:
Global.live = 2
if (Time.get_ticks_msec() - Global.wait) >= 1000 && (Input.is_key_pressed(KEY_ESCAPE) || Input.is_joy_button_pressed(0,JOY_BUTTON_X) || Input.is_joy_button_pressed(0,JOY_BUTTON_Y) || Input.is_joy_button_pressed(0,JOY_BUTTON_A) || Input.is_joy_button_pressed(0,JOY_BUTTON_B) || Input.is_joy_button_pressed(0,JOY_BUTTON_BACK) || Input.is_joy_button_pressed(0,JOY_BUTTON_START) || Input.is_joy_button_pressed(0,JOY_BUTTON_RIGHT_SHOULDER) || Input.is_joy_button_pressed(0,JOY_BUTTON_LEFT_SHOULDER)):
#print("Mouse Click/Unclick at: ", event.position)
_title()
elif Input.is_key_pressed(KEY_C):
@ -40,7 +41,7 @@ func _title():
func _crash():
# This is like autoloading the scene, only
# it happens after already loading the main scene.
Global.time = Time.get_ticks_msec() - wait
Global.time = Time.get_ticks_msec() - Global.wait
await get_tree().create_timer(1.0).timeout
queue_free()
get_tree().root.remove_child(galaxy)
@ -52,7 +53,7 @@ func _crash():
func _complete():
# This is like autoloading the scene, only
# it happens after already loading the main scene.
Global.time = Time.get_ticks_msec() - wait
Global.time = Time.get_ticks_msec() - Global.wait
get_tree().root.remove_child(galaxy)
get_tree().change_scene_to_file("res://levels/credits.tscn")
#get_tree().root.add_child(title)

View file

@ -1,9 +1,7 @@
[gd_scene load_steps=5 format=3 uid="uid://cnstwjy5mqdyo"]
[gd_scene load_steps=3 format=3 uid="uid://cnstwjy5mqdyo"]
[ext_resource type="Texture2D" uid="uid://bona2ytn3y3a5" path="res://backgounds/galaxy.png" id="1_bmyxf"]
[ext_resource type="Script" path="res://backgounds/galaxy.gd" id="1_h1j80"]
[ext_resource type="Script" path="res://fps.gd" id="3_t81vx"]
[ext_resource type="Script" path="res://backgounds/Home.gd" id="4_hhu74"]
[node name="galaxy" type="Node2D"]
script = ExtResource("1_h1j80")
@ -12,15 +10,3 @@ script = ExtResource("1_h1j80")
offset_right = 1280.0
offset_bottom = 720.0
texture = ExtResource("1_bmyxf")
[node name="fps" type="Label" parent="."]
offset_right = 40.0
offset_bottom = 23.0
script = ExtResource("3_t81vx")
[node name="Home" type="TextureButton" parent="."]
offset_left = 52.0
offset_top = 39.0
offset_right = 125.0
offset_bottom = 110.0
script = ExtResource("4_hhu74")

View file

@ -1,7 +1,8 @@
[gd_scene load_steps=5 format=3 uid="uid://cx3x5lteh72xk"]
[gd_scene load_steps=6 format=3 uid="uid://cx3x5lteh72xk"]
[ext_resource type="Texture2D" uid="uid://bqyx3wu4vf408" path="res://backgounds/supernova.png" id="1_0bxam"]
[ext_resource type="Script" path="res://backgounds/supernova.gd" id="1_3jmy0"]
[ext_resource type="Script" path="res://backgounds/Label.gd" id="3_24urm"]
[ext_resource type="Script" path="res://backgounds/Label3.gd" id="3_h0a4u"]
[ext_resource type="Script" path="res://fps.gd" id="3_tbeol"]
@ -20,6 +21,8 @@ offset_right = 99.0
offset_bottom = 112.0
scale = Vector2(6.32794, 4.85128)
text = "Your spaceship crashed"
horizontal_alignment = 1
script = ExtResource("3_24urm")
[node name="Label2" type="Label" parent="."]
offset_left = 108.0

View file

@ -3,17 +3,18 @@ extends Node2D
# Called when the node enters the scene tree for the first time.
var wormhole = load("res://levels/wormhole.tscn").instantiate()
var wait
func _ready():
get_tree().root.add_child.call_deferred(wormhole)
wait = Time.get_ticks_msec()
Global.wait = Time.get_ticks_msec()
#pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if (Time.get_ticks_msec() - wait) >= 1000 && (Input.is_key_pressed(KEY_ESCAPE) || Input.is_joy_button_pressed(0,JOY_BUTTON_X) || Input.is_joy_button_pressed(0,JOY_BUTTON_Y) || Input.is_joy_button_pressed(0,JOY_BUTTON_A) || Input.is_joy_button_pressed(0,JOY_BUTTON_B) || Input.is_joy_button_pressed(0,JOY_BUTTON_BACK) || Input.is_joy_button_pressed(0,JOY_BUTTON_START) || Input.is_joy_button_pressed(0,JOY_BUTTON_RIGHT_SHOULDER) || Input.is_joy_button_pressed(0,JOY_BUTTON_LEFT_SHOULDER)):
if Time.get_ticks_msec() - Global.wait > Global.timelimit:
Global.live = 2
if (Time.get_ticks_msec() - Global.wait) >= 1000 && (Input.is_key_pressed(KEY_ESCAPE) || Input.is_joy_button_pressed(0,JOY_BUTTON_X) || Input.is_joy_button_pressed(0,JOY_BUTTON_Y) || Input.is_joy_button_pressed(0,JOY_BUTTON_A) || Input.is_joy_button_pressed(0,JOY_BUTTON_B) || Input.is_joy_button_pressed(0,JOY_BUTTON_BACK) || Input.is_joy_button_pressed(0,JOY_BUTTON_START) || Input.is_joy_button_pressed(0,JOY_BUTTON_RIGHT_SHOULDER) || Input.is_joy_button_pressed(0,JOY_BUTTON_LEFT_SHOULDER)):
#print("Mouse Click/Unclick at: ", event.position)
_title()
elif Input.is_key_pressed(KEY_C):
@ -40,7 +41,7 @@ func _title():
func _crash():
# This is like autoloading the scene, only
# it happens after already loading the main scene.
Global.time = Time.get_ticks_msec() - wait
Global.time = Time.get_ticks_msec() - Global.wait
await get_tree().create_timer(1.0).timeout
queue_free()
get_tree().root.remove_child(wormhole)
@ -52,7 +53,7 @@ func _crash():
func _complete():
# This is like autoloading the scene, only
# it happens after already loading the main scene.
Global.time = Time.get_ticks_msec() - wait
Global.time = Time.get_ticks_msec() - Global.wait
get_tree().root.remove_child(wormhole)
get_tree().change_scene_to_file("res://levels/credits.tscn")
#get_tree().root.add_child(title)

View file

@ -1,9 +1,7 @@
[gd_scene load_steps=5 format=3 uid="uid://by7ktb1k5ml5y"]
[gd_scene load_steps=3 format=3 uid="uid://by7ktb1k5ml5y"]
[ext_resource type="Script" path="res://backgounds/wormhole.gd" id="1_fibhv"]
[ext_resource type="Texture2D" uid="uid://bcfmwk0ffy73n" path="res://backgounds/wormhole.png" id="2_6mic1"]
[ext_resource type="Script" path="res://fps.gd" id="3_o2q0w"]
[ext_resource type="Script" path="res://backgounds/Home.gd" id="5_elxjd"]
[node name="wormhole" type="Node2D"]
script = ExtResource("1_fibhv")
@ -12,15 +10,3 @@ script = ExtResource("1_fibhv")
offset_right = 1280.0
offset_bottom = 720.0
texture = ExtResource("2_6mic1")
[node name="fps" type="Label" parent="."]
offset_right = 40.0
offset_bottom = 23.0
script = ExtResource("3_o2q0w")
[node name="Home" type="TextureButton" parent="."]
offset_left = 52.0
offset_top = 39.0
offset_right = 125.0
offset_bottom = 110.0
script = ExtResource("5_elxjd")

View file

@ -4,6 +4,8 @@ var live
var time
var origmpos
var mousepos
var timelimit = 15000
var wait
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=22 format=3 uid="uid://mtl88mcwaqk0"]
[gd_scene load_steps=25 format=3 uid="uid://mtl88mcwaqk0"]
[ext_resource type="Script" path="res://levels/galaxy.gd" id="1_3c4wu"]
[ext_resource type="Texture2D" uid="uid://8lioamk650y7" path="res://sprites/css.png" id="2_3g4h6"]
@ -14,11 +14,14 @@
[ext_resource type="Script" path="res://levels/ast1.gd" id="12_g6l6s"]
[ext_resource type="Script" path="res://levels/ast2.gd" id="13_s46s0"]
[ext_resource type="Script" path="res://levels/ast3.gd" id="14_cu7w4"]
[ext_resource type="Script" path="res://levels/ss.gd" id="15_c4337"]
[ext_resource type="Script" path="res://levels/wall1.gd" id="15_jbm4l"]
[ext_resource type="Script" path="res://levels/ss.gd" id="15_n6ui8"]
[ext_resource type="Script" path="res://levels/wall2.gd" id="16_dnhp8"]
[ext_resource type="Script" path="res://levels/wall3.gd" id="17_jrw7x"]
[ext_resource type="Script" path="res://levels/wall4.gd" id="18_fasi1"]
[ext_resource type="Script" path="res://fps.gd" id="20_wbfof"]
[ext_resource type="Script" path="res://levels/timelimit.gd" id="21_4jblw"]
[ext_resource type="Script" path="res://backgounds/Home.gd" id="21_c1w3x"]
[sub_resource type="Gradient" id="Gradient_raqpb"]
colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 1)
@ -60,25 +63,25 @@ texture = ExtResource("2_3g4h6")
script = ExtResource("3_1tarv")
[node name="css3" type="Sprite2D" parent="."]
position = Vector2(2931, 925)
position = Vector2(2745, 708)
scale = Vector2(0.3, 0.3)
texture = ExtResource("2_3g4h6")
script = ExtResource("3_1tarv")
[node name="sat1" type="Sprite2D" parent="."]
position = Vector2(994, -488)
position = Vector2(858, -50)
scale = Vector2(0.3, 0.3)
texture = ExtResource("4_as4jm")
script = ExtResource("3_1tarv")
[node name="sat2" type="Sprite2D" parent="."]
position = Vector2(1177, -4)
position = Vector2(1389, -115)
scale = Vector2(0.3, 0.3)
texture = ExtResource("4_as4jm")
script = ExtResource("3_1tarv")
[node name="sat3" type="Sprite2D" parent="."]
position = Vector2(2721, -234)
position = Vector2(2726, -53)
scale = Vector2(0.3, 0.3)
texture = ExtResource("4_as4jm")
script = ExtResource("3_1tarv")
@ -90,13 +93,13 @@ texture = ExtResource("5_6ivog")
script = ExtResource("3_1tarv")
[node name="iss2" type="Sprite2D" parent="."]
position = Vector2(1991, -175)
position = Vector2(2021, -24)
scale = Vector2(0.5, 0.5)
texture = ExtResource("5_6ivog")
script = ExtResource("3_1tarv")
[node name="iss3" type="Sprite2D" parent="."]
position = Vector2(3236, 4)
position = Vector2(2747, 261)
scale = Vector2(0.5, 0.5)
texture = ExtResource("5_6ivog")
script = ExtResource("3_1tarv")
@ -108,37 +111,37 @@ texture = ExtResource("6_vp2ej")
script = ExtResource("3_1tarv")
[node name="tc2" type="Sprite2D" parent="."]
position = Vector2(2258, 1316)
position = Vector2(2273, 1084)
scale = Vector2(0.3, 0.3)
texture = ExtResource("6_vp2ej")
script = ExtResource("3_1tarv")
[node name="tc3" type="Sprite2D" parent="."]
position = Vector2(3445, 1440)
position = Vector2(3012, 1118)
scale = Vector2(0.3, 0.3)
texture = ExtResource("6_vp2ej")
script = ExtResource("3_1tarv")
[node name="bus1" type="Sprite2D" parent="."]
position = Vector2(991, 1389)
position = Vector2(966, 1066)
scale = Vector2(0.3, 0.3)
texture = ExtResource("7_5wmcj")
script = ExtResource("3_1tarv")
[node name="bus2" type="Sprite2D" parent="."]
position = Vector2(2266, 530)
position = Vector2(2266, 621)
scale = Vector2(0.3, 0.3)
texture = ExtResource("7_5wmcj")
script = ExtResource("3_1tarv")
[node name="bus3" type="Sprite2D" parent="."]
position = Vector2(3960, 656)
position = Vector2(3139, 268)
scale = Vector2(0.3, 0.3)
texture = ExtResource("7_5wmcj")
script = ExtResource("3_1tarv")
[node name="antenna" type="Sprite2D" parent="."]
position = Vector2(3953, 251)
position = Vector2(3031, -11)
scale = Vector2(0.3, 0.3)
texture = ExtResource("8_rmhxj")
script = ExtResource("9_diat7")
@ -147,7 +150,7 @@ script = ExtResource("9_diat7")
position = Vector2(640, 360)
scale = Vector2(0.3, 0.3)
texture = ExtResource("9_favs7")
script = ExtResource("15_c4337")
script = ExtResource("15_n6ui8")
[node name="wall1" type="Sprite2D" parent="."]
position = Vector2(357.5, 483.5)
@ -156,19 +159,37 @@ texture = SubResource("GradientTexture1D_4c28c")
script = ExtResource("15_jbm4l")
[node name="wall2" type="Sprite2D" parent="."]
position = Vector2(4288, 485.75)
position = Vector2(3618, 471)
scale = Vector2(0.332031, 2534.5)
texture = SubResource("GradientTexture1D_4c28c")
script = ExtResource("16_dnhp8")
[node name="wall3" type="Sprite2D" parent="."]
position = Vector2(2325.5, -725.5)
position = Vector2(2326, -282)
scale = Vector2(15.707, 111)
texture = SubResource("GradientTexture1D_4c28c")
script = ExtResource("17_jrw7x")
[node name="wall4" type="Sprite2D" parent="."]
position = Vector2(2325.5, 1692.5)
position = Vector2(2320, 1345)
scale = Vector2(15.707, 111)
texture = SubResource("GradientTexture1D_4c28c")
script = ExtResource("18_fasi1")
[node name="fps" type="Label" parent="."]
offset_right = 40.0
offset_bottom = 23.0
script = ExtResource("20_wbfof")
[node name="timelimit" type="Label" parent="."]
offset_left = 204.0
offset_right = 244.0
offset_bottom = 23.0
script = ExtResource("21_4jblw")
[node name="Home" type="TextureButton" parent="."]
offset_left = 52.0
offset_top = 39.0
offset_right = 125.0
offset_bottom = 110.0
script = ExtResource("21_c1w3x")

7
levels/timelimit.gd Normal file
View file

@ -0,0 +1,7 @@
extends Label
func _process(delta: float) -> void:
if (Global.timelimit - (Time.get_ticks_msec() - Global.wait)) > 0:
set_text("Time: " + str((Global.timelimit - (Time.get_ticks_msec() - Global.wait))/1000));
else:
set_text(str(0));

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=22 format=3 uid="uid://b82huqhu88xt6"]
[gd_scene load_steps=25 format=3 uid="uid://b82huqhu88xt6"]
[ext_resource type="Script" path="res://levels/wormhole.gd" id="1_n4a5i"]
[ext_resource type="Texture2D" uid="uid://8lioamk650y7" path="res://sprites/css.png" id="2_y6cio"]
@ -14,11 +14,14 @@
[ext_resource type="Script" path="res://levels/ast1.gd" id="12_s1o5o"]
[ext_resource type="Script" path="res://levels/ast2.gd" id="13_xw0he"]
[ext_resource type="Script" path="res://levels/ast3.gd" id="14_xcrsk"]
[ext_resource type="Script" path="res://levels/ss.gd" id="15_qucqy"]
[ext_resource type="Script" path="res://levels/ss.gd" id="15_hsg5e"]
[ext_resource type="Script" path="res://levels/wall1.gd" id="15_yx2oo"]
[ext_resource type="Script" path="res://levels/wall2.gd" id="16_el0w3"]
[ext_resource type="Script" path="res://levels/wall3.gd" id="17_pl58r"]
[ext_resource type="Script" path="res://levels/wall4.gd" id="18_ptooy"]
[ext_resource type="Script" path="res://fps.gd" id="20_li4sv"]
[ext_resource type="Script" path="res://backgounds/Home.gd" id="21_ipbod"]
[ext_resource type="Script" path="res://levels/timelimit.gd" id="21_tw1es"]
[sub_resource type="Gradient" id="Gradient_3wb6i"]
colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 1)
@ -78,7 +81,7 @@ texture = ExtResource("4_4mf4s")
script = ExtResource("3_4xg6i")
[node name="sat3" type="Sprite2D" parent="."]
position = Vector2(2717, 282)
position = Vector2(2436, 234)
scale = Vector2(0.3, 0.3)
texture = ExtResource("4_4mf4s")
script = ExtResource("3_4xg6i")
@ -96,7 +99,7 @@ texture = ExtResource("5_hhxgq")
script = ExtResource("3_4xg6i")
[node name="iss3" type="Sprite2D" parent="."]
position = Vector2(3412, -48)
position = Vector2(3027, -67)
scale = Vector2(0.5, 0.5)
texture = ExtResource("5_hhxgq")
script = ExtResource("3_4xg6i")
@ -114,13 +117,13 @@ texture = ExtResource("6_f0a2t")
script = ExtResource("3_4xg6i")
[node name="tc3" type="Sprite2D" parent="."]
position = Vector2(2121, 1646)
position = Vector2(2107, 1551)
scale = Vector2(0.3, 0.3)
texture = ExtResource("6_f0a2t")
script = ExtResource("3_4xg6i")
[node name="bus1" type="Sprite2D" parent="."]
position = Vector2(2879, 1253)
position = Vector2(2846, 1020)
scale = Vector2(0.3, 0.3)
texture = ExtResource("7_ymm87")
script = ExtResource("3_4xg6i")
@ -132,13 +135,13 @@ texture = ExtResource("7_ymm87")
script = ExtResource("3_4xg6i")
[node name="bus3" type="Sprite2D" parent="."]
position = Vector2(3977, 281)
position = Vector2(3035, 224)
scale = Vector2(0.3, 0.3)
texture = ExtResource("7_ymm87")
script = ExtResource("3_4xg6i")
[node name="antenna" type="Sprite2D" parent="."]
position = Vector2(3988, -111)
position = Vector2(2389, -107)
scale = Vector2(0.3, 0.3)
texture = ExtResource("8_7cq8u")
script = ExtResource("9_cr36o")
@ -147,7 +150,7 @@ script = ExtResource("9_cr36o")
position = Vector2(640, 360)
scale = Vector2(0.3, 0.3)
texture = ExtResource("10_shrek")
script = ExtResource("15_qucqy")
script = ExtResource("15_hsg5e")
[node name="wall1" type="Sprite2D" parent="."]
position = Vector2(338.5, 688.5)
@ -156,19 +159,37 @@ texture = SubResource("GradientTexture1D_8jpuy")
script = ExtResource("15_yx2oo")
[node name="wall2" type="Sprite2D" parent="."]
position = Vector2(4269, 690.75)
position = Vector2(3265, 719)
scale = Vector2(0.332031, 2534.5)
texture = SubResource("GradientTexture1D_8jpuy")
script = ExtResource("16_el0w3")
[node name="wall3" type="Sprite2D" parent="."]
position = Vector2(2306.5, -520.5)
position = Vector2(2292, -352)
scale = Vector2(15.707, 111)
texture = SubResource("GradientTexture1D_8jpuy")
script = ExtResource("17_pl58r")
[node name="wall4" type="Sprite2D" parent="."]
position = Vector2(2306.5, 1897.5)
position = Vector2(2302, 1769)
scale = Vector2(15.707, 111)
texture = SubResource("GradientTexture1D_8jpuy")
script = ExtResource("18_ptooy")
[node name="fps" type="Label" parent="."]
offset_right = 40.0
offset_bottom = 23.0
script = ExtResource("20_li4sv")
[node name="timelimit" type="Label" parent="."]
offset_left = 204.0
offset_right = 244.0
offset_bottom = 23.0
script = ExtResource("21_tw1es")
[node name="Home" type="TextureButton" parent="."]
offset_left = 52.0
offset_top = 39.0
offset_right = 125.0
offset_bottom = 110.0
script = ExtResource("21_ipbod")