Ground Y-sorting, nurse, title screen, settings functionality
This commit is contained in:
parent
31ae7ac906
commit
27e7ea5f65
13 changed files with 396 additions and 18 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
8
scenes/star.tscn
Normal file
8
scenes/star.tscn
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
[gd_scene load_steps=3 format=3 uid="uid://c12bwtw4jdp1e"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://5iimabvyld40" path="res://textures/particles/basic.png" id="1_mcqwg"]
|
||||||
|
[ext_resource type="Script" uid="uid://bswthfytadxup" path="res://scripts/star.gd" id="2_j6vao"]
|
||||||
|
|
||||||
|
[node name="Star" type="Sprite2D"]
|
||||||
|
texture = ExtResource("1_mcqwg")
|
||||||
|
script = ExtResource("2_j6vao")
|
||||||
|
|
@ -117,6 +117,7 @@ size_flags_vertical = 3
|
||||||
alignment = 1
|
alignment = 1
|
||||||
|
|
||||||
[node name="Title" type="VBoxContainer" parent="UI/Control"]
|
[node name="Title" type="VBoxContainer" parent="UI/Control"]
|
||||||
|
visible = false
|
||||||
layout_mode = 0
|
layout_mode = 0
|
||||||
offset_left = 480.0
|
offset_left = 480.0
|
||||||
offset_right = 1120.0
|
offset_right = 1120.0
|
||||||
|
|
@ -300,6 +301,93 @@ script = ExtResource("2_pyl7j")
|
||||||
action_name = "ui_accept"
|
action_name = "ui_accept"
|
||||||
metadata/_custom_type_script = "uid://b2maxk5g6yb0i"
|
metadata/_custom_type_script = "uid://b2maxk5g6yb0i"
|
||||||
|
|
||||||
|
[node name="OverrideSave" type="VBoxContainer" parent="UI/Control"]
|
||||||
|
visible = false
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 480.0
|
||||||
|
offset_right = 1120.0
|
||||||
|
offset_bottom = 900.0
|
||||||
|
size_flags_vertical = 3
|
||||||
|
alignment = 1
|
||||||
|
|
||||||
|
[node name="Label" type="RichTextLabel" parent="UI/Control/OverrideSave"]
|
||||||
|
custom_minimum_size = Vector2(640, 0)
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 4
|
||||||
|
size_flags_vertical = 4
|
||||||
|
theme_override_fonts/normal_font = ExtResource("1_wosw1")
|
||||||
|
theme_override_fonts/bold_font = ExtResource("3_b3w7a")
|
||||||
|
theme_override_font_sizes/normal_font_size = 32
|
||||||
|
theme_override_font_sizes/bold_font_size = 32
|
||||||
|
theme_override_font_sizes/bold_italics_font_size = 32
|
||||||
|
theme_override_font_sizes/italics_font_size = 32
|
||||||
|
theme_override_font_sizes/mono_font_size = 32
|
||||||
|
bbcode_enabled = true
|
||||||
|
text = "[b][font size=64]OVERRIDE SAVE?[/font][/b]"
|
||||||
|
fit_content = true
|
||||||
|
horizontal_alignment = 1
|
||||||
|
vertical_alignment = 1
|
||||||
|
|
||||||
|
[node name="Label3" type="RichTextLabel" parent="UI/Control/OverrideSave"]
|
||||||
|
custom_minimum_size = Vector2(640, 0)
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 4
|
||||||
|
size_flags_vertical = 4
|
||||||
|
theme_override_fonts/normal_font = ExtResource("1_wosw1")
|
||||||
|
theme_override_fonts/bold_font = ExtResource("3_b3w7a")
|
||||||
|
theme_override_font_sizes/normal_font_size = 32
|
||||||
|
theme_override_font_sizes/bold_font_size = 32
|
||||||
|
theme_override_font_sizes/bold_italics_font_size = 32
|
||||||
|
theme_override_font_sizes/italics_font_size = 32
|
||||||
|
theme_override_font_sizes/mono_font_size = 32
|
||||||
|
bbcode_enabled = true
|
||||||
|
text = "[font size=20]there is currently a save in storage. creating a new save will delete your old one.[/font]"
|
||||||
|
fit_content = true
|
||||||
|
horizontal_alignment = 1
|
||||||
|
vertical_alignment = 1
|
||||||
|
|
||||||
|
[node name="Buttons" type="HFlowContainer" parent="UI/Control/OverrideSave"]
|
||||||
|
layout_mode = 2
|
||||||
|
alignment = 1
|
||||||
|
|
||||||
|
[node name="YesOverride" type="Button" parent="UI/Control/OverrideSave/Buttons"]
|
||||||
|
custom_minimum_size = Vector2(128, 0)
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 4
|
||||||
|
size_flags_vertical = 4
|
||||||
|
text = "yes"
|
||||||
|
|
||||||
|
[node name="NoOverride" type="Button" parent="UI/Control/OverrideSave/Buttons"]
|
||||||
|
custom_minimum_size = Vector2(128, 0)
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 4
|
||||||
|
size_flags_vertical = 4
|
||||||
|
text = "no"
|
||||||
|
|
||||||
|
[node name="InputIconTextureRect2" type="TextureRect" parent="UI/Control/OverrideSave/Buttons"]
|
||||||
|
custom_minimum_size = Vector2(48, 48)
|
||||||
|
layout_mode = 2
|
||||||
|
expand_mode = 1
|
||||||
|
script = ExtResource("2_pyl7j")
|
||||||
|
action_name = "ui_left"
|
||||||
|
metadata/_custom_type_script = "uid://b2maxk5g6yb0i"
|
||||||
|
|
||||||
|
[node name="InputIconTextureRect3" type="TextureRect" parent="UI/Control/OverrideSave/Buttons"]
|
||||||
|
custom_minimum_size = Vector2(48, 48)
|
||||||
|
layout_mode = 2
|
||||||
|
expand_mode = 1
|
||||||
|
script = ExtResource("2_pyl7j")
|
||||||
|
action_name = "ui_right"
|
||||||
|
metadata/_custom_type_script = "uid://b2maxk5g6yb0i"
|
||||||
|
|
||||||
|
[node name="InputIconTextureRect4" type="TextureRect" parent="UI/Control/OverrideSave/Buttons"]
|
||||||
|
custom_minimum_size = Vector2(48, 48)
|
||||||
|
layout_mode = 2
|
||||||
|
expand_mode = 1
|
||||||
|
script = ExtResource("2_pyl7j")
|
||||||
|
action_name = "ui_accept"
|
||||||
|
metadata/_custom_type_script = "uid://b2maxk5g6yb0i"
|
||||||
|
|
||||||
[node name="Settings" parent="UI/Control" instance=ExtResource("6_yql1r")]
|
[node name="Settings" parent="UI/Control" instance=ExtResource("6_yql1r")]
|
||||||
visible = false
|
visible = false
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
|
|
@ -328,6 +416,7 @@ mouse_filter = 2
|
||||||
color = Color(1, 1, 1, 0)
|
color = Color(1, 1, 1, 0)
|
||||||
|
|
||||||
[connection signal="pressed" from="UI/Control/ControllerInfo/Box/Flow/Continue" to="." method="_on_continue_pressed"]
|
[connection signal="pressed" from="UI/Control/ControllerInfo/Box/Flow/Continue" to="." method="_on_continue_pressed"]
|
||||||
|
[connection signal="pressed" from="UI/Control/Title/Buttons/NewGame" to="." method="_on_new_game_pressed"]
|
||||||
[connection signal="pressed" from="UI/Control/Title/Buttons/Settings" to="." method="_on_settings_pressed"]
|
[connection signal="pressed" from="UI/Control/Title/Buttons/Settings" to="." method="_on_settings_pressed"]
|
||||||
[connection signal="pressed" from="UI/Control/Title/Buttons/Credits" to="." method="_on_credits_pressed"]
|
[connection signal="pressed" from="UI/Control/Title/Buttons/Credits" to="." method="_on_credits_pressed"]
|
||||||
[connection signal="pressed" from="UI/Control/Title/Buttons/Quit" to="." method="_on_quit_pressed"]
|
[connection signal="pressed" from="UI/Control/Title/Buttons/Quit" to="." method="_on_quit_pressed"]
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
extends Sprite2D
|
extends Sprite2D
|
||||||
|
|
||||||
@onready var game = get_parent()
|
@onready var game = get_owner()
|
||||||
|
|
||||||
func _on_enter_hitbox_body_entered(body: Node2D) -> void:
|
func _on_enter_hitbox_body_entered(body: Node2D) -> void:
|
||||||
if body.get_name() == "Player":
|
if body.get_name() == "Player":
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,11 @@ var current_atmospheric_track = null
|
||||||
|
|
||||||
var asteroid_scene = preload("res://scenes/asteroid.tscn")
|
var asteroid_scene = preload("res://scenes/asteroid.tscn")
|
||||||
var enemy_scene = preload("res://scenes/enemy.tscn")
|
var enemy_scene = preload("res://scenes/enemy.tscn")
|
||||||
|
var star_scene = preload("res://scenes/star.tscn")
|
||||||
|
|
||||||
|
@onready var spawn_points = {
|
||||||
|
"SpaceStation1": $Orbits/SpaceStation1/SpaceStation1/ExitPoint
|
||||||
|
}
|
||||||
|
|
||||||
func ship_health(health: float = 1000) -> void:
|
func ship_health(health: float = 1000) -> void:
|
||||||
$Player.health = health
|
$Player.health = health
|
||||||
|
|
@ -45,7 +50,7 @@ func enter_physical(map):
|
||||||
|
|
||||||
get_tree().paused = false
|
get_tree().paused = false
|
||||||
|
|
||||||
global.ground_location = map
|
global.stats.location = map
|
||||||
|
|
||||||
get_tree().change_scene_to_file("res://scenes/ground.tscn")
|
get_tree().change_scene_to_file("res://scenes/ground.tscn")
|
||||||
|
|
||||||
|
|
@ -56,9 +61,18 @@ func _ready() -> void:
|
||||||
|
|
||||||
var events = InputMap.action_get_events("forward")
|
var events = InputMap.action_get_events("forward")
|
||||||
|
|
||||||
if global.ground_location:
|
if (global.stats.location != "space") and (spawn_points.has(global.stats.location)):
|
||||||
$Player.global_position = get_node(global.ground_location + "/ExitPoint").global_position
|
$Player.global_position = spawn_points[global.stats.location].global_position
|
||||||
$Player.rotation = get_node(global.ground_location + "/ExitPoint").rotation
|
$Player.rotation = spawn_points[global.stats.location].rotation
|
||||||
|
|
||||||
|
var i = 0
|
||||||
|
while i < 512:
|
||||||
|
var star = star_scene.instantiate()
|
||||||
|
star.position = Vector2(-99999999999999999, -9999999999999999999)
|
||||||
|
|
||||||
|
$Stars.add_child(star)
|
||||||
|
|
||||||
|
i += 1
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
if get_tree().paused:
|
if get_tree().paused:
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
load_settings()
|
||||||
|
|
||||||
var ground_location = null
|
var ground_location = null
|
||||||
|
|
||||||
var orbit_zones = [
|
var orbit_zones = [
|
||||||
|
|
@ -23,12 +26,74 @@ var orbit_zones = [
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
func generate_save():
|
||||||
|
var save_dict = {
|
||||||
|
"stats": stats
|
||||||
|
}
|
||||||
|
return save_dict
|
||||||
|
|
||||||
|
## Saves the game in its current state.
|
||||||
|
func save_game():
|
||||||
|
var save_file = FileAccess.open("user://savegame.save", FileAccess.WRITE)
|
||||||
|
|
||||||
|
var json_string = JSON.stringify(generate_save())
|
||||||
|
|
||||||
|
save_file.store_line(json_string)
|
||||||
|
|
||||||
|
func save_settings():
|
||||||
|
var save_file = FileAccess.open("user://settings.json", FileAccess.WRITE)
|
||||||
|
|
||||||
|
var json_string = JSON.stringify(settings)
|
||||||
|
|
||||||
|
save_file.store_line(json_string)
|
||||||
|
|
||||||
|
## Loads the game data from the savegame.save file.
|
||||||
|
func load_game():
|
||||||
|
if not FileAccess.file_exists("user://savegame.save"):
|
||||||
|
return
|
||||||
|
|
||||||
|
var save_file = FileAccess.open("user://savegame.save", FileAccess.READ)
|
||||||
|
|
||||||
|
var json = JSON.new()
|
||||||
|
|
||||||
|
var parse_result = json.parse(save_file.get_as_text())
|
||||||
|
|
||||||
|
if not parse_result == OK:
|
||||||
|
print("JSON Parse Error: ", json.get_error_message(), " in ", parse_result, " at line ", json.get_error_line())
|
||||||
|
return
|
||||||
|
|
||||||
|
if json.data.settings: settings = json.data.settings
|
||||||
|
if json.data.stats: settings = json.data.stats
|
||||||
|
|
||||||
|
func load_settings():
|
||||||
|
if not FileAccess.file_exists("user://settings.json"):
|
||||||
|
return
|
||||||
|
|
||||||
|
var save_file = FileAccess.open("user://settings.json", FileAccess.READ)
|
||||||
|
|
||||||
|
var json = JSON.new()
|
||||||
|
|
||||||
|
var parse_result = json.parse(save_file.get_as_text())
|
||||||
|
|
||||||
|
if not parse_result == OK:
|
||||||
|
print("JSON Parse Error: ", json.get_error_message(), " in ", parse_result, " at line ", json.get_error_line())
|
||||||
|
return
|
||||||
|
|
||||||
|
settings = json.data
|
||||||
|
|
||||||
|
func delete_game():
|
||||||
|
await DirAccess.remove_absolute("user://savegame.save")
|
||||||
|
|
||||||
var stats = {
|
var stats = {
|
||||||
|
"loaded": false,
|
||||||
"fuel": 12,
|
"fuel": 12,
|
||||||
"fuel_tank_size": 1,
|
"fuel_tank_size": 1,
|
||||||
"speed": 512,
|
"speed": 512,
|
||||||
"boost_tank_size": 1,
|
"boost_tank_size": 1,
|
||||||
"marks": 200,
|
"marks": 200,
|
||||||
|
"location": "space",
|
||||||
|
"ship_position": Vector2(),
|
||||||
|
"ship_rotation": 0
|
||||||
}
|
}
|
||||||
|
|
||||||
var settings = {
|
var settings = {
|
||||||
|
|
|
||||||
|
|
@ -24,4 +24,5 @@ func _on_sfx_volume_value_changed(value: float) -> void:
|
||||||
|
|
||||||
|
|
||||||
func _on_back_pressed() -> void:
|
func _on_back_pressed() -> void:
|
||||||
|
global.save_settings()
|
||||||
get_owner()._on_settings_back_pressed()
|
get_owner()._on_settings_back_pressed()
|
||||||
|
|
|
||||||
36
scripts/star.gd
Normal file
36
scripts/star.gd
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
extends Sprite2D
|
||||||
|
|
||||||
|
@onready var player = get_parent().get_parent().get_node("Player")
|
||||||
|
|
||||||
|
func random_respawn(distance_min = 2000):
|
||||||
|
var random_rotation = randf_range(-7, 7)
|
||||||
|
var random_distance = randi_range(distance_min, 2000)
|
||||||
|
var random_size = randf_range(0.02, 0.5)
|
||||||
|
|
||||||
|
global_position = player.global_position + (Vector2.UP.rotated(random_rotation) * random_distance)
|
||||||
|
global_position += (Vector2.RIGHT * randi_range(-random_distance, random_distance)).rotated(random_rotation)
|
||||||
|
|
||||||
|
rotation = random_rotation
|
||||||
|
|
||||||
|
scale.x = random_size
|
||||||
|
scale.y = scale.x
|
||||||
|
|
||||||
|
var color = randi_range(1, 20)
|
||||||
|
|
||||||
|
if color <= 1:
|
||||||
|
modulate = Color(1.0, 0.0, 0.0, 1.0)
|
||||||
|
elif color <= 2:
|
||||||
|
modulate = Color(0.177, 0.242, 1.0, 1.0)
|
||||||
|
elif color <= 3:
|
||||||
|
modulate = Color(1.0, 1.0, 0.0, 1.0)
|
||||||
|
else:
|
||||||
|
modulate = Color(1, 1, 1)
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
random_respawn(0)
|
||||||
|
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
var distance = abs((player.global_position - global_position).length())
|
||||||
|
|
||||||
|
if distance > 2100:
|
||||||
|
random_respawn()
|
||||||
1
scripts/star.gd.uid
Normal file
1
scripts/star.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://bswthfytadxup
|
||||||
|
|
@ -194,3 +194,44 @@ func _on_settings_back_pressed() -> void:
|
||||||
|
|
||||||
transitioning = false
|
transitioning = false
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func _on_new_game_pressed() -> void:
|
||||||
|
if transitioning: return
|
||||||
|
|
||||||
|
transitioning = true
|
||||||
|
|
||||||
|
get_viewport().gui_release_focus()
|
||||||
|
var i = 0
|
||||||
|
|
||||||
|
while i < 6:
|
||||||
|
$UI/Control/Title.modulate.a -= 0.2
|
||||||
|
|
||||||
|
await get_tree().create_timer(0.2).timeout
|
||||||
|
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
$UI/Control/Title.visible = false
|
||||||
|
|
||||||
|
if global.stats.loaded:
|
||||||
|
$UI/Control/OverrideSave.visible = true
|
||||||
|
|
||||||
|
$UI/Control/OverrideSave.modulate.a = 0
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
|
||||||
|
while i < 6:
|
||||||
|
$UI/Control/OverrideSave.modulate.a += 0.2
|
||||||
|
|
||||||
|
await get_tree().create_timer(0.2).timeout
|
||||||
|
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
$UI/Control/OverrideSave/Buttons/NoOverride.grab_focus()
|
||||||
|
|
||||||
|
if global.stats.location == "space":
|
||||||
|
get_tree().change_scene_to_file("res://scenes/game.tscn")
|
||||||
|
else:
|
||||||
|
get_tree().change_scene_to_file("res://scenes/ground.tscn")
|
||||||
|
|
||||||
|
transitioning = false
|
||||||
|
|
|
||||||
BIN
textures/nurse-ground-sheet.png
Normal file
BIN
textures/nurse-ground-sheet.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 808 B |
40
textures/nurse-ground-sheet.png.import
Normal file
40
textures/nurse-ground-sheet.png.import
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://de0xeo6j2h1au"
|
||||||
|
path="res://.godot/imported/nurse-ground-sheet.png-2e8bea4c6b0a93bf710f93b3aa3590aa.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://textures/nurse-ground-sheet.png"
|
||||||
|
dest_files=["res://.godot/imported/nurse-ground-sheet.png-2e8bea4c6b0a93bf710f93b3aa3590aa.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
Loading…
Reference in a new issue