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

Fix stuffs

This commit is contained in:
Steffo 2023-10-02 23:43:42 +02:00
parent bfad133eb0
commit 9f779914b2
Signed by: steffo
GPG key ID: 2A24051445686895
10 changed files with 45 additions and 39 deletions

View file

@ -63,7 +63,7 @@ size = Vector2(26, 5)
size = Vector2(26, 10)
[node name="CopperConverter" type="StaticBody2D" node_paths=PackedStringArray("sprite_front", "conversion_timer", "sound_working", "sound_complete", "spawner")]
scale = Vector2(2, 2)
scale = Vector2(2.5, 2.5)
collision_layer = 8
collision_mask = 0
input_pickable = true

View file

@ -74,7 +74,7 @@ size = Vector2(26, 5)
size = Vector2(26, 10)
[node name="CoalDiamondConverter" type="StaticBody2D" node_paths=PackedStringArray("sprite_front", "conversion_timer", "sound_working", "sound_complete", "spawner", "spawner_alt")]
scale = Vector2(2, 2)
scale = Vector2(2.5, 2.5)
collision_layer = 8
collision_mask = 0
input_pickable = true
@ -113,6 +113,7 @@ z_index = 3
position = Vector2(0, 4.5)
rotation = 3.14159
shape = SubResource("RectangleShape2D_31dtl")
one_way_collision = true
[node name="Collector" parent="." instance=ExtResource("7_rxm8j")]
z_index = 2

View file

@ -71,7 +71,7 @@ size = Vector2(26, 5)
size = Vector2(26, 8.83334)
[node name="GoldConverter" type="StaticBody2D" node_paths=PackedStringArray("sprite_front", "conversion_timer", "sound_working", "sound_complete", "spawner")]
scale = Vector2(2, 2)
scale = Vector2(2.5, 2.5)
collision_layer = 8
collision_mask = 0
input_pickable = true
@ -109,6 +109,7 @@ z_index = 3
position = Vector2(0, 4.5)
rotation = 3.14159
shape = SubResource("RectangleShape2D_31dtl")
one_way_collision = true
[node name="Collector" parent="." instance=ExtResource("8_77gmi")]
z_index = 2

View file

@ -20,6 +20,40 @@ class_name ItemConverter
@onready var chalice_spawner = $ChaliceSpawner
@onready var crown_spawner = $CrownSpawner
var is_pending_deletion: bool = false
func pending_deletion():
sprite_front.modulate = Color.RED
is_pending_deletion = true
func ending_deletion():
sprite_front.modulate = Color.WHITE
is_pending_deletion = false
func _on_input_event(_viewport: Node, event: InputEvent, _shape_idx: int):
if is_pending_deletion:
if event is InputEventMouseButton or event is InputEventScreenTouch:
queue_free()
func _on_gem_collector_collected(body: RigidBody2D):
print("[ItemConverter] Collected gem: ", body)
var colored: Colored = body.get_node("CollisionShape2D/Sprite/Colored")
gem_hue_ready.append(colored.hue)
try_produce()
func _on_gold_collector_collected(body: RigidBody2D):
print("[ItemConverter] Collected gold: ", body)
stored_gold += 1
try_produce()
func try_produce():
if stored_gold >= required_gold:
var hue = gem_hue_ready.pop_back()
if hue:
stored_gold -= required_gold
gem_hue_stored.append(hue)
func _physics_process(_delta):
if conversion_timer.is_stopped():
var hue = gem_hue_stored.pop_front()
@ -33,11 +67,6 @@ func _physics_process(_delta):
if sound_working:
sound_working.play()
func try_produce():
if stored_gold >= required_gold and len(gem_hue_ready) >= 1:
stored_gold -= required_gold
gem_hue_stored.append(gem_hue_ready.pop_back())
func _on_timer_timeout():
var rand = Randomizer.rng.randf()
if rand <= crown_chance:
@ -53,31 +82,6 @@ func _on_timer_timeout():
if sound_working:
sound_working.stop()
var is_pending_deletion: bool = false
func pending_deletion():
sprite_front.modulate = Color.RED
is_pending_deletion = true
func ending_deletion():
sprite_front.modulate = Color.WHITE
is_pending_deletion = false
func _on_input_event(_viewport: Node, event: InputEvent, _shape_idx: int):
if is_pending_deletion:
if event is InputEventMouseButton or event is InputEventScreenTouch:
queue_free()
func _on_gem_collector_collected(body: RigidBody2D):
var colored: Colored = body.get_node("CollisionShape2D/Sprite/Colored")
gem_hue_ready.append(colored.hue)
try_produce()
func _on_gold_collector_collected(_body: RigidBody2D):
stored_gold += 1
try_produce()
func _on_spawner_spawned(what: RigidBody2D):
var hue = gem_hue_spawn.pop_front()
if not hue:

View file

@ -119,7 +119,7 @@ size = Vector2(26, 5)
size = Vector2(26, 8.83334)
[node name="ItemConverter" type="StaticBody2D"]
scale = Vector2(2, 2)
scale = Vector2(2.5, 2.5)
collision_layer = 8
collision_mask = 0
input_pickable = true
@ -151,6 +151,7 @@ z_index = 3
position = Vector2(0, 4.5)
rotation = 3.14159
shape = SubResource("RectangleShape2D_31dtl")
one_way_collision = true
[node name="GoldCollector" parent="." node_paths=PackedStringArray("sound_absorb") instance=ExtResource("3_qehi7")]
z_index = 2

View file

@ -47,7 +47,7 @@ size = Vector2(26, 5)
size = Vector2(26, 10)
[node name="SilverConverter" type="StaticBody2D" node_paths=PackedStringArray("sprite_front", "conversion_timer", "sound_working", "sound_complete", "spawner")]
scale = Vector2(2, 2)
scale = Vector2(2.5, 2.5)
collision_layer = 8
collision_mask = 0
input_pickable = true
@ -85,6 +85,7 @@ z_index = 3
position = Vector2(0, 4.5)
rotation = 3.14159
shape = SubResource("RectangleShape2D_31dtl")
one_way_collision = true
[node name="Collector" parent="." instance=ExtResource("7_3046q")]
z_index = 2

View file

@ -21,7 +21,6 @@ linear_damp = 0.1
angular_damp = 0.1
[node name="CollisionShape2D" type="CollisionPolygon2D" parent="."]
scale = Vector2(2, 2)
polygon = PackedVector2Array(0, -15, -11.5, -13, -10.5, -1, -2.5, 5, -2.5, 8, -8.5, 12, -4.5, 15, 4.5, 15, 8.5, 12, 2.5, 8, 2.5, 5, 10.5, -1, 11.5, -12.75)
[node name="Sprite2D" type="Sprite2D" parent="CollisionShape2D"]

View file

@ -25,7 +25,7 @@ linear_damp = 0.1
angular_damp = 0.1
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
scale = Vector2(4, 4)
scale = Vector2(0.75, 0.75)
shape = SubResource("CircleShape2D_058rf")
[node name="Sprite2D" type="Sprite2D" parent="CollisionShape2D"]

View file

@ -25,7 +25,6 @@ linear_damp = 0.1
angular_damp = 0.1
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
scale = Vector2(2, 2)
shape = SubResource("CapsuleShape2D_ka4h2")
[node name="Sprite2D" type="Sprite2D" parent="CollisionShape2D"]

View file

@ -12,7 +12,7 @@ collision_mask_prevent_placement = 16
collision_mask_delete_placement = 4
[node name="PlacementShape" parent="." instance=ExtResource("3_lskcf")]
scale = Vector2(2, 2)
scale = Vector2(2.5, 2.5)
[node name="PreviewSprite" type="Sprite2D" parent="PlacementShape"]
modulate = Color(1, 1, 1, 0.5)