Skip to content

Commit

Permalink
started working on a background loader
Browse files Browse the repository at this point in the history
  • Loading branch information
geegaz committed Jan 17, 2022
1 parent 5d0ee44 commit 3111d03
Show file tree
Hide file tree
Showing 26 changed files with 293 additions and 158 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ export_presets.cfg
data_*/

# Custom ignores
.build/
Builds/
Media/
Empty file removed .img/.gdignore
Empty file.
Binary file removed .img/badge_IndieGamesLyon-Sheet.png
Binary file not shown.
Binary file removed .img/badge_IndieGamesLyon.aseprite
Binary file not shown.
Binary file removed .img/badge_IndieGamesLyon1.png
Binary file not shown.
Binary file removed .img/badge_IndieGamesLyon2.png
Binary file not shown.
Binary file removed .img/badge_IndieGamesLyon3.png
Binary file not shown.
Binary file removed .img/badge_IndieGamesLyon4.png
Binary file not shown.
40 changes: 40 additions & 0 deletions Addons/SimpleNodes/HealthBar.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
class_name HealthBar, "./HealthBar.svg"
extends LabelRange

signal death
signal health_changed(health)

export(float) var max_health: float setget set_max_health
export(float) var current_health: float setget set_current_health
export(bool) var always_visible: bool = false

func is_dead()->bool:
return current_health <= 0

func is_max_health()->bool:
return current_health >= max_health

func set_max_health(new_value: float)->void:
max_health = new_value
max_value = new_value
set_current_health(current_health)

func set_current_health(new_value: float)->void:
current_health = clamp(new_value, 0, max_health)
value = current_health/max_health * max_value
visible = is_visible()
if is_dead():
emit_signal("death")
emit_signal("health_changed", current_health)

func is_visible()->bool:
return always_visible or !(is_max_health() or is_dead())

func remove_health(amount: float)->void:
set_current_health(current_health - amount)

func add_health(amount: float)->void:
set_current_health(current_health + amount)

func get_class()->String:
return "HealthBar"
1 change: 1 addition & 0 deletions Addons/SimpleNodes/HealthBar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions Addons/SimpleNodes/HealthBar.svg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/HealthBar.svg-72b95c61a6db338f7a3f4dfd24471c04.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://Addons/SimpleNodes/HealthBar.svg"
dest_files=[ "res://.import/HealthBar.svg-72b95c61a6db338f7a3f4dfd24471c04.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0
16 changes: 16 additions & 0 deletions Addons/SimpleNodes/RandomStreamPlayer.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class_name RandomStreamPlayer, "./RandomStreamPlayer.svg"
extends AudioStreamPlayer

export(Array, AudioStream) var samples = []
export(float, 0, 2) var min_pitch: = 1.0
export(float, 0, 2) var max_pitch: = 1.0

func play_random(from_position: float = 0.0)->void:
var samples_size = samples.size()
if samples_size > 0:
stream = samples[randi() % samples_size]
pitch_scale = wrapf(randf()*2.0, min_pitch, max_pitch)
play(from_position)

func get_class()->String:
return "RandomStreamPlayer"
1 change: 1 addition & 0 deletions Addons/SimpleNodes/RandomStreamPlayer.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions Addons/SimpleNodes/RandomStreamPlayer.svg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/RandomStreamPlayer.svg-89397f9824a2f06d60dc171b435309b7.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://Addons/SimpleNodes/RandomStreamPlayer.svg"
dest_files=[ "res://.import/RandomStreamPlayer.svg-89397f9824a2f06d60dc171b435309b7.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0
File renamed without changes.
7 changes: 3 additions & 4 deletions Scenes/Global.tscn
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
[gd_scene load_steps=3 format=2]

[ext_resource path="res://Scripts/Global.gd" type="Script" id=1]
[ext_resource path="res://Scenes/UI/TransitionScreen.tscn" type="PackedScene" id=2]
[ext_resource path="res://Scenes/SceneTransition.tscn" type="PackedScene" id=2]

[node name="Global" type="Node"]
pause_mode = 2
script = ExtResource( 1 )

[node name="TransitionLayer" type="CanvasLayer" parent="."]
layer = 3
[node name="OverlayLayer" type="CanvasLayer" parent="."]

[node name="TransitionScreen" parent="TransitionLayer" instance=ExtResource( 2 )]
[node name="SceneTransition" parent="OverlayLayer" instance=ExtResource( 2 )]
19 changes: 7 additions & 12 deletions Scenes/Main.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,13 @@ tile_data = PoolIntArray( 196588, 13, 0, 131072, 11, 0, 131091, 14, 0, 131111, 3
[node name="PlayerSprite" type="AnimatedSprite" parent="Background"]
position = Vector2( 80, 144 )
frames = SubResource( 9 )
frame = 2
frame = 1
playing = true

[node name="FlagSprite" type="AnimatedSprite" parent="Background"]
position = Vector2( 264, 104 )
frames = SubResource( 18 )
frame = 5
frame = 4
playing = true

[node name="MainMenu" type="Control" parent="."]
Expand Down Expand Up @@ -276,6 +276,7 @@ texture_pressed = SubResource( 20 )
texture_hover = SubResource( 21 )
texture_disabled = SubResource( 22 )
__meta__ = {
"_edit_lock_": true,
"_edit_use_anchors_": false
}

Expand All @@ -286,9 +287,9 @@ anchor_right = 0.0
[node name="OptionsBack" type="TextureButton" parent="OptionsMenu"]
anchor_left = 1.0
anchor_right = 1.0
margin_left = -24.0
margin_left = -24.8909
margin_top = 5.0
margin_right = -8.0
margin_right = -8.89093
margin_bottom = 21.0
mouse_default_cursor_shape = 2
size_flags_horizontal = 0
Expand All @@ -298,6 +299,7 @@ texture_pressed = SubResource( 24 )
texture_hover = SubResource( 25 )
texture_disabled = SubResource( 26 )
__meta__ = {
"_edit_lock_": true,
"_edit_use_anchors_": false
}

Expand All @@ -318,6 +320,7 @@ texture_pressed = SubResource( 28 )
texture_hover = SubResource( 29 )
texture_disabled = SubResource( 30 )
__meta__ = {
"_edit_lock_": true,
"_edit_use_anchors_": false
}

Expand All @@ -326,11 +329,3 @@ anchor_mode = 0
current = true

[node name="Tween" type="Tween" parent="."]

[connection signal="pressed" from="MainMenu/Quit" to="." method="_on_Quit_pressed"]
[connection signal="pressed" from="MainMenu/VBoxContainer/Start" to="." method="_on_Start_pressed"]
[connection signal="pressed" from="MainMenu/VBoxContainer/HBoxContainer/Options" to="." method="_on_Options_pressed"]
[connection signal="pressed" from="MainMenu/VBoxContainer/HBoxContainer/Credits" to="." method="_on_Credits_pressed"]
[connection signal="pressed" from="LevelsMenu/LevelsBack" to="." method="_on_LevelsBack_pressed"]
[connection signal="pressed" from="OptionsMenu/OptionsBack" to="." method="_on_OptionsBack_pressed"]
[connection signal="pressed" from="CreditsMenu/CreditsBack" to="." method="_on_CreditsBack_pressed"]
41 changes: 31 additions & 10 deletions Scenes/UI/TransitionScreen.tscn → Scenes/SceneTransition.tscn
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[gd_scene load_steps=10 format=2]

[ext_resource path="res://Scripts/UI/TransitionScreen.gd" type="Script" id=1]
[ext_resource path="res://Assets/Shaders/transition.shader" type="Shader" id=2]
[ext_resource path="res://Assets/Shaders/transition.shader" type="Shader" id=1]
[ext_resource path="res://Assets/Shaders/animated_sprite.shader" type="Shader" id=2]
[ext_resource path="res://Assets/Sprites/transitions/diagonal.png" type="Texture" id=3]
[ext_resource path="res://Assets/Sprites/player/loading_animation-Sheet.png" type="Texture" id=4]
[ext_resource path="res://Assets/Shaders/animated_sprite.shader" type="Shader" id=5]
[ext_resource path="res://Scripts/UI/SceneTransition.gd" type="Script" id=5]

[sub_resource type="ShaderMaterial" id=1]
shader = ExtResource( 2 )
shader = ExtResource( 1 )
shader_param/progress = 0.0
shader_param/smooth_size = 0.001
shader_param/color = Color( 0.105882, 0.105882, 0.105882, 1 )
Expand Down Expand Up @@ -39,6 +39,18 @@ tracks/1/keys = {
"update": 0,
"values": [ Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 1 ) ]
}
tracks/2/type = "value"
tracks/2/path = NodePath(".:visible")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 1,
"values": [ true ]
}

[sub_resource type="Animation" id=3]
resource_name = "transition_out"
Expand Down Expand Up @@ -66,18 +78,29 @@ tracks/1/keys = {
"update": 0,
"values": [ Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 0 ) ]
}
tracks/2/type = "value"
tracks/2/path = NodePath(".:visible")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/keys = {
"times": PoolRealArray( 1 ),
"transitions": PoolRealArray( 1 ),
"update": 1,
"values": [ false ]
}

[sub_resource type="ShaderMaterial" id=4]
shader = ExtResource( 5 )
shader = ExtResource( 2 )
shader_param/h_frames = 4
shader_param/v_frames = 1
shader_param/frame_duration = 0.1

[node name="TransitionScreen" type="Control"]
pause_mode = 2
[node name="SceneTransition" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 1 )
script = ExtResource( 5 )
__meta__ = {
"_edit_use_anchors_": true
}
Expand All @@ -100,5 +123,3 @@ material = SubResource( 4 )
position = Vector2( 296, 160 )
texture = ExtResource( 4 )
hframes = 4

[connection signal="animation_finished" from="AnimationPlayer" to="." method="_on_AnimationPlayer_animation_finished"]
29 changes: 8 additions & 21 deletions Scenes/UI/OptionsMenu.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -55,25 +55,19 @@ __meta__ = {

[node name="CenterContainer" type="CenterContainer" parent="ScrollContainer"]
margin_right = 304.0
margin_bottom = 190.0
margin_bottom = 158.0
size_flags_horizontal = 3
size_flags_vertical = 3

[node name="VBoxContainer" type="VBoxContainer" parent="ScrollContainer/CenterContainer"]
margin_left = 73.0
margin_right = 231.0
margin_bottom = 190.0
margin_bottom = 158.0
custom_constants/separation = 16

[node name="MarginContainer" type="MarginContainer" parent="ScrollContainer/CenterContainer/VBoxContainer"]
margin_right = 158.0
margin_bottom = 8.0
custom_constants/margin_top = 8

[node name="Sound" type="VBoxContainer" parent="ScrollContainer/CenterContainer/VBoxContainer"]
margin_top = 24.0
margin_right = 158.0
margin_bottom = 97.0
margin_bottom = 73.0

[node name="Label" type="Label" parent="ScrollContainer/CenterContainer/VBoxContainer/Sound"]
margin_right = 158.0
Expand Down Expand Up @@ -180,9 +174,9 @@ script = ExtResource( 5 )
label_path = NodePath("../Number")

[node name="Display" type="VBoxContainer" parent="ScrollContainer/CenterContainer/VBoxContainer"]
margin_top = 113.0
margin_top = 89.0
margin_right = 158.0
margin_bottom = 166.0
margin_bottom = 142.0

[node name="Label" type="Label" parent="ScrollContainer/CenterContainer/VBoxContainer/Display"]
margin_right = 158.0
Expand Down Expand Up @@ -221,14 +215,7 @@ custom_colors/font_color_pressed = Color( 1, 1, 1, 1 )
pressed = true
text = "Screenshake"

[node name="MarginContainer2" type="MarginContainer" parent="ScrollContainer/CenterContainer/VBoxContainer"]
margin_top = 182.0
[node name="PushBottom" type="Control" parent="ScrollContainer/CenterContainer/VBoxContainer"]
margin_top = 158.0
margin_right = 158.0
margin_bottom = 190.0
custom_constants/margin_top = 8

[connection signal="value_changed" from="ScrollContainer/CenterContainer/VBoxContainer/Sound/Master/MasterSlider" to="." method="_on_MasterSlider_value_changed"]
[connection signal="value_changed" from="ScrollContainer/CenterContainer/VBoxContainer/Sound/SFX/SFXSlider" to="." method="_on_SFXSlider_value_changed"]
[connection signal="value_changed" from="ScrollContainer/CenterContainer/VBoxContainer/Sound/Music/MusicSlider" to="." method="_on_MusicSlider_value_changed"]
[connection signal="toggled" from="ScrollContainer/CenterContainer/VBoxContainer/Display/FullscreenCheckButton" to="." method="_on_FullscreenCheckButton_toggled"]
[connection signal="toggled" from="ScrollContainer/CenterContainer/VBoxContainer/Display/ScreenshakeCheckButton" to="." method="_on_ScreenshakeCheckButton_toggled"]
margin_bottom = 158.0
Loading

0 comments on commit 3111d03

Please sign in to comment.