split gravity logic, various bug fixes
fixed gravity strength being possibly strong at level beginning fixed restarting being allowed after getting the last ring fixed save file's "played_for" being reset or set to another file's fixed the displayed save file total play time not being updated on main menu maybe there's other stuff
This commit is contained in:
parent
38897c706a
commit
709ce8eea3
11 changed files with 131 additions and 106 deletions
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=8 format=3 uid="uid://dw0xl8644x166"]
|
[gd_scene load_steps=7 format=3 uid="uid://dw0xl8644x166"]
|
||||||
|
|
||||||
[ext_resource type="Texture2D" uid="uid://ctjugvy1v3y6b" path="res://graphics/arrow.svg" id="1_4mbho"]
|
[ext_resource type="Texture2D" uid="uid://ctjugvy1v3y6b" path="res://graphics/arrow.svg" id="1_4mbho"]
|
||||||
[ext_resource type="AudioStream" uid="uid://dmdbharecy448" path="res://sounds/gravity.ogg" id="2_5uwlw"]
|
[ext_resource type="AudioStream" uid="uid://dmdbharecy448" path="res://sounds/gravity.ogg" id="2_5uwlw"]
|
||||||
|
@ -6,66 +6,35 @@
|
||||||
[sub_resource type="GDScript" id="GDScript_3yq1l"]
|
[sub_resource type="GDScript" id="GDScript_3yq1l"]
|
||||||
script/source = "extends Control
|
script/source = "extends Control
|
||||||
|
|
||||||
var player_ready = false
|
@onready var direction_node: TextureRect = $Direction
|
||||||
const normal = 7
|
@onready var animation: AnimationPlayer = $Direction/AnimationPlayer
|
||||||
const stronger = normal * 3
|
@onready var audio: AudioStreamPlayer = $Direction/AudioStreamPlayer
|
||||||
|
|
||||||
func _input(_event: InputEvent) -> void:
|
|
||||||
if player_ready:
|
|
||||||
var grav = stronger if Input.is_action_pressed(\"gravity_strong\") else normal
|
|
||||||
PhysicsServer3D.area_set_param(get_viewport().find_world_3d().space, PhysicsServer3D.AREA_PARAM_GRAVITY, grav)
|
|
||||||
"
|
|
||||||
|
|
||||||
[sub_resource type="GDScript" id="GDScript_my602"]
|
|
||||||
script/source = "extends TextureRect
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
# set the indicator to be fully transparent when it first spawns
|
# set the indicator to be fully transparent when it first spawns
|
||||||
self.self_modulate = Color(1, 1, 1, 0)
|
direction_node.self_modulate = Color(1, 1, 1, 0)
|
||||||
|
|
||||||
func _input(ev: InputEvent) -> void:
|
func react_to_gravity_change(direction: Vector3) -> void:
|
||||||
if ev is InputEventKey and ev.is_pressed():
|
if direction == Vector3.UP:
|
||||||
var up := Input.is_action_just_pressed(\"gravity_up\")
|
direction_node.rotation_degrees = -90
|
||||||
var left := Input.is_action_just_pressed(\"gravity_left\")
|
audio.pitch_scale = 1.05
|
||||||
var right := Input.is_action_just_pressed(\"gravity_right\")
|
elif direction == Vector3.LEFT:
|
||||||
var down := Input.is_action_just_pressed(\"gravity_down\")
|
direction_node.rotation_degrees = -180
|
||||||
|
audio.pitch_scale = 1.02
|
||||||
|
elif direction == Vector3.RIGHT:
|
||||||
|
direction = Vector3.RIGHT
|
||||||
|
direction_node.rotation_degrees = 0
|
||||||
|
audio.pitch_scale = 0.98
|
||||||
|
elif direction == Vector3.DOWN:
|
||||||
|
direction_node.rotation_degrees = 90
|
||||||
|
audio.pitch_scale = 0.95
|
||||||
|
|
||||||
if up or left or right or down:
|
if animation.is_playing():
|
||||||
var direction = Vector3()
|
animation.stop()
|
||||||
if up:
|
animation.play(\"grow_fadeout\")
|
||||||
direction = Vector3.UP
|
|
||||||
self.rotation_degrees = -90
|
|
||||||
$AudioStreamPlayer.pitch_scale = 1.05
|
|
||||||
elif left:
|
|
||||||
direction = Vector3.LEFT
|
|
||||||
self.rotation_degrees = -180
|
|
||||||
$AudioStreamPlayer.pitch_scale = 1.02
|
|
||||||
elif right:
|
|
||||||
direction = Vector3.RIGHT
|
|
||||||
self.rotation_degrees = 0
|
|
||||||
$AudioStreamPlayer.pitch_scale = 0.98
|
|
||||||
elif down:
|
|
||||||
direction = Vector3.DOWN
|
|
||||||
self.rotation_degrees = 90
|
|
||||||
$AudioStreamPlayer.pitch_scale = 0.95
|
|
||||||
|
|
||||||
if get_parent().player_ready == false or direction != PhysicsServer3D.area_get_param(
|
if Settings.sound_on_gravity_change:
|
||||||
get_viewport().find_world_3d().space,
|
audio.play()
|
||||||
PhysicsServer3D.AREA_PARAM_GRAVITY_VECTOR
|
|
||||||
):
|
|
||||||
get_parent().player_ready = true
|
|
||||||
PhysicsServer3D.area_set_param(
|
|
||||||
get_viewport().find_world_3d().space,
|
|
||||||
PhysicsServer3D.AREA_PARAM_GRAVITY_VECTOR,
|
|
||||||
direction
|
|
||||||
)
|
|
||||||
|
|
||||||
if $AnimationPlayer.is_playing():
|
|
||||||
$AnimationPlayer.stop()
|
|
||||||
$AnimationPlayer.play(\"grow_fadeout\")
|
|
||||||
|
|
||||||
if Settings.sound_on_gravity_change:
|
|
||||||
$AudioStreamPlayer.play()
|
|
||||||
"
|
"
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_6rwl4"]
|
[sub_resource type="Animation" id="Animation_6rwl4"]
|
||||||
|
@ -158,7 +127,6 @@ scale = Vector2(0.3, 0.3)
|
||||||
pivot_offset = Vector2(400, 400)
|
pivot_offset = Vector2(400, 400)
|
||||||
mouse_filter = 2
|
mouse_filter = 2
|
||||||
texture = ExtResource("1_4mbho")
|
texture = ExtResource("1_4mbho")
|
||||||
script = SubResource("GDScript_my602")
|
|
||||||
|
|
||||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="Direction"]
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="Direction"]
|
||||||
libraries = {
|
libraries = {
|
|
@ -31,11 +31,6 @@ var seconds_spent_level_attempt := 0.0:
|
||||||
seconds_spent_level_attempt = value
|
seconds_spent_level_attempt = value
|
||||||
$Level.text = \"Level: \" + seconds_to_readable(seconds_spent_level_attempt)
|
$Level.text = \"Level: \" + seconds_to_readable(seconds_spent_level_attempt)
|
||||||
|
|
||||||
func _ready():
|
|
||||||
var data = SaveFiles.read(SaveFiles.selected_file)
|
|
||||||
if data.has(\"played_for\") and data.played_for is float:
|
|
||||||
seconds_spent_total = data.played_for
|
|
||||||
|
|
||||||
func seconds_to_readable(seconds: float) -> String:
|
func seconds_to_readable(seconds: float) -> String:
|
||||||
var minutes: int = floor(seconds / 60)
|
var minutes: int = floor(seconds / 60)
|
||||||
return (\"%0*d\" % [2, minutes]) + \":\" + (\"%0*.3f\" % [6, seconds - (minutes * 60)])
|
return (\"%0*d\" % [2, minutes]) + \":\" + (\"%0*.3f\" % [6, seconds - (minutes * 60)])
|
||||||
|
|
24
index.tscn
24
index.tscn
|
@ -1,6 +1,7 @@
|
||||||
[gd_scene load_steps=7 format=3 uid="uid://ccgnnif026wb4"]
|
[gd_scene load_steps=8 format=3 uid="uid://ccgnnif026wb4"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://xd3nsiglcdfc" path="res://gui/timer.tscn" id="1_356j3"]
|
[ext_resource type="PackedScene" uid="uid://xd3nsiglcdfc" path="res://gui/timer.tscn" id="1_356j3"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://dw0xl8644x166" path="res://gui/gravity.tscn" id="1_ir7so"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cckeamgkt8bqo" path="res://gui/speed.tscn" id="2_2gn6w"]
|
[ext_resource type="PackedScene" uid="uid://cckeamgkt8bqo" path="res://gui/speed.tscn" id="2_2gn6w"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cn55m5dqo3m6u" path="res://gui/rings.tscn" id="3_mbj17"]
|
[ext_resource type="PackedScene" uid="uid://cn55m5dqo3m6u" path="res://gui/rings.tscn" id="3_mbj17"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dkxtwpcy4moyo" path="res://menus/pause_menu.tscn" id="4_3bfj3"]
|
[ext_resource type="PackedScene" uid="uid://dkxtwpcy4moyo" path="res://menus/pause_menu.tscn" id="4_3bfj3"]
|
||||||
|
@ -8,8 +9,8 @@
|
||||||
[sub_resource type="GDScript" id="GDScript_8n212"]
|
[sub_resource type="GDScript" id="GDScript_8n212"]
|
||||||
script/source = "extends Node
|
script/source = "extends Node
|
||||||
|
|
||||||
var playing: bool = false
|
var playing := false
|
||||||
var changing_level: bool = false
|
var changing_level := false
|
||||||
|
|
||||||
var main_menu: Node
|
var main_menu: Node
|
||||||
var current_level: Level
|
var current_level: Level
|
||||||
|
@ -17,6 +18,7 @@ var current_level_scene: PackedScene
|
||||||
|
|
||||||
const res_main_menu = preload(\"res://menus/main/main_menu.tscn\")
|
const res_main_menu = preload(\"res://menus/main/main_menu.tscn\")
|
||||||
|
|
||||||
|
@onready var gui_gravity := $GUI/Gravity
|
||||||
@onready var gui_timer := $GUI/TopLeft/Timer
|
@onready var gui_timer := $GUI/TopLeft/Timer
|
||||||
@onready var gui_speed := $GUI/TopRight/Speed
|
@onready var gui_speed := $GUI/TopRight/Speed
|
||||||
@onready var gui_rings := $GUI/BottomRight/Rings
|
@onready var gui_rings := $GUI/BottomRight/Rings
|
||||||
|
@ -57,6 +59,7 @@ func start_level(level: Level, scene: PackedScene) -> void:
|
||||||
current_level_scene = scene
|
current_level_scene = scene
|
||||||
add_child(current_level)
|
add_child(current_level)
|
||||||
|
|
||||||
|
current_level.connect(\"gravity_change\", gui_gravity.react_to_gravity_change)
|
||||||
current_level.connect(\"completed\", finish_current_level)
|
current_level.connect(\"completed\", finish_current_level)
|
||||||
current_level.connect(\"ring_collected\", func():
|
current_level.connect(\"ring_collected\", func():
|
||||||
gui_rings.remaining_rings = len(current_level.rings) - current_level.finished_rings_count
|
gui_rings.remaining_rings = len(current_level.rings) - current_level.finished_rings_count
|
||||||
|
@ -68,18 +71,13 @@ func start_level(level: Level, scene: PackedScene) -> void:
|
||||||
pause_game(false)
|
pause_game(false)
|
||||||
|
|
||||||
playing = true
|
playing = true
|
||||||
PhysicsServer3D.area_set_param(
|
|
||||||
get_viewport().find_world_3d().space,
|
|
||||||
PhysicsServer3D.AREA_PARAM_GRAVITY_VECTOR,
|
|
||||||
Vector3.DOWN
|
|
||||||
)
|
|
||||||
changing_level = false
|
changing_level = false
|
||||||
gui_timer.seconds_spent_level_attempt = 0.0
|
gui_timer.seconds_spent_level_attempt = 0.0
|
||||||
gui_timer.enabled = true
|
gui_timer.enabled = true
|
||||||
|
|
||||||
func finish_current_level() -> void:
|
func finish_current_level() -> void:
|
||||||
gui_timer.enabled = false
|
gui_timer.enabled = false
|
||||||
PhysicsServer3D.area_set_param(get_viewport().find_world_3d().space, PhysicsServer3D.AREA_PARAM_GRAVITY, 1)
|
PhysicsServer3D.area_set_param(get_viewport().find_world_3d().space, PhysicsServer3D.AREA_PARAM_GRAVITY, 0.5)
|
||||||
playing = false
|
playing = false
|
||||||
changing_level = true
|
changing_level = true
|
||||||
|
|
||||||
|
@ -102,19 +100,20 @@ func win_game() -> void:
|
||||||
$VictoryScreen.hide()
|
$VictoryScreen.hide()
|
||||||
|
|
||||||
func restart_level() -> void:
|
func restart_level() -> void:
|
||||||
if !current_level:
|
if !current_level or changing_level:
|
||||||
return
|
return
|
||||||
if current_level_scene is not PackedScene:
|
if current_level_scene is not PackedScene:
|
||||||
print(\"Tried to restart the level despite not having the level scene\")
|
print(\"Tried to restart the level despite not having the level scene\")
|
||||||
return
|
return
|
||||||
|
SaveFiles.change_property(\"played_for\", gui_timer.seconds_spent_total, SaveFiles.selected_file)
|
||||||
start_level(current_level_scene.instantiate(), current_level_scene)
|
start_level(current_level_scene.instantiate(), current_level_scene)
|
||||||
|
|
||||||
func pause_game(to_pause: bool) -> void:
|
func pause_game(to_pause: bool) -> void:
|
||||||
if !is_instance_valid(current_level) or changing_level:
|
if !is_instance_valid(current_level) or changing_level:
|
||||||
return
|
return
|
||||||
|
|
||||||
SaveFiles.change_property(\"played_for\", gui_timer.seconds_spent_total, SaveFiles.selected_file)
|
|
||||||
if to_pause:
|
if to_pause:
|
||||||
|
SaveFiles.change_property(\"played_for\", gui_timer.seconds_spent_total, SaveFiles.selected_file)
|
||||||
current_level.process_mode = Node.PROCESS_MODE_DISABLED
|
current_level.process_mode = Node.PROCESS_MODE_DISABLED
|
||||||
playing = false
|
playing = false
|
||||||
pause_menu.show()
|
pause_menu.show()
|
||||||
|
@ -161,6 +160,9 @@ grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
mouse_filter = 2
|
mouse_filter = 2
|
||||||
|
|
||||||
|
[node name="Gravity" parent="GUI" instance=ExtResource("1_ir7so")]
|
||||||
|
layout_mode = 1
|
||||||
|
|
||||||
[node name="TopLeft" type="MarginContainer" parent="GUI"]
|
[node name="TopLeft" type="MarginContainer" parent="GUI"]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
offset_right = 160.0
|
offset_right = 160.0
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
[gd_scene load_steps=12 format=3 uid="uid://ovtknjyj83gh"]
|
[gd_scene load_steps=11 format=3 uid="uid://ovtknjyj83gh"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://cnnvwotv33u1b" path="res://elements/player.tscn" id="2_b00jj"]
|
[ext_resource type="PackedScene" uid="uid://cnnvwotv33u1b" path="res://elements/player.tscn" id="2_b00jj"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cpm3laywhlbq5" path="res://elements/ring.tscn" id="3_hel5x"]
|
[ext_resource type="PackedScene" uid="uid://cpm3laywhlbq5" path="res://elements/ring.tscn" id="3_hel5x"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dw0xl8644x166" path="res://elements/gravity.tscn" id="3_muudg"]
|
|
||||||
[ext_resource type="PackedScene" uid="uid://c77bli40240nk" path="res://elements/sign.tscn" id="4_atq6y"]
|
[ext_resource type="PackedScene" uid="uid://c77bli40240nk" path="res://elements/sign.tscn" id="4_atq6y"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dnuakh7n3fuij" path="res://levels/base/music.tscn" id="4_uq42r"]
|
[ext_resource type="PackedScene" uid="uid://dnuakh7n3fuij" path="res://levels/base/music.tscn" id="4_uq42r"]
|
||||||
|
|
||||||
|
@ -43,8 +42,6 @@ reflected_light_source = 2
|
||||||
script = SubResource("GDScript_1yugx")
|
script = SubResource("GDScript_1yugx")
|
||||||
metadata/_custom_type_script = "uid://w3fetao1pegm"
|
metadata/_custom_type_script = "uid://w3fetao1pegm"
|
||||||
|
|
||||||
[node name="Gravity" parent="." instance=ExtResource("3_muudg")]
|
|
||||||
|
|
||||||
[node name="Environment" type="WorldEnvironment" parent="."]
|
[node name="Environment" type="WorldEnvironment" parent="."]
|
||||||
environment = SubResource("Environment_y0yoy")
|
environment = SubResource("Environment_y0yoy")
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
[gd_scene load_steps=11 format=3 uid="uid://e1761h6d522a"]
|
[gd_scene load_steps=10 format=3 uid="uid://e1761h6d522a"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://dw0xl8644x166" path="res://elements/gravity.tscn" id="2_gxmta"]
|
|
||||||
[ext_resource type="PackedScene" uid="uid://cnnvwotv33u1b" path="res://elements/player.tscn" id="2_mjogx"]
|
[ext_resource type="PackedScene" uid="uid://cnnvwotv33u1b" path="res://elements/player.tscn" id="2_mjogx"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cakmsiye3hjfe" path="res://levels/forest/music.tscn" id="3_n1xsx"]
|
[ext_resource type="PackedScene" uid="uid://cakmsiye3hjfe" path="res://levels/forest/music.tscn" id="3_n1xsx"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cpm3laywhlbq5" path="res://elements/ring.tscn" id="4_p8yhq"]
|
[ext_resource type="PackedScene" uid="uid://cpm3laywhlbq5" path="res://elements/ring.tscn" id="4_p8yhq"]
|
||||||
|
@ -52,8 +51,6 @@ reflected_light_source = 2
|
||||||
script = SubResource("GDScript_mqwxc")
|
script = SubResource("GDScript_mqwxc")
|
||||||
metadata/_custom_type_script = "uid://w3fetao1pegm"
|
metadata/_custom_type_script = "uid://w3fetao1pegm"
|
||||||
|
|
||||||
[node name="Gravity" parent="." instance=ExtResource("2_gxmta")]
|
|
||||||
|
|
||||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
||||||
transform = Transform3D(-0.920505, 0.195366, -0.338383, 0, 0.866025, 0.5, 0.390731, 0.460252, -0.797181, 0, 0, 0)
|
transform = Transform3D(-0.920505, 0.195366, -0.338383, 0, 0.866025, 0.5, 0.390731, 0.460252, -0.797181, 0, 0, 0)
|
||||||
shadow_enabled = true
|
shadow_enabled = true
|
||||||
|
|
|
@ -1,14 +1,20 @@
|
||||||
class_name Level
|
class_name Level
|
||||||
extends Node3D
|
extends Node3D
|
||||||
|
|
||||||
|
signal started_playing
|
||||||
|
signal gravity_change
|
||||||
signal ring_collected
|
signal ring_collected
|
||||||
signal completed
|
signal completed
|
||||||
|
|
||||||
|
const gravity_strength_normal = 7
|
||||||
|
const gravity_strength_strong = gravity_strength_normal * 3
|
||||||
|
|
||||||
## Lowercase, spaceless name of the level
|
## Lowercase, spaceless name of the level
|
||||||
var id: String
|
var id: String
|
||||||
var thumbnail: CompressedTexture2D
|
var thumbnail: CompressedTexture2D
|
||||||
var music: Music
|
var music: Music
|
||||||
var rings: Array[Ring] = []
|
var rings: Array[Ring] = []
|
||||||
|
|
||||||
var finished_rings_count: int = 0
|
var finished_rings_count: int = 0
|
||||||
var velocity: float = 0.0
|
var velocity: float = 0.0
|
||||||
|
|
||||||
|
@ -16,6 +22,18 @@ func _init() -> void:
|
||||||
assert(len(id) > 0, self.name + " has no id!")
|
assert(len(id) > 0, self.name + " has no id!")
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
PhysicsServer3D.area_set_param(
|
||||||
|
get_viewport().find_world_3d().space,
|
||||||
|
PhysicsServer3D.AREA_PARAM_GRAVITY_VECTOR,
|
||||||
|
Vector3(0, 0, 0)
|
||||||
|
)
|
||||||
|
|
||||||
|
PhysicsServer3D.area_set_param(
|
||||||
|
get_viewport().find_world_3d().space,
|
||||||
|
PhysicsServer3D.AREA_PARAM_GRAVITY,
|
||||||
|
0
|
||||||
|
)
|
||||||
|
|
||||||
var children = get_children()
|
var children = get_children()
|
||||||
for child in children:
|
for child in children:
|
||||||
if is_instance_of(child, Music):
|
if is_instance_of(child, Music):
|
||||||
|
@ -36,3 +54,45 @@ func collect_ring():
|
||||||
|
|
||||||
if finished_rings_count >= len(rings):
|
if finished_rings_count >= len(rings):
|
||||||
completed.emit()
|
completed.emit()
|
||||||
|
|
||||||
|
func _input(_event: InputEvent) -> void:
|
||||||
|
if Input.is_action_pressed("gravity_strong") or Input.is_action_just_released("gravity_strong"):
|
||||||
|
PhysicsServer3D.area_set_param(
|
||||||
|
get_viewport().find_world_3d().space,
|
||||||
|
PhysicsServer3D.AREA_PARAM_GRAVITY,
|
||||||
|
gravity_strength_strong if Input.is_action_pressed("gravity_strong") else gravity_strength_normal
|
||||||
|
)
|
||||||
|
|
||||||
|
var up := Input.is_action_just_pressed("gravity_up")
|
||||||
|
var left := Input.is_action_just_pressed("gravity_left")
|
||||||
|
var right := Input.is_action_just_pressed("gravity_right")
|
||||||
|
var down := Input.is_action_just_pressed("gravity_down")
|
||||||
|
|
||||||
|
if up or left or right or down:
|
||||||
|
started_playing.emit()
|
||||||
|
PhysicsServer3D.area_set_param(
|
||||||
|
get_viewport().find_world_3d().space,
|
||||||
|
PhysicsServer3D.AREA_PARAM_GRAVITY,
|
||||||
|
gravity_strength_strong if Input.is_action_pressed("gravity_strong") else gravity_strength_normal
|
||||||
|
)
|
||||||
|
|
||||||
|
var direction: Vector3
|
||||||
|
if up:
|
||||||
|
direction = Vector3.UP
|
||||||
|
elif left:
|
||||||
|
direction = Vector3.LEFT
|
||||||
|
elif right:
|
||||||
|
direction = Vector3.RIGHT
|
||||||
|
elif down:
|
||||||
|
direction = Vector3.DOWN
|
||||||
|
|
||||||
|
if direction && direction != PhysicsServer3D.area_get_param(
|
||||||
|
get_viewport().find_world_3d().space,
|
||||||
|
PhysicsServer3D.AREA_PARAM_GRAVITY_VECTOR
|
||||||
|
):
|
||||||
|
PhysicsServer3D.area_set_param(
|
||||||
|
get_viewport().find_world_3d().space,
|
||||||
|
PhysicsServer3D.AREA_PARAM_GRAVITY_VECTOR,
|
||||||
|
direction
|
||||||
|
)
|
||||||
|
gravity_change.emit(direction)
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
[gd_scene load_steps=14 format=3 uid="uid://drnqmu4lka22d"]
|
[gd_scene load_steps=13 format=3 uid="uid://drnqmu4lka22d"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://drfy3vhe6skp1" path="res://levels/night/music.tscn" id="1_npc74"]
|
[ext_resource type="PackedScene" uid="uid://drfy3vhe6skp1" path="res://levels/night/music.tscn" id="1_npc74"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cnnvwotv33u1b" path="res://elements/player.tscn" id="2_bc1ig"]
|
[ext_resource type="PackedScene" uid="uid://cnnvwotv33u1b" path="res://elements/player.tscn" id="2_bc1ig"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dw0xl8644x166" path="res://elements/gravity.tscn" id="2_lfplq"]
|
|
||||||
[ext_resource type="PackedScene" uid="uid://cpm3laywhlbq5" path="res://elements/ring.tscn" id="4_brcr0"]
|
[ext_resource type="PackedScene" uid="uid://cpm3laywhlbq5" path="res://elements/ring.tscn" id="4_brcr0"]
|
||||||
[ext_resource type="PackedScene" uid="uid://c77bli40240nk" path="res://elements/sign.tscn" id="6_36yav"]
|
[ext_resource type="PackedScene" uid="uid://c77bli40240nk" path="res://elements/sign.tscn" id="6_36yav"]
|
||||||
[ext_resource type="PackedScene" uid="uid://b4jtpua36m6b1" path="res://elements/star.tscn" id="7_ltcl0"]
|
[ext_resource type="PackedScene" uid="uid://b4jtpua36m6b1" path="res://elements/star.tscn" id="7_ltcl0"]
|
||||||
|
@ -45,8 +44,6 @@ reflected_light_source = 2
|
||||||
script = SubResource("GDScript_akhnt")
|
script = SubResource("GDScript_akhnt")
|
||||||
metadata/_custom_type_script = "uid://w3fetao1pegm"
|
metadata/_custom_type_script = "uid://w3fetao1pegm"
|
||||||
|
|
||||||
[node name="Gravity" parent="." instance=ExtResource("2_lfplq")]
|
|
||||||
|
|
||||||
[node name="Environment" type="WorldEnvironment" parent="."]
|
[node name="Environment" type="WorldEnvironment" parent="."]
|
||||||
environment = SubResource("Environment_8o42c")
|
environment = SubResource("Environment_8o42c")
|
||||||
|
|
||||||
|
|
|
@ -198,6 +198,21 @@ ambient_light_source = 3
|
||||||
ambient_light_color = Color(0.986752, 0.986752, 0.986752, 1)
|
ambient_light_color = Color(0.986752, 0.986752, 0.986752, 1)
|
||||||
reflected_light_source = 2
|
reflected_light_source = 2
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_j2kye"]
|
||||||
|
length = 0.001
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("../../WorldEnvironment:environment:sky:sky_material:energy_multiplier")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [1.0]
|
||||||
|
}
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_gma2u"]
|
[sub_resource type="Animation" id="Animation_gma2u"]
|
||||||
resource_name = "sky_brightness"
|
resource_name = "sky_brightness"
|
||||||
length = 0.3
|
length = 0.3
|
||||||
|
@ -215,21 +230,6 @@ tracks/0/keys = {
|
||||||
"values": [1.0, 1.0]
|
"values": [1.0, 1.0]
|
||||||
}
|
}
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_j2kye"]
|
|
||||||
length = 0.001
|
|
||||||
tracks/0/type = "value"
|
|
||||||
tracks/0/imported = false
|
|
||||||
tracks/0/enabled = true
|
|
||||||
tracks/0/path = NodePath("../../WorldEnvironment:environment:sky:sky_material:energy_multiplier")
|
|
||||||
tracks/0/interp = 1
|
|
||||||
tracks/0/loop_wrap = true
|
|
||||||
tracks/0/keys = {
|
|
||||||
"times": PackedFloat32Array(0),
|
|
||||||
"transitions": PackedFloat32Array(1),
|
|
||||||
"update": 0,
|
|
||||||
"values": [1.0]
|
|
||||||
}
|
|
||||||
|
|
||||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_wruj6"]
|
[sub_resource type="AnimationLibrary" id="AnimationLibrary_wruj6"]
|
||||||
_data = {
|
_data = {
|
||||||
&"RESET": SubResource("Animation_j2kye"),
|
&"RESET": SubResource("Animation_j2kye"),
|
||||||
|
|
|
@ -8,19 +8,25 @@ signal request_start
|
||||||
@onready var label_name = $VBoxContainer/MarginContainer/VBoxContainer/Description/Name
|
@onready var label_name = $VBoxContainer/MarginContainer/VBoxContainer/Description/Name
|
||||||
@onready var label_time = $VBoxContainer/MarginContainer/VBoxContainer/Description/Time
|
@onready var label_time = $VBoxContainer/MarginContainer/VBoxContainer/Description/Time
|
||||||
|
|
||||||
|
## Get the newest \"played_for\" when the main menu appears again
|
||||||
|
func _enter_tree() -> void:
|
||||||
|
if len(SaveFiles.selected_file):
|
||||||
|
display_file_data(SaveFiles.selected_file)
|
||||||
|
|
||||||
func _on_save_1_pressed() -> void:
|
func _on_save_1_pressed() -> void:
|
||||||
label_name.text = $VBoxContainer/Save1.text
|
label_name.text = $VBoxContainer/Save1.text
|
||||||
display_file_data(SaveFiles.read(SaveFiles.names[0]))
|
display_file_data(SaveFiles.names[0])
|
||||||
|
|
||||||
func _on_save_2_pressed() -> void:
|
func _on_save_2_pressed() -> void:
|
||||||
label_name.text = $VBoxContainer/Save2.text
|
label_name.text = $VBoxContainer/Save2.text
|
||||||
display_file_data(SaveFiles.read(SaveFiles.names[1]))
|
display_file_data(SaveFiles.names[1])
|
||||||
|
|
||||||
func _on_save_3_pressed() -> void:
|
func _on_save_3_pressed() -> void:
|
||||||
label_name.text = $VBoxContainer/Save3.text
|
label_name.text = $VBoxContainer/Save3.text
|
||||||
display_file_data(SaveFiles.read(SaveFiles.names[2]))
|
display_file_data(SaveFiles.names[2])
|
||||||
|
|
||||||
func display_file_data(data: Variant) -> void:
|
func display_file_data(file_name: String) -> void:
|
||||||
|
var data = SaveFiles.read(file_name)
|
||||||
$VBoxContainer/MarginContainer.show()
|
$VBoxContainer/MarginContainer.show()
|
||||||
label_time.text = \" | \"
|
label_time.text = \" | \"
|
||||||
if data.has(\"played_for\") and data.played_for is float:
|
if data.has(\"played_for\") and data.played_for is float:
|
||||||
|
|
|
@ -86,6 +86,7 @@ common/physics_ticks_per_second=120
|
||||||
common/max_physics_steps_per_frame=20
|
common/max_physics_steps_per_frame=20
|
||||||
3d/physics_engine="GodotPhysics3D"
|
3d/physics_engine="GodotPhysics3D"
|
||||||
3d/default_gravity=1.0
|
3d/default_gravity=1.0
|
||||||
|
3d/default_gravity_vector=Vector3(0, -0.5, 0)
|
||||||
3d/solver/solver_iterations=40
|
3d/solver/solver_iterations=40
|
||||||
3d/solver/default_contact_bias=1.0
|
3d/solver/default_contact_bias=1.0
|
||||||
common/physics_interpolation=true
|
common/physics_interpolation=true
|
||||||
|
|
|
@ -6,7 +6,7 @@ const names := [
|
||||||
"user://save_file_3.save",
|
"user://save_file_3.save",
|
||||||
]
|
]
|
||||||
|
|
||||||
var selected_file := names[0]
|
var selected_file: String
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
for save_file_name in names:
|
for save_file_name in names:
|
||||||
|
@ -22,6 +22,7 @@ func empty(save_file_name: String) -> void:
|
||||||
write(JSON.stringify({}), save_file_name)
|
write(JSON.stringify({}), save_file_name)
|
||||||
|
|
||||||
func read(save_file_name: String) -> Variant:
|
func read(save_file_name: String) -> Variant:
|
||||||
|
print("Reading from save file ", save_file_name)
|
||||||
ensure_existence(save_file_name)
|
ensure_existence(save_file_name)
|
||||||
selected_file = save_file_name
|
selected_file = save_file_name
|
||||||
|
|
||||||
|
@ -41,6 +42,7 @@ func write(json_string: String, save_file_name: String) -> void:
|
||||||
save_file.store_line("FOR YOUR SAFETY, ALWAYS CHECK IF THE DATA OF THE FILES YOU DOWNLOAD LOOKS OKAY")
|
save_file.store_line("FOR YOUR SAFETY, ALWAYS CHECK IF THE DATA OF THE FILES YOU DOWNLOAD LOOKS OKAY")
|
||||||
|
|
||||||
func change_property(property: String, value, save_file_name: String) -> void:
|
func change_property(property: String, value, save_file_name: String) -> void:
|
||||||
|
print("Changing property '", property, "' on save file ", save_file_name)
|
||||||
ensure_existence(save_file_name)
|
ensure_existence(save_file_name)
|
||||||
var data = read(save_file_name)
|
var data = read(save_file_name)
|
||||||
data[property] = value
|
data[property] = value
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue