1
Fork 0
mirror of https://github.com/Steffo99/swear-jar.git synced 2024-11-21 23:34:18 +00:00
This commit is contained in:
Maxim Lobovsky 2023-10-02 23:56:15 +02:00
commit e7d328c145
14 changed files with 82 additions and 42 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

@ -34,8 +34,8 @@ package/signed=true
package/app_category=2
package/retain_data_on_uninstall=false
package/exclude_from_recents=false
launcher_icons/main_192x192=""
launcher_icons/adaptive_foreground_432x432=""
launcher_icons/main_192x192="res://media/jar_icon.png"
launcher_icons/adaptive_foreground_432x432="res://media/jar_icon.png"
launcher_icons/adaptive_background_432x432=""
graphics/opengl_debug=false
xr_features/xr_mode=0

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)

34
media/jar_icon.png.import Normal file
View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b8moowo7t8ldj"
path="res://.godot/imported/jar_icon.png-72adba97c3a431a53ad66454ba774c72.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://media/jar_icon.png"
dest_files=["res://.godot/imported/jar_icon.png-72adba97c3a431a53ad66454ba774c72.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View file

@ -15,7 +15,7 @@ run/main_scene="res://main.tscn"
config/features=PackedStringArray("4.1", "Mobile")
boot_splash/bg_color=Color(0.0977035, 0.0977035, 0.10161, 1)
boot_splash/image="res://icon.png"
config/icon="res://icon.png"
config/icon="res://media/jar_icon.png"
[display]