summaryrefslogtreecommitdiff
path: root/Scenes/Entities
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-05-03 09:32:22 +0200
committerDaniel Weipert <git@mail.dweipert.de>2024-05-03 09:32:22 +0200
commit516d22c1737a9c94026b5ff0c9856bc5549aa416 (patch)
treecd9ef3089d1c8bdfc440b5673f7ad0d0dce787a9 /Scenes/Entities
parentd192b1546ab39180cdc28d2621c117539e3d26d6 (diff)
update
Diffstat (limited to 'Scenes/Entities')
-rw-r--r--Scenes/Entities/Bombs/Bomb.gd16
-rw-r--r--Scenes/Entities/Enemies/Balloon.gd20
-rw-r--r--Scenes/Entities/Enemies/Balloon.tscn31
-rw-r--r--Scenes/Entities/Enemies/Components/Collision.gd11
-rw-r--r--Scenes/Entities/Enemies/Components/Health.gd31
-rw-r--r--Scenes/Entities/Enemies/Components/Movement.gd16
-rw-r--r--Scenes/Entities/Enemies/Flowers.gd1
-rw-r--r--Scenes/Entities/Enemies/Flowers.tscn13
-rw-r--r--Scenes/Entities/Enemies/Slime.tscn29
-rw-r--r--Scenes/Entities/Enemies/Tree.gd12
-rw-r--r--Scenes/Entities/Enemies/Tree.tscn4
-rw-r--r--Scenes/Entities/Objects/Box.tscn1
-rw-r--r--Scenes/Entities/Objects/Button.gd13
-rw-r--r--Scenes/Entities/Objects/Button.tscn50
-rw-r--r--Scenes/Entities/Objects/Wood.tscn22
-rw-r--r--Scenes/Entities/Player.gd7
16 files changed, 236 insertions, 41 deletions
diff --git a/Scenes/Entities/Bombs/Bomb.gd b/Scenes/Entities/Bombs/Bomb.gd
index 4256fc5..97fbf4f 100644
--- a/Scenes/Entities/Bombs/Bomb.gd
+++ b/Scenes/Entities/Bombs/Bomb.gd
@@ -16,7 +16,7 @@ enum COMPONENT_TYPE {
}
-var Explosion = preload("res://Scenes/Entities/Bombs/Explosion.tscn")
+var ExplosionScene = preload("res://Scenes/Entities/Bombs/Explosion.tscn")
var power: int = 2
var components: Array[COMPONENT_TYPE] = []
@@ -60,17 +60,21 @@ func explode():
var direction = directions[j]
for i in range(self.get_power()):
+ var from = Utilities.from_grid_to_position(
+ Utilities.from_position_to_grid(self.global_position) + (direction * i)
+ )
var to = Utilities.from_grid_to_position(
Utilities.from_position_to_grid(self.global_position) + (direction * (i + 1))
)
- var query = PhysicsPointQueryParameters2D.new()
- query.set_position(to)
+ var query = PhysicsRayQueryParameters2D.new()
+ query.set_from(from)
+ query.set_to(to)
query.set_collision_mask(explosion.collision_mask)
- var explosion_intersection = get_world_2d().direct_space_state.intersect_point(query)
+ var explosion_intersection = get_world_2d().direct_space_state.intersect_ray(query)
if explosion_intersection:
- var collider = explosion_intersection[0].collider
+ var collider = explosion_intersection.collider
# call collision function and get collision type
var collision_type
@@ -120,7 +124,7 @@ func get_power():
func spawn_explosion(spawn_position: Vector2):
- var explosion = Explosion.instantiate()
+ var explosion = ExplosionScene.instantiate()
explosion.position = spawn_position
get_tree().get_current_scene().add_child(explosion)
diff --git a/Scenes/Entities/Enemies/Balloon.gd b/Scenes/Entities/Enemies/Balloon.gd
index 7c4b402..ec41822 100644
--- a/Scenes/Entities/Enemies/Balloon.gd
+++ b/Scenes/Entities/Enemies/Balloon.gd
@@ -1,27 +1,15 @@
extends CharacterBody2D
+@onready var component_collision: ComponentCollision = $Collision
+@onready var component_movement: ComponentMovement = $Movement
func _ready():
add_to_group("enemies")
- get_node("Collision").init()
-
- get_node("Movement").connect("direction_changed", func(current_direction):
- var frame = $AnimatedSprite2D.frame
- var progress = $AnimatedSprite2D.frame_progress
- if current_direction == Vector2.UP:
- $AnimatedSprite2D.play("up")
- elif current_direction == Vector2.DOWN:
- $AnimatedSprite2D.play("down")
- elif current_direction == Vector2.LEFT:
- $AnimatedSprite2D.play("left")
- elif current_direction == Vector2.RIGHT:
- $AnimatedSprite2D.play("right")
- $AnimatedSprite2D.set_frame_and_progress(frame, progress)
- )
+ component_collision.init()
func _physics_process(delta):
- get_node("Movement").physics_process(delta)
+ component_movement.physics_process(delta)
# todo: animation shadow
diff --git a/Scenes/Entities/Enemies/Balloon.tscn b/Scenes/Entities/Enemies/Balloon.tscn
index a9a2cec..9e1a6bc 100644
--- a/Scenes/Entities/Enemies/Balloon.tscn
+++ b/Scenes/Entities/Enemies/Balloon.tscn
@@ -1,12 +1,17 @@
-[gd_scene load_steps=20 format=3 uid="uid://ccolri3egf8rk"]
+[gd_scene load_steps=25 format=3 uid="uid://ccolri3egf8rk"]
[ext_resource type="Script" path="res://Scenes/Entities/Enemies/Balloon.gd" id="1_8q3w8"]
[ext_resource type="Texture2D" uid="uid://ck1sxw5vqhoa" path="res://Assets/Enemies/Balloon_death_2.png" id="2_c4j5c"]
[ext_resource type="Texture2D" uid="uid://b1mr0hh682o5o" path="res://Assets/Enemies/Balloon_down_2_01.png" id="3_pcii7"]
+[ext_resource type="Texture2D" uid="uid://cpl4n4jmgiwrv" path="res://Assets/Enemies/Enemy_death_01_01.png" id="3_ue08m"]
[ext_resource type="Texture2D" uid="uid://bqjxycrl7qh2s" path="res://Assets/Enemies/Balloon_down_2_02.png" id="4_3eanq"]
+[ext_resource type="Texture2D" uid="uid://d2gk5amafhctu" path="res://Assets/Enemies/Enemy_death_01_02.png" id="4_38531"]
+[ext_resource type="Texture2D" uid="uid://dqwxq3g3aph4i" path="res://Assets/Enemies/Enemy_death_01_03.png" id="5_q6h7x"]
[ext_resource type="Texture2D" uid="uid://ciku28v7q6a2q" path="res://Assets/Enemies/Balloon_down_2_03.png" id="5_vhsnp"]
+[ext_resource type="Texture2D" uid="uid://uoj5222vlq8q" path="res://Assets/Enemies/Enemy_death_01_04.png" id="6_nyfwy"]
[ext_resource type="Texture2D" uid="uid://di8wp5yyn36uj" path="res://Assets/Enemies/Balloon_left_2_01.png" id="6_ykdih"]
[ext_resource type="Texture2D" uid="uid://c0qju385rrnvv" path="res://Assets/Enemies/Balloon_left_2_02.png" id="7_81kws"]
+[ext_resource type="Texture2D" uid="uid://cxx2vv1ohiw07" path="res://Assets/Enemies/Enemy_death_01_05.png" id="7_sjn47"]
[ext_resource type="Texture2D" uid="uid://bgjm6vhpdxgbe" path="res://Assets/Enemies/Balloon_left_2_03.png" id="8_7eum3"]
[ext_resource type="Texture2D" uid="uid://cjqjq1ppdhoxe" path="res://Assets/Enemies/Balloon_right_2_01.png" id="9_doy2d"]
[ext_resource type="Texture2D" uid="uid://dmsxbrwqju44n" path="res://Assets/Enemies/Balloon_right_2_02.png" id="10_xyola"]
@@ -30,6 +35,26 @@ animations = [{
}, {
"frames": [{
"duration": 1.0,
+"texture": ExtResource("3_ue08m")
+}, {
+"duration": 1.0,
+"texture": ExtResource("4_38531")
+}, {
+"duration": 1.0,
+"texture": ExtResource("5_q6h7x")
+}, {
+"duration": 1.0,
+"texture": ExtResource("6_nyfwy")
+}, {
+"duration": 1.0,
+"texture": ExtResource("7_sjn47")
+}],
+"loop": false,
+"name": &"death_post",
+"speed": 5.0
+}, {
+"frames": [{
+"duration": 1.0,
"texture": ExtResource("3_pcii7")
}, {
"duration": 1.0,
@@ -103,11 +128,12 @@ height = 15.0
[node name="Balloon" type="CharacterBody2D"]
collision_layer = 16
-collision_mask = 188
+collision_mask = 172
motion_mode = 1
script = ExtResource("1_8q3w8")
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
+texture_filter = 1
sprite_frames = SubResource("SpriteFrames_nxaqi")
animation = &"down"
@@ -129,4 +155,5 @@ component_health_path = NodePath("../Health")
[node name="Health" parent="." instance=ExtResource("17_d8phm")]
entityPath = NodePath("..")
spritePath = NodePath("../AnimatedSprite2D")
+component_movement_path = NodePath("../Movement")
health = 1
diff --git a/Scenes/Entities/Enemies/Components/Collision.gd b/Scenes/Entities/Enemies/Components/Collision.gd
index 6e25402..5a82c31 100644
--- a/Scenes/Entities/Enemies/Components/Collision.gd
+++ b/Scenes/Entities/Enemies/Components/Collision.gd
@@ -1,7 +1,6 @@
+class_name ComponentCollision
extends Node
-class_name Component_Collision
-
signal collided
@@ -11,8 +10,8 @@ signal collided
@export_node_path("CollisionShape2D") var collision_shape_path: NodePath
@onready var collision_shape: CollisionShape2D = get_node(collision_shape_path)
-@export_node_path("Component_Health") var component_health_path: NodePath
-var component_health: Component_Health
+@export_node_path("ComponentHealth") var component_health_path: NodePath
+var component_health: ComponentHealth
var collision_area: Area2D
@@ -29,3 +28,7 @@ func init():
if area.is_in_group("explosions"):
component_health.take_damage()
)
+ component_health.died.connect(func():
+ collision_area.set_collision_layer_value(Utilities.Collision.Layer.ENEMY, false)
+ collision_area.set_collision_mask_value(Utilities.Collision.Layer.PLAYER, false)
+ )
diff --git a/Scenes/Entities/Enemies/Components/Health.gd b/Scenes/Entities/Enemies/Components/Health.gd
index d6b7361..6f65e79 100644
--- a/Scenes/Entities/Enemies/Components/Health.gd
+++ b/Scenes/Entities/Enemies/Components/Health.gd
@@ -1,7 +1,6 @@
+class_name ComponentHealth
extends Node
-class_name Component_Health
-
signal died
@@ -11,8 +10,22 @@ signal died
@export_node_path("AnimatedSprite2D") var spritePath: NodePath
@onready var sprite: AnimatedSprite2D = get_node(spritePath)
+@export_node_path("ComponentMovement") var component_movement_path: NodePath
+var component_movement: ComponentMovement
+
@export var health: int
+@export var drops_items: bool = true
+@export_range(1, 100) var drop_chance: int = 30
+var drop_items = [
+ preload("res://Scenes/Entities/Objects/Coin.tscn"),
+]
+
+
+func _ready():
+ if component_movement_path:
+ component_movement = get_node(component_movement_path)
+
func take_damage():
health -= 1
@@ -24,11 +37,14 @@ func take_damage():
func death():
emit_signal("died")
- entity.set_physics_process(false)
+ if component_movement: # stop all movement
+ component_movement.process_mode = Node.PROCESS_MODE_DISABLED
+ entity.set_physics_process(false)
sprite.play("death")
await sprite.animation_finished
+ assert(sprite.sprite_frames.has_animation("death_post"))
sprite.play("death_post")
var tween: Tween = get_tree().create_tween()
@@ -39,5 +55,14 @@ func death():
1 / sprite.sprite_frames.get_animation_speed("death_post")
)
tween.tween_callback(func():
+ if drops_items and randi_range(1, 100) <= drop_chance:
+ call_deferred("drop_item")
+
entity.queue_free()
)
+
+
+func drop_item():
+ var item = drop_items.pick_random().instantiate()
+ item.position = entity.position
+ get_tree().current_scene.add_child(item)
diff --git a/Scenes/Entities/Enemies/Components/Movement.gd b/Scenes/Entities/Enemies/Components/Movement.gd
index 28b374d..5470a7d 100644
--- a/Scenes/Entities/Enemies/Components/Movement.gd
+++ b/Scenes/Entities/Enemies/Components/Movement.gd
@@ -1,3 +1,4 @@
+class_name ComponentMovement
extends Node
@@ -41,7 +42,7 @@ func physics_process(delta):
sprite.play("down")
elif CURRENT_DIRECTION == Vector2.LEFT:
entity.velocity.x -= SPEED
- if sprite.sprite_frames.has_animation("leftup"):
+ if sprite.sprite_frames.has_animation("left"):
sprite.play("left")
elif CURRENT_DIRECTION == Vector2.RIGHT:
entity.velocity.x += SPEED
@@ -96,4 +97,17 @@ func _on_movement_timer_timeout():
emit_signal("direction_changed", CURRENT_DIRECTION)
LAST_DIRECTION = CURRENT_DIRECTION
+ if not sprite.sprite_frames.has_animation("default"):
+ var frame = sprite.frame
+ var progress = sprite.frame_progress
+ if CURRENT_DIRECTION == Vector2.UP and sprite.sprite_frames.has_animation("up"):
+ sprite.play("up")
+ elif CURRENT_DIRECTION == Vector2.DOWN and sprite.sprite_frames.has_animation("down"):
+ sprite.play("down")
+ elif CURRENT_DIRECTION == Vector2.LEFT and sprite.sprite_frames.has_animation("left"):
+ sprite.play("left")
+ elif CURRENT_DIRECTION == Vector2.RIGHT and sprite.sprite_frames.has_animation("right"):
+ sprite.play("right")
+ sprite.set_frame_and_progress(frame, progress)
+
MovementTimer.start()
diff --git a/Scenes/Entities/Enemies/Flowers.gd b/Scenes/Entities/Enemies/Flowers.gd
index 09e6085..d18a244 100644
--- a/Scenes/Entities/Enemies/Flowers.gd
+++ b/Scenes/Entities/Enemies/Flowers.gd
@@ -20,6 +20,7 @@ var flowers: Array = []
func _ready():
$Timer.wait_time = mode_duration
+ $CollisionShape2D.shape.radius = max_radius + 16 # + tile width
var FlowerScene = preload("res://Scenes/Entities/Enemies/Flower.tscn")
diff --git a/Scenes/Entities/Enemies/Flowers.tscn b/Scenes/Entities/Enemies/Flowers.tscn
index 91c54d4..82c1f70 100644
--- a/Scenes/Entities/Enemies/Flowers.tscn
+++ b/Scenes/Entities/Enemies/Flowers.tscn
@@ -1,12 +1,16 @@
[gd_scene load_steps=4 format=3 uid="uid://cplelcvju50xj"]
[ext_resource type="Script" path="res://Scenes/Entities/Enemies/Flowers.gd" id="1_a4wuh"]
-[ext_resource type="Texture2D" uid="uid://bbo73owb43h0e" path="res://icon.svg" id="2_womd7"]
[sub_resource type="CircleShape2D" id="CircleShape2D_2a0s2"]
radius = 64.0
+[sub_resource type="CircleShape2D" id="CircleShape2D_y4xm5"]
+radius = 8.0
+
[node name="Flowers" type="CharacterBody2D"]
+collision_layer = 0
+collision_mask = 136
motion_mode = 1
script = ExtResource("1_a4wuh")
@@ -17,13 +21,12 @@ collision_mask = 2
[node name="CollisionShape2D" type="CollisionShape2D" parent="DetectionArea"]
shape = SubResource("CircleShape2D_2a0s2")
-[node name="Sprite2D" type="Sprite2D" parent="."]
-scale = Vector2(0.0625, 0.0625)
-texture = ExtResource("2_womd7")
-
[node name="Timer" type="Timer" parent="."]
autostart = true
+[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
+shape = SubResource("CircleShape2D_y4xm5")
+
[connection signal="body_entered" from="DetectionArea" to="." method="_on_detection_area_body_entered"]
[connection signal="body_exited" from="DetectionArea" to="." method="_on_detection_area_body_exited"]
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]
diff --git a/Scenes/Entities/Enemies/Slime.tscn b/Scenes/Entities/Enemies/Slime.tscn
index f30d161..50927b3 100644
--- a/Scenes/Entities/Enemies/Slime.tscn
+++ b/Scenes/Entities/Enemies/Slime.tscn
@@ -1,11 +1,16 @@
-[gd_scene load_steps=11 format=3 uid="uid://d3evry1ketf0s"]
+[gd_scene load_steps=16 format=3 uid="uid://d3evry1ketf0s"]
[ext_resource type="Script" path="res://Scenes/Entities/Enemies/Slime.gd" id="1_2xftl"]
[ext_resource type="Texture2D" uid="uid://ca7oars0vec8k" path="res://Assets/Enemies/Slime_death.png" id="2_mqou3"]
[ext_resource type="Texture2D" uid="uid://b88dvu2ridy4t" path="res://Assets/Enemies/Slime_01.png" id="3_20mej"]
+[ext_resource type="Texture2D" uid="uid://cpl4n4jmgiwrv" path="res://Assets/Enemies/Enemy_death_01_01.png" id="3_fd7f8"]
+[ext_resource type="Texture2D" uid="uid://d2gk5amafhctu" path="res://Assets/Enemies/Enemy_death_01_02.png" id="4_pgm70"]
[ext_resource type="Texture2D" uid="uid://bndhg7wom64mq" path="res://Assets/Enemies/Slime_02.png" id="4_r6mjl"]
+[ext_resource type="Texture2D" uid="uid://dqwxq3g3aph4i" path="res://Assets/Enemies/Enemy_death_01_03.png" id="5_0pqwp"]
[ext_resource type="Texture2D" uid="uid://dh7vaujrw6i26" path="res://Assets/Enemies/Slime_03.png" id="5_mm7vy"]
+[ext_resource type="Texture2D" uid="uid://uoj5222vlq8q" path="res://Assets/Enemies/Enemy_death_01_04.png" id="6_dllhk"]
[ext_resource type="PackedScene" uid="uid://cq7yj2av01tqd" path="res://Scenes/Entities/Enemies/Components/Movement.tscn" id="6_u48ct"]
+[ext_resource type="Texture2D" uid="uid://cxx2vv1ohiw07" path="res://Assets/Enemies/Enemy_death_01_05.png" id="7_iujdy"]
[ext_resource type="PackedScene" uid="uid://ce3vv2pod6auc" path="res://Scenes/Entities/Enemies/Components/Collision.tscn" id="7_kjjor"]
[ext_resource type="PackedScene" uid="uid://b3i372vgdbxk" path="res://Scenes/Entities/Enemies/Components/Health.tscn" id="8_klsy3"]
@@ -20,6 +25,26 @@ animations = [{
}],
"loop": false,
"name": &"death",
+"speed": 1.0
+}, {
+"frames": [{
+"duration": 1.0,
+"texture": ExtResource("3_fd7f8")
+}, {
+"duration": 1.0,
+"texture": ExtResource("4_pgm70")
+}, {
+"duration": 1.0,
+"texture": ExtResource("5_0pqwp")
+}, {
+"duration": 1.0,
+"texture": ExtResource("6_dllhk")
+}, {
+"duration": 1.0,
+"texture": ExtResource("7_iujdy")
+}],
+"loop": false,
+"name": &"death_post",
"speed": 2.0
}, {
"frames": [{
@@ -49,6 +74,7 @@ script = ExtResource("1_2xftl")
shape = SubResource("CircleShape2D_f54tg")
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
+texture_filter = 1
sprite_frames = SubResource("SpriteFrames_4e1a7")
[node name="Movement" parent="." instance=ExtResource("6_u48ct")]
@@ -65,4 +91,5 @@ component_health_path = NodePath("../Health")
[node name="Health" parent="." instance=ExtResource("8_klsy3")]
entityPath = NodePath("..")
spritePath = NodePath("../AnimatedSprite2D")
+component_movement_path = NodePath("../Movement")
health = 1
diff --git a/Scenes/Entities/Enemies/Tree.gd b/Scenes/Entities/Enemies/Tree.gd
index db78788..5572e02 100644
--- a/Scenes/Entities/Enemies/Tree.gd
+++ b/Scenes/Entities/Enemies/Tree.gd
@@ -1,11 +1,17 @@
extends CharacterBody2D
+@onready var component_collision: ComponentCollision = $Collision
+@onready var component_movement: ComponentMovement = $Movement
+
+
func _ready():
add_to_group("enemies")
- get_node("Collision").init()
+ component_collision.init()
+ component_collision.collision_area.set_collision_mask_value(Utilities.Collision.Layer.EXPLOSION, false)
+ component_movement.process_mode = Node.PROCESS_MODE_DISABLED
set_physics_process(false)
$AnimatedSprite2D.play("spawn")
$AnimatedSprite2D.stop()
@@ -13,10 +19,12 @@ func _ready():
func _physics_process(delta):
- get_node("Movement").physics_process(delta)
+ component_movement.physics_process(delta)
func _on_detection_body_entered(_body):
$AnimatedSprite2D.play("spawn")
await $AnimatedSprite2D.animation_finished
+ component_collision.collision_area.set_collision_mask_value(Utilities.Collision.Layer.EXPLOSION, true)
+ component_movement.process_mode = Node.PROCESS_MODE_INHERIT
set_physics_process(true)
diff --git a/Scenes/Entities/Enemies/Tree.tscn b/Scenes/Entities/Enemies/Tree.tscn
index aedc79f..3a0de4a 100644
--- a/Scenes/Entities/Enemies/Tree.tscn
+++ b/Scenes/Entities/Enemies/Tree.tscn
@@ -51,7 +51,7 @@ animations = [{
"duration": 1.0,
"texture": ExtResource("7_n5hht")
}],
-"loop": true,
+"loop": false,
"name": &"death_post",
"speed": 2.0
}, {
@@ -138,6 +138,7 @@ collision_mask = 188
script = ExtResource("1_ktvfx")
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
+texture_filter = 1
position = Vector2(0, -8)
sprite_frames = SubResource("SpriteFrames_c5ryj")
animation = &"spawn"
@@ -162,6 +163,7 @@ component_health_path = NodePath("../Health")
[node name="Health" parent="." instance=ExtResource("19_u7yi8")]
entityPath = NodePath("..")
spritePath = NodePath("../AnimatedSprite2D")
+component_movement_path = NodePath("../Movement")
health = 1
[node name="Detection" type="Area2D" parent="."]
diff --git a/Scenes/Entities/Objects/Box.tscn b/Scenes/Entities/Objects/Box.tscn
index 2e02d75..eda0e6a 100644
--- a/Scenes/Entities/Objects/Box.tscn
+++ b/Scenes/Entities/Objects/Box.tscn
@@ -88,6 +88,7 @@ _data = {
}
[node name="Box" type="StaticBody2D"]
+texture_filter = 1
collision_layer = 8
collision_mask = 32
script = ExtResource("1_owgyi")
diff --git a/Scenes/Entities/Objects/Button.gd b/Scenes/Entities/Objects/Button.gd
new file mode 100644
index 0000000..f028440
--- /dev/null
+++ b/Scenes/Entities/Objects/Button.gd
@@ -0,0 +1,13 @@
+extends Area2D
+
+
+signal pressed
+
+var is_pressed: bool = false
+
+
+func _on_body_entered(body):
+ if body is Player and not is_pressed:
+ is_pressed = true
+ $AnimatedSprite2D.play("pressed")
+ emit_signal("pressed")
diff --git a/Scenes/Entities/Objects/Button.tscn b/Scenes/Entities/Objects/Button.tscn
new file mode 100644
index 0000000..0416167
--- /dev/null
+++ b/Scenes/Entities/Objects/Button.tscn
@@ -0,0 +1,50 @@
+[gd_scene load_steps=7 format=3 uid="uid://8fbkdifli6ic"]
+
+[ext_resource type="Script" path="res://Scenes/Entities/Objects/Button.gd" id="1_83jjd"]
+[ext_resource type="Texture2D" uid="uid://b6ce2eihxulqb" path="res://Assets/Stages/core_set pieces.png" id="2_frejs"]
+
+[sub_resource type="RectangleShape2D" id="RectangleShape2D_xgggr"]
+size = Vector2(12, 7)
+
+[sub_resource type="AtlasTexture" id="AtlasTexture_t47kb"]
+atlas = ExtResource("2_frejs")
+region = Rect2(272, 512, 16, 16)
+
+[sub_resource type="AtlasTexture" id="AtlasTexture_6om1g"]
+atlas = ExtResource("2_frejs")
+region = Rect2(288, 512, 16, 16)
+
+[sub_resource type="SpriteFrames" id="SpriteFrames_moi56"]
+animations = [{
+"frames": [{
+"duration": 1.0,
+"texture": SubResource("AtlasTexture_t47kb")
+}],
+"loop": false,
+"name": &"default",
+"speed": 1.0
+}, {
+"frames": [{
+"duration": 1.0,
+"texture": SubResource("AtlasTexture_6om1g")
+}],
+"loop": false,
+"name": &"pressed",
+"speed": 1.0
+}]
+
+[node name="Button" type="Area2D"]
+z_index = -1
+collision_layer = 64
+collision_mask = 2
+script = ExtResource("1_83jjd")
+
+[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
+position = Vector2(0, 1.5)
+shape = SubResource("RectangleShape2D_xgggr")
+
+[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
+texture_filter = 1
+sprite_frames = SubResource("SpriteFrames_moi56")
+
+[connection signal="body_entered" from="." to="." method="_on_body_entered"]
diff --git a/Scenes/Entities/Objects/Wood.tscn b/Scenes/Entities/Objects/Wood.tscn
new file mode 100644
index 0000000..23ba656
--- /dev/null
+++ b/Scenes/Entities/Objects/Wood.tscn
@@ -0,0 +1,22 @@
+[gd_scene load_steps=3 format=3 uid="uid://b2xpm8k3chbae"]
+
+[ext_resource type="Texture2D" uid="uid://cctukh2hhfgty" path="res://Assets/Stages/core_outdoor_nature.png" id="1_khy0w"]
+
+[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_1je2f"]
+radius = 7.0
+height = 60.0
+
+[node name="Wood" type="StaticBody2D"]
+z_index = -1
+y_sort_enabled = true
+collision_layer = 8
+collision_mask = 30
+
+[node name="Sprite2D" type="Sprite2D" parent="."]
+texture_filter = 1
+texture = ExtResource("1_khy0w")
+region_enabled = true
+region_rect = Rect2(912, 0, 16, 64)
+
+[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
+shape = SubResource("CapsuleShape2D_1je2f")
diff --git a/Scenes/Entities/Player.gd b/Scenes/Entities/Player.gd
index ba404fe..77dfac5 100644
--- a/Scenes/Entities/Player.gd
+++ b/Scenes/Entities/Player.gd
@@ -95,6 +95,10 @@ func _process(delta):
self.DIRECTION = Vector2.DOWN
self.DIRECTIONS.append(Vector2.DOWN)
+ var last_animation = $AnimatedSprite2D.animation
+ var frame = $AnimatedSprite2D.frame
+ var progress = $AnimatedSprite2D.frame_progress
+
if velocity.x < 0 && velocity.y == 0:
$AnimatedSprite2D.play("left")
elif velocity.x > 0 && velocity.y == 0:
@@ -130,6 +134,9 @@ func _process(delta):
elif self.LAST_DIRECTIONS == [Vector2.RIGHT, Vector2.DOWN]:
$AnimatedSprite2D.play("idle_bottom_right")
+ if last_animation != $AnimatedSprite2D.animation:
+ $AnimatedSprite2D.set_frame_and_progress(frame, progress)
+
self.LAST_DIRECTIONS = self.DIRECTIONS
if Input.is_action_just_pressed("ui_accept"):