1
Fork 0
mirror of https://github.com/Steffo99/swear-jar.git synced 2024-11-24 00:24:19 +00:00

Tweak a ton of stuff

This commit is contained in:
Steffo 2023-10-14 02:27:55 +02:00
parent 509f6a3626
commit 2b3827ed51
Signed by: steffo
GPG key ID: 2A24051445686895
20 changed files with 99 additions and 78 deletions

View file

@ -10,7 +10,10 @@ var collected_count: int = 0
##
## The strings will match only if exactly the same.
@export var collecting_types: Array[StringName]
@export var sound_absorb: AudioStreamPlayer
## The sound played when an item is collected.
@export var sound_absorb: AudioStreamPlayer2D
## The goal amount of entities to collect.
##
## When [collected_count] reaches it, it will be reset to zero, and the "goal" signal will be emitted.

View file

@ -1,17 +1,10 @@
[gd_scene load_steps=3 format=3 uid="uid://c5w3b55aiui6c"]
[gd_scene load_steps=2 format=3 uid="uid://c5w3b55aiui6c"]
[ext_resource type="Script" path="res://collector/collector.gd" id="1_1xtt5"]
[ext_resource type="AudioStream" uid="uid://bpxjhl0aq3yrv" path="res://audio/conversione/suck2.wav" id="2_n0plc"]
[node name="Collector" type="Area2D" node_paths=PackedStringArray("sound_absorb")]
[node name="Collector" type="Area2D"]
collision_layer = 0
collision_mask = 4
script = ExtResource("1_1xtt5")
sound_absorb = NodePath("sound_absorb")
[node name="sound_absorb" type="AudioStreamPlayer" parent="."]
stream = ExtResource("2_n0plc")
volume_db = -8.0
pitch_scale = 2.0
[connection signal="body_entered" from="." to="." method="_on_body_entered"]

View file

@ -18,6 +18,7 @@ func _ready():
var material = ShaderMaterial.new()
material.shader = shader
parent.material = material
randomize_hue()
func randomize_hue():

View file

@ -1,11 +1,9 @@
extends StaticBody2D
class_name Converter
@export var sprite_front: AnimatedSprite2D
@export var sprite_back: AnimatedSprite2D
@export var conversion_timer: Timer
@export var sound_working: AudioStreamPlayer
@export var sound_complete: AudioStreamPlayer
@onready var sprite_front: AnimatedSprite2D = find_children("SpriteFront", "AnimatedSprite2D", false, true).pop_front()
@onready var sprite_back: AnimatedSprite2D = find_children("SpriteBack", "AnimatedSprite2D", false, true).pop_front()
@onready var working_timer: Timer = $WorkingTimer
@export var spawner: Spawner
@export var spawner_alt: Spawner
@export_range(0.0, 1.0, 0.01) var spawner_alt_chance: float
@ -17,20 +15,18 @@ func _on_collector_goal():
to_produce += 1
func _physics_process(_delta):
if to_produce >= 1 and conversion_timer.is_stopped():
if to_produce >= 1 and working_timer.is_stopped():
to_produce -= 1
produce()
func produce():
conversion_timer.start()
working_timer.start()
if sprite_front:
sprite_front.play()
if sprite_back:
sprite_back.play()
if sound_working:
sound_working.play()
func _on_timer_timeout():
func _on_working_timer_timeout():
if spawner_alt and Randomizer.rng.randf() < spawner_alt_chance:
spawner_alt.spawn()
else:
@ -39,8 +35,6 @@ func _on_timer_timeout():
sprite_front.stop()
if sprite_back:
sprite_back.stop()
if sound_working:
sound_working.stop()
var is_pending_deletion: bool = false

View file

@ -1,9 +0,0 @@
[gd_scene load_steps=2 format=3 uid="uid://bevj27e1ha8m3"]
[ext_resource type="PackedScene" uid="uid://c3p0jdf7416ac" path="res://converters/full_converter_shape.tscn" id="1_qs7xk"]
[node name="ConverterPlacementBody" type="StaticBody2D"]
collision_layer = 16
collision_mask = 0
[node name="FullConverterShape" parent="." instance=ExtResource("1_qs7xk")]

View file

@ -11,7 +11,7 @@
[ext_resource type="PackedScene" uid="uid://c67lfbk4gf1ga" path="res://spawner/spawner.tscn" id="9_2wvgu"]
[ext_resource type="AudioStream" uid="uid://br25ip30mu174" path="res://audio/conversione/mechanic_sound.wav" id="10_6hhch"]
[ext_resource type="AudioStream" uid="uid://7tw5efuo3gxj" path="res://audio/conversione/coin_to_coin.wav" id="11_r8505"]
[ext_resource type="PackedScene" uid="uid://bevj27e1ha8m3" path="res://converters/converter_placement_body.tscn" id="12_5qhgs"]
[ext_resource type="PackedScene" uid="uid://bevj27e1ha8m3" path="res://converters/placement_obstruction.tscn" id="12_5qhgs"]
[sub_resource type="AtlasTexture" id="AtlasTexture_62dyi"]
atlas = ExtResource("4_exnn7")
@ -88,6 +88,7 @@ sprite_frames = SubResource("SpriteFrames_4m3dg")
z_index = 2
position = Vector2(-14.5, -3)
shape = SubResource("CapsuleShape2D_aslkt")
debug_color = Color(0, 0.6, 0.701961, 0.419608)
[node name="RightWall" type="CollisionShape2D" parent="."]
z_index = 2

View file

@ -14,7 +14,7 @@
[ext_resource type="AudioStream" uid="uid://db1i6rqitk0e" path="res://audio/conversione/coal_funny.wav" id="11_601lg"]
[ext_resource type="PackedScene" uid="uid://cr5tiep20hk0s" path="res://entity/coal_diamond/diamond.tscn" id="11_ekhmr"]
[ext_resource type="AudioStream" uid="uid://cc4mqxq6mxmdg" path="res://audio/conversione/coin_to_gem.wav" id="12_pddsd"]
[ext_resource type="PackedScene" uid="uid://bevj27e1ha8m3" path="res://converters/converter_placement_body.tscn" id="12_xld3l"]
[ext_resource type="PackedScene" uid="uid://bevj27e1ha8m3" path="res://converters/placement_obstruction.tscn" id="12_xld3l"]
[ext_resource type="AudioStream" uid="uid://du16ilpv6gmxd" path="res://audio/conversione/drop_in_lava.wav" id="13_jvouj"]
[sub_resource type="AtlasTexture" id="AtlasTexture_00uxa"]

View file

@ -12,7 +12,7 @@
[ext_resource type="PackedScene" uid="uid://bawprh8kluilq" path="res://entity/gem/gem.tscn" id="10_op7xt"]
[ext_resource type="AudioStream" uid="uid://br25ip30mu174" path="res://audio/conversione/mechanic_sound.wav" id="11_lofho"]
[ext_resource type="AudioStream" uid="uid://cc4mqxq6mxmdg" path="res://audio/conversione/coin_to_gem.wav" id="11_sk30q"]
[ext_resource type="PackedScene" uid="uid://bevj27e1ha8m3" path="res://converters/converter_placement_body.tscn" id="13_6o73w"]
[ext_resource type="PackedScene" uid="uid://bevj27e1ha8m3" path="res://converters/placement_obstruction.tscn" id="13_6o73w"]
[sub_resource type="AtlasTexture" id="AtlasTexture_wy1v3"]
atlas = ExtResource("3_ofrsl")

View file

@ -19,7 +19,7 @@
[ext_resource type="AudioStream" uid="uid://du16ilpv6gmxd" path="res://audio/conversione/drop_in_lava.wav" id="15_nahnf"]
[ext_resource type="AudioStream" uid="uid://dv1e0wiiquxp0" path="res://audio/conversione/lava.wav" id="16_ptmks"]
[ext_resource type="AudioStream" uid="uid://c0uhi1hrejyxg" path="res://audio/conversione/new_item.wav" id="17_4wm4w"]
[ext_resource type="PackedScene" uid="uid://bevj27e1ha8m3" path="res://converters/converter_placement_body.tscn" id="17_udaa3"]
[ext_resource type="PackedScene" uid="uid://bevj27e1ha8m3" path="res://converters/placement_obstruction.tscn" id="17_udaa3"]
[sub_resource type="AtlasTexture" id="AtlasTexture_uqtie"]
atlas = ExtResource("2_136t7")

View file

@ -0,0 +1,9 @@
[gd_scene load_steps=2 format=3 uid="uid://bevj27e1ha8m3"]
[ext_resource type="PackedScene" uid="uid://o8kq85q3qtl4" path="res://converters/shield_converter_obstruction_shape.tscn" id="1_mcdb6"]
[node name="PlacementObstruction" type="StaticBody2D"]
collision_layer = 16
collision_mask = 0
[node name="ShieldConverterObstructionShape" parent="." instance=ExtResource("1_mcdb6")]

View file

@ -1,7 +1,9 @@
[gd_scene load_steps=2 format=3 uid="uid://c3p0jdf7416ac"]
[gd_scene load_steps=2 format=3 uid="uid://o8kq85q3qtl4"]
[sub_resource type="ConvexPolygonShape2D" id="ConvexPolygonShape2D_cfy64"]
points = PackedVector2Array(-15, 9, -6, 15, 5, 15, 15, 9, 15, -16, -15, -16)
[node name="FullConverterShape" type="CollisionShape2D"]
[node name="ShieldConverterObstructionShape" type="CollisionShape2D"]
z_index = 2
shape = SubResource("ConvexPolygonShape2D_cfy64")
debug_color = Color(0, 0, 0, 0.141176)

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=18 format=3 uid="uid://but1bdslxp5jl"]
[gd_scene load_steps=20 format=3 uid="uid://but1bdslxp5jl"]
[ext_resource type="Script" path="res://converters/converter.gd" id="1_chhfg"]
[ext_resource type="Texture2D" uid="uid://c1fu70mb51gyd" path="res://converters/silver_to_gold/silver_converter_back.png" id="2_rpdc3"]
@ -7,11 +7,13 @@
[ext_resource type="Texture2D" uid="uid://b006dig4oebpl" path="res://converters/silver_to_gold/silver_converter_front_3.png" id="5_ycslk"]
[ext_resource type="Texture2D" uid="uid://djixrek5573a6" path="res://converters/silver_to_gold/silver_converter_front_4.png" id="6_0qxp1"]
[ext_resource type="PackedScene" uid="uid://c5w3b55aiui6c" path="res://collector/collector.tscn" id="7_3046q"]
[ext_resource type="AudioStream" uid="uid://bpxjhl0aq3yrv" path="res://audio/conversione/suck2.wav" id="8_0jhl8"]
[ext_resource type="PackedScene" uid="uid://c67lfbk4gf1ga" path="res://spawner/spawner.tscn" id="8_65kmt"]
[ext_resource type="PackedScene" uid="uid://b3ev0md0jrpfj" path="res://converters/working_timer.tscn" id="9_8xv87"]
[ext_resource type="PackedScene" uid="uid://du3005kwybbrh" path="res://entity/coin_gold/coin_gold.tscn" id="9_t8y3t"]
[ext_resource type="AudioStream" uid="uid://br25ip30mu174" path="res://audio/conversione/mechanic_sound.wav" id="10_0dr47"]
[ext_resource type="AudioStream" uid="uid://7tw5efuo3gxj" path="res://audio/conversione/coin_to_coin.wav" id="11_ow0vy"]
[ext_resource type="PackedScene" uid="uid://bevj27e1ha8m3" path="res://converters/converter_placement_body.tscn" id="12_37x2h"]
[ext_resource type="PackedScene" uid="uid://bevj27e1ha8m3" path="res://converters/placement_obstruction.tscn" id="12_37x2h"]
[sub_resource type="SpriteFrames" id="SpriteFrames_1qp6y"]
animations = [{
@ -37,25 +39,22 @@ animations = [{
radius = 1.5
height = 28.0
[sub_resource type="RectangleShape2D" id="RectangleShape2D_31dtl"]
size = Vector2(26, 4)
[sub_resource type="ConvexPolygonShape2D" id="ConvexPolygonShape2D_emmmj"]
points = PackedVector2Array(0, 0, -16, 0, -16, -3, -5, -7, 5, -7, 16, -3, 16, 0)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_k11if"]
size = Vector2(26, 5)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_jeo5f"]
size = Vector2(26, 10)
size = Vector2(16, 4)
[node name="SilverConverter" type="StaticBody2D" node_paths=PackedStringArray("sprite_front", "conversion_timer", "sound_working", "sound_complete", "spawner")]
[node name="SilverConverter" type="StaticBody2D" node_paths=PackedStringArray("spawner")]
position = Vector2(0, -2)
scale = Vector2(3, 3)
collision_layer = 8
collision_mask = 0
input_pickable = true
script = ExtResource("1_chhfg")
sprite_front = NodePath("SpriteFront")
conversion_timer = NodePath("ConversionTimer")
sound_working = NodePath("SoundWorking")
sound_complete = NodePath("Spawner/SoundComplete")
spawner = NodePath("Spawner")
[node name="SpriteBack" type="Sprite2D" parent="."]
@ -70,34 +69,53 @@ sprite_frames = SubResource("SpriteFrames_1qp6y")
frame = 3
frame_progress = 0.193836
[node name="PlacementObstruction" parent="." instance=ExtResource("12_37x2h")]
[node name="LeftWall" type="CollisionShape2D" parent="."]
z_index = 2
position = Vector2(-14.5, -3)
shape = SubResource("CapsuleShape2D_aslkt")
debug_color = Color(0, 0, 0, 0.784314)
[node name="RightWall" type="CollisionShape2D" parent="."]
z_index = 2
position = Vector2(14.5, -3)
shape = SubResource("CapsuleShape2D_aslkt")
debug_color = Color(0, 0, 0, 0.784314)
[node name="InnerWall" type="CollisionShape2D" parent="."]
[node name="BottomWall" type="CollisionShape2D" parent="."]
z_index = 3
position = Vector2(0, 4.5)
position = Vector2(1.16196e-05, 9.08333)
rotation = 3.14159
shape = SubResource("RectangleShape2D_31dtl")
shape = SubResource("ConvexPolygonShape2D_emmmj")
one_way_collision = true
debug_color = Color(0, 0, 0, 0.784314)
[node name="Collector" parent="." instance=ExtResource("7_3046q")]
[node name="Collector" parent="." node_paths=PackedStringArray("sound_absorb") instance=ExtResource("7_3046q")]
z_index = 2
position = Vector2(0, 6.5)
collecting_types = Array[StringName]([&"Silver"])
sound_absorb = NodePath("SoundAbsorb")
collecting_amount = 10
[node name="CollectShape" type="CollisionShape2D" parent="Collector"]
shape = SubResource("RectangleShape2D_k11if")
debug_color = Color(0, 0.701961, 0.188235, 0.419608)
[node name="SoundAbsorb" type="AudioStreamPlayer2D" parent="Collector"]
stream = ExtResource("8_0jhl8")
volume_db = -8.0
pitch_scale = 2.0
[node name="WorkingTimer" parent="." node_paths=PackedStringArray("working_sound") instance=ExtResource("9_8xv87")]
working_sound = NodePath("SoundWorking")
[node name="SoundWorking" type="AudioStreamPlayer2D" parent="WorkingTimer"]
position = Vector2(0, 25)
stream = ExtResource("10_0dr47")
[node name="Spawner" parent="." node_paths=PackedStringArray("sound_complete") instance=ExtResource("8_65kmt")]
position = Vector2(0, 8)
position = Vector2(0, 10)
scene = ExtResource("9_t8y3t")
buffer_cap = 1
spawn_rect = Rect2(-8, 0, 16, 4)
@ -110,23 +128,14 @@ sound_complete_pitch_max = 1.14
[node name="PreventSpawnShape" type="CollisionShape2D" parent="Spawner"]
z_index = 3
position = Vector2(0, 3.5)
position = Vector2(0, 2)
shape = SubResource("RectangleShape2D_jeo5f")
debug_color = Color(0.701961, 0, 0, 0.419608)
[node name="SoundComplete" type="AudioStreamPlayer" parent="Spawner"]
[node name="SoundComplete" type="AudioStreamPlayer2D" parent="Spawner"]
position = Vector2(0, 2)
stream = ExtResource("11_ow0vy")
[node name="ConversionTimer" type="Timer" parent="."]
wait_time = 0.5
one_shot = true
[node name="SoundWorking" type="AudioStreamPlayer" parent="."]
stream = ExtResource("10_0dr47")
[node name="ConverterPlacementBody" parent="." instance=ExtResource("12_37x2h")]
[connection signal="input_event" from="." to="." method="_on_input_event"]
[connection signal="collected" from="Collector" to="." method="_on_collector_collected"]
[connection signal="goal" from="Collector" to="." method="_on_collector_goal"]
[connection signal="timeout" from="ConversionTimer" to="." method="_on_timer_timeout"]
[connection signal="timeout" from="WorkingTimer" to="." method="_on_working_timer_timeout"]

View file

@ -0,0 +1,16 @@
extends Timer
class_name WorkingTimer
@export var working_sound: AudioStreamPlayer2D
func do_start():
if working_sound:
working_sound.play()
start()
func _on_timeout():
if working_sound:
working_sound.stop()

View file

@ -0,0 +1,10 @@
[gd_scene load_steps=2 format=3 uid="uid://b3ev0md0jrpfj"]
[ext_resource type="Script" path="res://converters/working_timer.gd" id="1_7a4bc"]
[node name="WorkingTimer" type="Timer"]
wait_time = 0.5
one_shot = true
script = ExtResource("1_7a4bc")
[connection signal="timeout" from="." to="." method="_on_timeout"]

View file

@ -23,8 +23,8 @@ var is_overlapping_with: Array[Node2D] = []:
return is_overlapping_with
set(value):
for body in is_overlapping_with:
# Make sure to re-modulate coins which have been collected
if body.is_instance_valid():
# Make sure to not re-modulate coins which have been collected
if is_instance_valid(body):
body.modulate = valid_color
for body in value:
body.modulate = invalid_color

View file

@ -139,7 +139,6 @@ item_cost_text = "40 silver"
item_scene = ExtResource("12_ml4jm")
item_cost_type = &"Silver"
item_cost_goal = 40
has_unlocked = false
[node name="PurchasableItemPadding2" parent="Rows/PaddedScrollable/Scrollable/ScrollableItems/ConvertCategory" instance=ExtResource("3_4feaj")]
layout_mode = 2

View file

@ -48,6 +48,7 @@ stretch = true
[node name="Viewport" type="SubViewport" parent="CustomUI/GameViewport"]
disable_3d = true
handle_input_locally = false
audio_listener_enable_2d = true
physics_object_picking = true
size = Vector2i(270, 480)
render_target_update_mode = 4

View file

@ -17,11 +17,6 @@ boot_splash/bg_color=Color(0.0977035, 0.0977035, 0.10161, 1)
boot_splash/image="res://icon.png"
config/icon="res://media/jar_icon.png"
[debug]
settings/stdout/print_fps=true
settings/stdout/print_gpu_profile=true
[display]
window/size/viewport_width=270

View file

@ -1,3 +0,0 @@
extends Node
class_name GemRandomizer
static var rng : RandomNumberGenerator = RandomNumberGenerator.new()

View file

@ -30,7 +30,7 @@ var buffer: int = 0
## Sound to play when spawning an item.
##
## Doesn't spawn anything if not set.
@export var sound_complete: AudioStreamPlayer
@export var sound_complete: AudioStreamPlayer2D
@export_range(0.01, 8.0, 0.01, "or_greater") var sound_complete_pitch_min: float = 1.00
@export_range(0.01, 8.0, 0.01, "or_greater") var sound_complete_pitch_max: float = 1.00
@ -68,7 +68,7 @@ func _do_spawn():
# print("ehi")
var instantiated = scene.instantiate()
instantiated.global_position = global_position + _select_spawn_position()
instantiated.rotation_degrees = _select_spawn_rotation()
instantiated.rotation_degrees = global_rotation_degrees + _select_spawn_rotation()
target.add_child(instantiated)
if sound_complete:
sound_complete.pitch_scale = Randomizer.rng.randf_range(sound_complete_pitch_min, sound_complete_pitch_max)