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
140
gui/gravity.tscn
Normal file
140
gui/gravity.tscn
Normal file
|
@ -0,0 +1,140 @@
|
|||
[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="AudioStream" uid="uid://dmdbharecy448" path="res://sounds/gravity.ogg" id="2_5uwlw"]
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_3yq1l"]
|
||||
script/source = "extends Control
|
||||
|
||||
@onready var direction_node: TextureRect = $Direction
|
||||
@onready var animation: AnimationPlayer = $Direction/AnimationPlayer
|
||||
@onready var audio: AudioStreamPlayer = $Direction/AudioStreamPlayer
|
||||
|
||||
func _ready() -> void:
|
||||
# set the indicator to be fully transparent when it first spawns
|
||||
direction_node.self_modulate = Color(1, 1, 1, 0)
|
||||
|
||||
func react_to_gravity_change(direction: Vector3) -> void:
|
||||
if direction == Vector3.UP:
|
||||
direction_node.rotation_degrees = -90
|
||||
audio.pitch_scale = 1.05
|
||||
elif direction == Vector3.LEFT:
|
||||
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 animation.is_playing():
|
||||
animation.stop()
|
||||
animation.play(\"grow_fadeout\")
|
||||
|
||||
if Settings.sound_on_gravity_change:
|
||||
audio.play()
|
||||
"
|
||||
|
||||
[sub_resource type="Animation" id="Animation_6rwl4"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:scale")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Vector2(0.3, 0.3)]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath(".:self_modulate")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 0.501961)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_ll6d0"]
|
||||
resource_name = "grow_fadeout"
|
||||
length = 0.2
|
||||
step = 0.2
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:scale")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.2),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector2(0.3, 0.3), Vector2(0.8, 0.8)]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath(".:self_modulate")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0, 0.142857),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 0.501961), Color(1, 1, 1, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_0w0ne"]
|
||||
_data = {
|
||||
&"RESET": SubResource("Animation_6rwl4"),
|
||||
&"grow_fadeout": SubResource("Animation_ll6d0")
|
||||
}
|
||||
|
||||
[node name="Gravity" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
script = SubResource("GDScript_3yq1l")
|
||||
|
||||
[node name="Direction" type="TextureRect" parent="."]
|
||||
self_modulate = Color(1, 1, 1, 0.501961)
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -400.0
|
||||
offset_top = -400.0
|
||||
offset_right = 400.0
|
||||
offset_bottom = 400.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
scale = Vector2(0.3, 0.3)
|
||||
pivot_offset = Vector2(400, 400)
|
||||
mouse_filter = 2
|
||||
texture = ExtResource("1_4mbho")
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="Direction"]
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_0w0ne")
|
||||
}
|
||||
|
||||
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="Direction"]
|
||||
stream = ExtResource("2_5uwlw")
|
||||
volume_db = -6.0
|
||||
mix_target = 2
|
||||
bus = &"Sounds"
|
|
@ -31,11 +31,6 @@ var seconds_spent_level_attempt := 0.0:
|
|||
seconds_spent_level_attempt = value
|
||||
$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:
|
||||
var minutes: int = floor(seconds / 60)
|
||||
return (\"%0*d\" % [2, minutes]) + \":\" + (\"%0*.3f\" % [6, seconds - (minutes * 60)])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue