summaryrefslogtreecommitdiff
path: root/Scenes/Entities
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-07-19 14:24:09 +0200
committerDaniel Weipert <git@mail.dweipert.de>2024-07-19 14:24:09 +0200
commit294f87adb4441ec25316601505ca1a7e97fa24c7 (patch)
treee48ed54e97f19ae5dd189ee42ddb73c4e995175f /Scenes/Entities
parent06647b11ee163bc40daf454d87e1fcae563c3ced (diff)
update
Diffstat (limited to 'Scenes/Entities')
-rw-r--r--Scenes/Entities/Bombs/Bomb.gd5
-rw-r--r--Scenes/Entities/Bombs/Bomb__Breakables.tscn2
-rw-r--r--Scenes/Entities/Bombs/Bomb__Normal.tscn2
-rw-r--r--Scenes/Entities/Enemies/Balloon.gd6
-rw-r--r--Scenes/Entities/Enemies/Balloon.tscn2
-rw-r--r--Scenes/Entities/Enemies/Components/Health.gd37
-rw-r--r--Scenes/Entities/Enemies/Components/Movement.gd281
-rw-r--r--Scenes/Entities/Enemies/Flower.gd5
-rw-r--r--Scenes/Entities/Enemies/Flowers.gd5
-rw-r--r--Scenes/Entities/Enemies/Slime.gd8
-rw-r--r--Scenes/Entities/Enemies/Slime.tscn17
-rw-r--r--Scenes/Entities/Enemies/Snake.gd15
-rw-r--r--Scenes/Entities/Enemies/Snake.tscn1
-rw-r--r--Scenes/Entities/Enemies/Tree.gd16
-rw-r--r--Scenes/Entities/Enemies/Tree.tscn7
-rw-r--r--Scenes/Entities/Player.gd2
-rw-r--r--Scenes/Entities/Player.tscn136
17 files changed, 347 insertions, 200 deletions
diff --git a/Scenes/Entities/Bombs/Bomb.gd b/Scenes/Entities/Bombs/Bomb.gd
index 0456c15..4a4e901 100644
--- a/Scenes/Entities/Bombs/Bomb.gd
+++ b/Scenes/Entities/Bombs/Bomb.gd
@@ -1,6 +1,5 @@
-extends CharacterBody2D
-
class_name Bomb
+extends CharacterBody2D
signal body_exited
@@ -144,7 +143,7 @@ func _collide(area: Area2D):
call_deferred("explode")
-func _on_Timer_timeout():
+func _on_timer_timeout():
self.explode()
diff --git a/Scenes/Entities/Bombs/Bomb__Breakables.tscn b/Scenes/Entities/Bombs/Bomb__Breakables.tscn
index a4bb192..92a4900 100644
--- a/Scenes/Entities/Bombs/Bomb__Breakables.tscn
+++ b/Scenes/Entities/Bombs/Bomb__Breakables.tscn
@@ -47,4 +47,4 @@ wait_time = 4.0
one_shot = true
autostart = true
-[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]
+[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]
diff --git a/Scenes/Entities/Bombs/Bomb__Normal.tscn b/Scenes/Entities/Bombs/Bomb__Normal.tscn
index d42223e..cb6813a 100644
--- a/Scenes/Entities/Bombs/Bomb__Normal.tscn
+++ b/Scenes/Entities/Bombs/Bomb__Normal.tscn
@@ -47,4 +47,4 @@ wait_time = 4.0
one_shot = true
autostart = true
-[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]
+[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]
diff --git a/Scenes/Entities/Enemies/Balloon.gd b/Scenes/Entities/Enemies/Balloon.gd
index ec41822..179dda7 100644
--- a/Scenes/Entities/Enemies/Balloon.gd
+++ b/Scenes/Entities/Enemies/Balloon.gd
@@ -7,9 +7,11 @@ func _ready():
add_to_group("enemies")
component_collision.init()
+ component_movement.init()
-func _physics_process(delta):
- component_movement.physics_process(delta)
+#func _physics_process(delta):
+ #pass
+ #component_movement.physics_process(delta)
# todo: animation shadow
diff --git a/Scenes/Entities/Enemies/Balloon.tscn b/Scenes/Entities/Enemies/Balloon.tscn
index c1b0701..4100d54 100644
--- a/Scenes/Entities/Enemies/Balloon.tscn
+++ b/Scenes/Entities/Enemies/Balloon.tscn
@@ -144,7 +144,7 @@ shape = SubResource("CapsuleShape2D_abul4")
[node name="Movement" parent="." instance=ExtResource("15_fwetl")]
entityPath = NodePath("..")
spritePath = NodePath("../AnimatedSprite2D")
-SPEED = 10.0
+SPEED = 0.7
timer_time = 10.0
[node name="Collision" parent="." instance=ExtResource("16_yau34")]
diff --git a/Scenes/Entities/Enemies/Components/Health.gd b/Scenes/Entities/Enemies/Components/Health.gd
index 2bd2447..00bf9e0 100644
--- a/Scenes/Entities/Enemies/Components/Health.gd
+++ b/Scenes/Entities/Enemies/Components/Health.gd
@@ -2,6 +2,7 @@ class_name ComponentHealth
extends Node
+signal hit
signal died
@export_node_path("CharacterBody2D") var entityPath: NodePath
@@ -21,7 +22,8 @@ var drop_items = [
preload("res://Scenes/Entities/Objects/Coin.tscn"),
]
-var is_dying = false
+@export var invincibility_timeout: float = 1.0
+var is_invincible = false
func _ready():
@@ -30,23 +32,38 @@ func _ready():
func take_damage():
+ if is_invincible:
+ return
+
+ emit_signal("hit")
+
health -= 1
- if health <= 0 and not is_dying:
+ is_invincible = true
+ if component_movement: # stop all movement
+ component_movement.pause()
+
+ sprite.play("death")
+ await sprite.animation_finished
+
+ if health <= 0:
death()
+ else:
+ if component_movement: # resume all movement
+ component_movement.unpause()
+
+ #var flicker_speed = 0.2
+ #var tween = create_tween().set_loops(invincibility_timeout / (flicker_speed*2))
+ #tween.tween_property(sprite, "modulate", Color(1, 1, 1, 0.5), flicker_speed)
+ #tween.tween_property(sprite, "modulate", Color(1, 1, 1, 1), flicker_speed)
+ #
+ #await get_tree().create_timer(invincibility_timeout).timeout
+ is_invincible = false
func death():
- is_dying = true
emit_signal("died")
- 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")
diff --git a/Scenes/Entities/Enemies/Components/Movement.gd b/Scenes/Entities/Enemies/Components/Movement.gd
index 3174508..98fb43a 100644
--- a/Scenes/Entities/Enemies/Components/Movement.gd
+++ b/Scenes/Entities/Enemies/Components/Movement.gd
@@ -10,11 +10,14 @@ signal direction_changed
@export_node_path("AnimatedSprite2D") var spritePath: NodePath
@onready var sprite: AnimatedSprite2D = get_node(spritePath)
-@export var SPEED: float
+@export_node_path("ComponentCollision") var component_collision_path: NodePath
+var component_collision: ComponentCollision
+
+@export_range(0, 2, 0.01) var SPEED: float
const DIRECTIONS = [Vector2.UP, Vector2.RIGHT, Vector2.DOWN, Vector2.LEFT]
var CURRENT_DIRECTION = Vector2.UP
-var LAST_DIRECTION = Vector2.UP
+var FIXED_DIRECTION = null
var was_colliding = false
var animations: Dictionary = {
@@ -24,6 +27,11 @@ var animations: Dictionary = {
"left": "left",
"right": "right",
}
+var CURRENT_ANIMATION = {
+ "name": "default",
+ "frame": 0,
+ "progress": 0,
+}
@export var timer_time: float = 3.0
@onready var MovementTimer: Timer = Timer.new()
@@ -31,101 +39,183 @@ var animations: Dictionary = {
@export var follows: bool = false
@export_range(1, 100, 1) var follow_chance: int = 100
+var is_paused = false
-func _ready():
- MovementTimer.wait_time = timer_time
- MovementTimer.autostart = true
- MovementTimer.connect("timeout", Callable(_on_movement_timer_timeout))
- add_child(MovementTimer)
+var tween: Tween
-func physics_process(delta):
- if CURRENT_DIRECTION == Vector2.UP:
- entity.velocity.y -= SPEED/2
- if sprite.sprite_frames.has_animation(animations["up"]):
- sprite.play(animations["up"])
- elif CURRENT_DIRECTION == Vector2.DOWN:
- entity.velocity.y += SPEED/2
- if sprite.sprite_frames.has_animation(animations["down"]):
- sprite.play(animations["down"])
- elif CURRENT_DIRECTION == Vector2.LEFT:
- entity.velocity.x -= SPEED/2
- if sprite.sprite_frames.has_animation(animations["left"]):
- sprite.play(animations["left"])
- elif CURRENT_DIRECTION == Vector2.RIGHT:
- entity.velocity.x += SPEED/2
- if sprite.sprite_frames.has_animation(animations["right"]):
- sprite.play(animations["right"])
-
- if sprite.sprite_frames.has_animation(animations["default"]):
- sprite.play(animations["default"])
-
- var collision = entity.move_and_collide(entity.velocity * delta)
- entity.velocity = entity.velocity.lerp(Vector2(0, 0), 1) # speed too low => no collision
-
- # todo movement along grid (maybe move position to current tile center)
- var target_grid_position = Utilities.from_grid_to_position(Utilities.get_level_position(entity) + CURRENT_DIRECTION)
- entity.position = entity.position.move_toward(target_grid_position, delta*SPEED/2)
- # todo or set velocity to tiles per SPEED per second somehow, instead of Timer
-
- if collision:
- was_colliding = true
- if MovementTimer.time_left > 0:
- _on_movement_timer_timeout()
- else:
- was_colliding = false
+func _ready():
+ #MovementTimer.wait_time = timer_time
+ #MovementTimer.autostart = true
+ #MovementTimer.connect("timeout", Callable(_on_movement_timer_timeout))
+ #add_child(MovementTimer)
+ pass
+
+func init():
+ #if component_collision_path:
+ #component_collision = get_node(component_collision_path)
+ #component_collision.collision_area.connect("collided", func(body):
+ #if check_direction_has_intersection(CURRENT_DIRECTION):
+ #tween.stop()
+ #move()
+ #)
+ ## TODO: area mit direction change detection? on solid and bomb?
- return collision
+ await get_tree().create_timer(0.2).timeout # wait for surrounding collision objects to load
+ move()
+
+
+#func physics_process(delta):
+ #if is_paused:
+ #return null
+ #
+ #if CURRENT_DIRECTION == Vector2.UP:
+ #entity.velocity.y -= SPEED/2
+ #if sprite.sprite_frames.has_animation(animations["up"]):
+ #sprite.play(animations["up"])
+ #elif CURRENT_DIRECTION == Vector2.DOWN:
+ #entity.velocity.y += SPEED/2
+ #if sprite.sprite_frames.has_animation(animations["down"]):
+ #sprite.play(animations["down"])
+ #elif CURRENT_DIRECTION == Vector2.LEFT:
+ #entity.velocity.x -= SPEED/2
+ #if sprite.sprite_frames.has_animation(animations["left"]):
+ #sprite.play(animations["left"])
+ #elif CURRENT_DIRECTION == Vector2.RIGHT:
+ #entity.velocity.x += SPEED/2
+ #if sprite.sprite_frames.has_animation(animations["right"]):
+ #sprite.play(animations["right"])
+ #
+ #if sprite.sprite_frames.has_animation(animations["default"]):
+ #sprite.play(animations["default"])
+ #
+ #var collision = entity.move_and_collide(entity.velocity * delta)
+ #entity.velocity = entity.velocity.lerp(Vector2(0, 0), 1) # speed too low => no collision
+ #
+ ## todo movement along grid (maybe move position to current tile center)
+ #var target_grid_position = Utilities.from_grid_to_position(Utilities.get_level_position(entity) + CURRENT_DIRECTION)
+ #entity.position = entity.position.move_toward(target_grid_position, delta*SPEED/2)
+ ## todo or set velocity to tiles per SPEED per second somehow, instead of Timer
+ ## use raycast in every direction to check next valid tile, move there
+ ## get start, current and end position, check if reached instead of velocity to tiles per second or Timer
+ #
+ #if collision:
+ #was_colliding = true
+ #if MovementTimer.time_left > 0:
+ #_on_movement_timer_timeout()
+ #else:
+ #was_colliding = false
+ #
+ #return collision
func set_animations(new_animations: Dictionary):
animations.merge(new_animations, true)
-func _on_movement_timer_timeout():
- var randomize_direction = false
+#func _on_movement_timer_timeout():
+ #var randomize_direction = false
+#
+ #if false and follows and randi_range(0, 100) <= follow_chance:
+ #var player_direction = entity.position.direction_to(Global.player.position)
+ #var query = PhysicsRayQueryParameters2D.new()
+ #query.set_from(entity.position)
+ #query.set_to(Global.player.position)
+ #query.set_collision_mask(entity.collision_mask)
+ #var intersection = entity.get_world_2d().direct_space_state.intersect_ray(query)
+ #if intersection:
+ #randomize_direction = true
+ #
+ #if abs(player_direction.x) >= abs(player_direction.y):
+ #if player_direction.x >= 0:
+ #CURRENT_DIRECTION = Vector2.RIGHT
+ #elif player_direction.x < 0:
+ #CURRENT_DIRECTION = Vector2.LEFT
+ #elif abs(player_direction.y) > abs(player_direction.x):
+ #if player_direction.y >= 0:
+ #CURRENT_DIRECTION = Vector2.DOWN
+ #elif player_direction.y < 0:
+ #CURRENT_DIRECTION = Vector2.UP
+ #
+ #if was_colliding and LAST_DIRECTION == CURRENT_DIRECTION:
+ #randomize_direction = true
+ #else:
+ #randomize_direction = true
+ #
+ #if randomize_direction:
+ #var directions = DIRECTIONS.duplicate()
+ #
+ #directions.erase(CURRENT_DIRECTION)
+ #directions.shuffle()
+ #
+ #if not directions.is_empty():
+ #CURRENT_DIRECTION = directions[0]
+#
+ #emit_signal("direction_changed", CURRENT_DIRECTION)
+ #LAST_DIRECTION = CURRENT_DIRECTION
+ #
+ #if not sprite.sprite_frames.has_animation(animations["default"]):
+ #var frame = sprite.frame
+ #var progress = sprite.frame_progress
+ #if CURRENT_DIRECTION == Vector2.UP and sprite.sprite_frames.has_animation(animations["up"]):
+ #sprite.play(animations["up"])
+ #elif CURRENT_DIRECTION == Vector2.DOWN and sprite.sprite_frames.has_animation(animations["down"]):
+ #sprite.play(animations["down"])
+ #elif CURRENT_DIRECTION == Vector2.LEFT and sprite.sprite_frames.has_animation(animations["left"]):
+ #sprite.play(animations["left"])
+ #elif CURRENT_DIRECTION == Vector2.RIGHT and sprite.sprite_frames.has_animation(animations["right"]):
+ #sprite.play(animations["right"])
+ #sprite.set_frame_and_progress(frame, progress)
+ #
+ #MovementTimer.start()
+
+
+func pause():
+ is_paused = true
+ #MovementTimer.paused = true
+
+ process_mode = Node.PROCESS_MODE_DISABLED
- if false and follows and randi_range(0, 100) <= follow_chance:
- var player_direction = entity.position.direction_to(Global.player.position)
- var query = PhysicsRayQueryParameters2D.new()
- query.set_from(entity.position)
- query.set_to(Global.player.position)
- query.set_collision_mask(entity.collision_mask)
- var intersection = entity.get_world_2d().direct_space_state.intersect_ray(query)
- if intersection:
- randomize_direction = true
-
- if abs(player_direction.x) >= abs(player_direction.y):
- if player_direction.x >= 0:
- CURRENT_DIRECTION = Vector2.RIGHT
- elif player_direction.x < 0:
- CURRENT_DIRECTION = Vector2.LEFT
- elif abs(player_direction.y) > abs(player_direction.x):
- if player_direction.y >= 0:
- CURRENT_DIRECTION = Vector2.DOWN
- elif player_direction.y < 0:
- CURRENT_DIRECTION = Vector2.UP
-
- if was_colliding and LAST_DIRECTION == CURRENT_DIRECTION:
- randomize_direction = true
- else:
+func unpause():
+ is_paused = false
+ #MovementTimer.paused = false
+
+ process_mode = Node.PROCESS_MODE_INHERIT
+ sprite.play(CURRENT_ANIMATION.name)
+ sprite.set_frame_and_progress(CURRENT_ANIMATION.frame, CURRENT_ANIMATION.progress)
+
+
+func move():
+ var can_move = true
+ var randomize_direction = false
+
+ #randomize_direction = randi() % 10 > 8
+ if check_direction_has_intersection(CURRENT_DIRECTION):
randomize_direction = true
-
+
+ var directions = DIRECTIONS.duplicate()
if randomize_direction:
- var directions = DIRECTIONS.duplicate()
-
directions.erase(CURRENT_DIRECTION)
- directions.shuffle()
-
- if not directions.is_empty():
- CURRENT_DIRECTION = directions[0]
-
+ directions.shuffle()
+
+ for idx in range(directions.size()):
+ if not check_direction_has_intersection(directions[idx]):
+ CURRENT_DIRECTION = directions[idx]
+ break
+ if idx == directions.size() - 1:
+ can_move = false
+
+ if FIXED_DIRECTION:
+ CURRENT_DIRECTION = FIXED_DIRECTION
+
emit_signal("direction_changed", CURRENT_DIRECTION)
- LAST_DIRECTION = CURRENT_DIRECTION
- if not sprite.sprite_frames.has_animation(animations["default"]):
- var frame = sprite.frame
- var progress = sprite.frame_progress
+ var frame = sprite.frame
+ var progress = sprite.frame_progress
+ var animation = sprite.animation
+ if sprite.sprite_frames.has_animation(animations["default"]):
+ sprite.play(animations["default"])
+ else:
if CURRENT_DIRECTION == Vector2.UP and sprite.sprite_frames.has_animation(animations["up"]):
sprite.play(animations["up"])
elif CURRENT_DIRECTION == Vector2.DOWN and sprite.sprite_frames.has_animation(animations["down"]):
@@ -134,6 +224,31 @@ func _on_movement_timer_timeout():
sprite.play(animations["left"])
elif CURRENT_DIRECTION == Vector2.RIGHT and sprite.sprite_frames.has_animation(animations["right"]):
sprite.play(animations["right"])
- sprite.set_frame_and_progress(frame, progress)
+ sprite.set_frame_and_progress(frame, progress)
+
+ CURRENT_ANIMATION.name = animation
+ CURRENT_ANIMATION.frame = frame
+ CURRENT_ANIMATION.progress = progress
+
+ var target_grid_position = Utilities.from_grid_to_position(Utilities.get_level_position(entity) + CURRENT_DIRECTION)
+
+ tween = create_tween()
+ if can_move:
+ tween.tween_property(entity, "position", target_grid_position, 1/SPEED).set_ease(Tween.EASE_IN_OUT)
+ else:
+ tween.tween_callback(func():
+ await get_tree().create_timer(1/SPEED).timeout
+ )
+ tween.tween_callback(func():
+ move()
+ )
+
+
+func check_direction_has_intersection(direction: Vector2):
+ var query = PhysicsRayQueryParameters2D.new()
+ query.set_from(entity.position)
+ query.set_to(Utilities.from_grid_to_position(Utilities.get_level_position(entity) + direction))
+ query.set_collision_mask(entity.collision_mask)
+ var intersection = entity.get_world_2d().direct_space_state.intersect_ray(query)
- MovementTimer.start()
+ return intersection
diff --git a/Scenes/Entities/Enemies/Flower.gd b/Scenes/Entities/Enemies/Flower.gd
index 3e50e80..d287bdc 100644
--- a/Scenes/Entities/Enemies/Flower.gd
+++ b/Scenes/Entities/Enemies/Flower.gd
@@ -8,8 +8,13 @@ func _ready():
$Body/Bottom.play("default")
add_to_group("enemies")
+
$Collision.init()
$Collision.collision_area.set_collision_layer_value(Utilities.Collision.Layer.ENEMY, true)
+
+ $Health.hit.connect(func():
+ $Body/Top.visible = false
+ )
$Health.died.connect(func():
$Body.remove_child($Body/Top)
)
diff --git a/Scenes/Entities/Enemies/Flowers.gd b/Scenes/Entities/Enemies/Flowers.gd
index 5f8e974..9b6658e 100644
--- a/Scenes/Entities/Enemies/Flowers.gd
+++ b/Scenes/Entities/Enemies/Flowers.gd
@@ -28,9 +28,12 @@ func _ready():
var flower = FlowerScene.instantiate()
flower.angle = deg_to_rad(120 * number)
+ flower.get_node("Health").hit.connect(func():
+ flowers.remove_at(flowers.find(flower))
+ )
+
# if last flower is removed, remove self
flower.get_node("Health").died.connect(func():
- flowers.remove_at(flowers.find(flower))
if flowers.is_empty():
queue_free()
)
diff --git a/Scenes/Entities/Enemies/Slime.gd b/Scenes/Entities/Enemies/Slime.gd
index 427b18f..fe67fca 100644
--- a/Scenes/Entities/Enemies/Slime.gd
+++ b/Scenes/Entities/Enemies/Slime.gd
@@ -5,7 +5,11 @@ func _ready():
add_to_group("enemies")
get_node("Collision").init()
+
+ get_node("Movement").init()
-func _physics_process(delta):
- get_node("Movement").physics_process(delta)
+#func _physics_process(delta):
+ #pass
+ #print(position)
+ #get_node("Movement").physics_process(delta)
diff --git a/Scenes/Entities/Enemies/Slime.tscn b/Scenes/Entities/Enemies/Slime.tscn
index 558b736..dcaaf52 100644
--- a/Scenes/Entities/Enemies/Slime.tscn
+++ b/Scenes/Entities/Enemies/Slime.tscn
@@ -14,9 +14,6 @@
[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"]
-[sub_resource type="CircleShape2D" id="CircleShape2D_f54tg"]
-radius = 6.0
-
[sub_resource type="SpriteFrames" id="SpriteFrames_4e1a7"]
animations = [{
"frames": [{
@@ -65,24 +62,26 @@ animations = [{
"speed": 8.0
}]
+[sub_resource type="CircleShape2D" id="CircleShape2D_f54tg"]
+radius = 6.0
+
[node name="Slime" type="CharacterBody2D"]
collision_layer = 16
collision_mask = 188
script = ExtResource("1_2xftl")
-[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
-position = Vector2(0, -6)
-shape = SubResource("CircleShape2D_f54tg")
-
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
texture_filter = 1
-position = Vector2(0, -6.25)
sprite_frames = SubResource("SpriteFrames_4e1a7")
+[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
+shape = SubResource("CircleShape2D_f54tg")
+
[node name="Movement" parent="." instance=ExtResource("6_u48ct")]
entityPath = NodePath("..")
spritePath = NodePath("../AnimatedSprite2D")
-SPEED = 12
+component_collision_path = NodePath("../Collision")
+SPEED = 1.0
timer_time = 5.0
[node name="Collision" parent="." instance=ExtResource("7_kjjor")]
diff --git a/Scenes/Entities/Enemies/Snake.gd b/Scenes/Entities/Enemies/Snake.gd
index a87ecf0..af09990 100644
--- a/Scenes/Entities/Enemies/Snake.gd
+++ b/Scenes/Entities/Enemies/Snake.gd
@@ -1,7 +1,7 @@
extends CharacterBody2D
-@export var speed: float = 10
+@export var speed: float = 1
static var detected_bombs = []
var did_detect_bomb = false
@@ -32,7 +32,9 @@ func _ready():
add_to_group("enemies")
component_collision.init()
+
component_movement.SPEED = speed
+ component_movement.init()
func _physics_process(delta):
@@ -71,18 +73,19 @@ func _physics_process(delta):
if $DetectionArea.get_overlapping_bodies().has(detected_bomb):
_on_detection_area_body_entered(detected_bomb)
elif did_detect_bomb:
- component_movement.CURRENT_DIRECTION = detected_bomb_direction
+ component_movement.FIXED_DIRECTION = detected_bomb_direction
- if not is_animating_state:
- component_movement.physics_process(delta)
+ #if not is_animating_state:
+ #component_movement.physics_process(delta)
func set_animating_state(state: bool):
is_animating_state = state
if is_animating_state:
- component_movement.MovementTimer.stop()
+ component_movement.pause()
+ component_movement.FIXED_DIRECTION = null
else:
- component_movement.MovementTimer.start()
+ component_movement.unpause()
func _on_detection_area_body_entered(_body):
diff --git a/Scenes/Entities/Enemies/Snake.tscn b/Scenes/Entities/Enemies/Snake.tscn
index 660b3d7..48a19ae 100644
--- a/Scenes/Entities/Enemies/Snake.tscn
+++ b/Scenes/Entities/Enemies/Snake.tscn
@@ -380,6 +380,7 @@ shape = SubResource("RectangleShape2D_7ji0i")
[node name="Movement" parent="." instance=ExtResource("14_ab70e")]
entityPath = NodePath("..")
spritePath = NodePath("../AnimatedSprite2D")
+SPEED = 1.0
timer_time = 2.0
follows = true
follow_chance = 80
diff --git a/Scenes/Entities/Enemies/Tree.gd b/Scenes/Entities/Enemies/Tree.gd
index bbd02a9..320640e 100644
--- a/Scenes/Entities/Enemies/Tree.gd
+++ b/Scenes/Entities/Enemies/Tree.gd
@@ -12,24 +12,20 @@ func _ready():
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()
$AnimatedSprite2D.set_frame_and_progress(0, 0)
-
- $Health.connect("died", func():
- $Detection.set_collision_mask_value(Utilities.Collision.Layer.PLAYER, false)
- )
-func _physics_process(delta):
- component_movement.physics_process(delta)
+#func _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)
+ component_movement.init()
+
+ $Detection.set_collision_mask_value(Utilities.Collision.Layer.PLAYER, false)
diff --git a/Scenes/Entities/Enemies/Tree.tscn b/Scenes/Entities/Enemies/Tree.tscn
index f216159..01a79bf 100644
--- a/Scenes/Entities/Enemies/Tree.tscn
+++ b/Scenes/Entities/Enemies/Tree.tscn
@@ -141,7 +141,7 @@ script = ExtResource("1_ktvfx")
texture_filter = 1
position = Vector2(0, -8)
sprite_frames = SubResource("SpriteFrames_c5ryj")
-animation = &"death_post"
+animation = &"spawn"
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(0, -8)
@@ -150,7 +150,8 @@ shape = SubResource("CapsuleShape2D_u8qfj")
[node name="Movement" parent="." instance=ExtResource("17_wlky1")]
entityPath = NodePath("..")
spritePath = NodePath("../AnimatedSprite2D")
-SPEED = 24
+component_collision_path = NodePath("../Collision")
+SPEED = 1.4
timer_time = 2.0
follows = true
follow_chance = 50
@@ -164,7 +165,7 @@ component_health_path = NodePath("../Health")
entityPath = NodePath("..")
spritePath = NodePath("../AnimatedSprite2D")
component_movement_path = NodePath("../Movement")
-health = 1
+health = 2
[node name="Detection" type="Area2D" parent="."]
collision_layer = 64
diff --git a/Scenes/Entities/Player.gd b/Scenes/Entities/Player.gd
index e8e9fbb..77e27b4 100644
--- a/Scenes/Entities/Player.gd
+++ b/Scenes/Entities/Player.gd
@@ -287,6 +287,8 @@ func heal(amount: int):
func play_idle():
+ #$AnimatedSprite2D.play("idle")
+ #return
if self.LAST_DIRECTIONS == [Vector2.LEFT]:
$AnimatedSprite2D.play("idle_left")
elif self.LAST_DIRECTIONS == [Vector2.RIGHT]:
diff --git a/Scenes/Entities/Player.tscn b/Scenes/Entities/Player.tscn
index caf6c7c..51eb36a 100644
--- a/Scenes/Entities/Player.tscn
+++ b/Scenes/Entities/Player.tscn
@@ -1,45 +1,45 @@
[gd_scene load_steps=29 format=3 uid="uid://b1xhgqwrw4pgs"]
[ext_resource type="Script" path="res://Scenes/Entities/Player.gd" id="1_2xulf"]
-[ext_resource type="Texture2D" uid="uid://c1lfciwp5n6wh" path="res://Assets/Character/Bomberman_bl_02.png" id="2_7c86j"]
-[ext_resource type="Texture2D" uid="uid://cwuyr6j4fowbn" path="res://Assets/Character/Bomberman_bl_01.png" id="3_frmop"]
-[ext_resource type="Texture2D" uid="uid://c17pybwy8uebb" path="res://Assets/Character/Bomberman_bl_03.png" id="4_viays"]
-[ext_resource type="Texture2D" uid="uid://d21ri773nni5x" path="res://Assets/Character/Bomberman_br_02.png" id="5_f3x6s"]
-[ext_resource type="Texture2D" uid="uid://cn844bbmb6ebw" path="res://Assets/Character/Bomberman_br_01.png" id="6_id2dl"]
-[ext_resource type="Texture2D" uid="uid://b4ajsycsqfy6b" path="res://Assets/Character/Bomberman_br_03.png" id="7_snc6l"]
-[ext_resource type="Texture2D" uid="uid://dcrvqjbr30piu" path="res://Assets/Character/Bomberman_down_02.png" id="8_6nrho"]
-[ext_resource type="Texture2D" uid="uid://llvrhcwdwyxq" path="res://Assets/Character/Bomberman_down_01.png" id="9_4r1t6"]
-[ext_resource type="Texture2D" uid="uid://dqgnibpodjph1" path="res://Assets/Character/Bomberman_down_03.png" id="10_0c5dt"]
-[ext_resource type="Texture2D" uid="uid://dsosylrax8qc0" path="res://Assets/Character/Bomberman_left_01.png" id="11_4vfbf"]
-[ext_resource type="Texture2D" uid="uid://dyrlofdra1jg" path="res://Assets/Character/Bomberman_right_01.png" id="12_b74y7"]
-[ext_resource type="Texture2D" uid="uid://b1ftykprnvmb2" path="res://Assets/Character/Bomberman_tl_01.png" id="13_t5fk2"]
-[ext_resource type="Texture2D" uid="uid://cpia0jdfix3v1" path="res://Assets/Character/Bomberman_tr_01.png" id="14_ank74"]
-[ext_resource type="Texture2D" uid="uid://cfxr2vqrydpxa" path="res://Assets/Character/Bomberman_up_01.png" id="15_an6q7"]
-[ext_resource type="Texture2D" uid="uid://rjsxm415e85y" path="res://Assets/Character/Bomberman_left_02.png" id="16_74r3r"]
-[ext_resource type="Texture2D" uid="uid://b2vn64asvfwpa" path="res://Assets/Character/Bomberman_left_03.png" id="17_am4b3"]
-[ext_resource type="Texture2D" uid="uid://cqc4sxd5jlog3" path="res://Assets/Character/Bomberman_right_02.png" id="18_au0ca"]
-[ext_resource type="Texture2D" uid="uid://da4ematmp08qs" path="res://Assets/Character/Bomberman_right_03.png" id="19_736tk"]
-[ext_resource type="Texture2D" uid="uid://c3gdllyr2gjwr" path="res://Assets/Character/Bomberman_tl_02.png" id="20_wtgma"]
-[ext_resource type="Texture2D" uid="uid://b7w657i2b8i7b" path="res://Assets/Character/Bomberman_tl_03.png" id="21_m2nht"]
-[ext_resource type="Texture2D" uid="uid://dtk5hkysfnsgk" path="res://Assets/Character/Bomberman_tr_02.png" id="22_kojwu"]
-[ext_resource type="Texture2D" uid="uid://b5535ungwxix7" path="res://Assets/Character/Bomberman_tr_03.png" id="23_fpo4g"]
-[ext_resource type="Texture2D" uid="uid://0pr3bb5cn5da" path="res://Assets/Character/Bomberman_up_02.png" id="24_tx0m0"]
-[ext_resource type="Texture2D" uid="uid://m2vf7nnhlatp" path="res://Assets/Character/Bomberman_up_03.png" id="25_6f86e"]
+[ext_resource type="Texture2D" uid="uid://bg118etml15yv" path="res://Assets/Character/Holo/Pekora/UsadaPekora_dl_01.png" id="2_jla7x"]
+[ext_resource type="Texture2D" uid="uid://15xbcugoqlqi" path="res://Assets/Character/Holo/Pekora/UsadaPekora_down_01.png" id="2_p4v8h"]
+[ext_resource type="Texture2D" uid="uid://cap4ceyokrpyg" path="res://Assets/Character/Holo/Pekora/UsadaPekora_dr_01.png" id="3_177dx"]
+[ext_resource type="Texture2D" uid="uid://cnfiwdbfeldka" path="res://Assets/Character/Holo/Pekora/UsadaPekora_dl_02.png" id="3_lxvmr"]
+[ext_resource type="Texture2D" uid="uid://cy0imnb7nxpvp" path="res://Assets/Character/Holo/Pekora/UsadaPekora_dl_03.png" id="4_rba8x"]
+[ext_resource type="Texture2D" uid="uid://dyrm5j2cnbjkc" path="res://Assets/Character/Holo/Pekora/UsadaPekora_left_01.png" id="5_qp5pw"]
+[ext_resource type="Texture2D" uid="uid://dr60n8hird4dj" path="res://Assets/Character/Holo/Pekora/UsadaPekora_dr_02.png" id="6_hpvt1"]
+[ext_resource type="Texture2D" uid="uid://bftq45mjm8uv" path="res://Assets/Character/Holo/Pekora/UsadaPekora_right_01.png" id="6_swanx"]
+[ext_resource type="Texture2D" uid="uid://j3gux07q0sdi" path="res://Assets/Character/Holo/Pekora/UsadaPekora_dr_03.png" id="7_66d3g"]
+[ext_resource type="Texture2D" uid="uid://s3g73mdo8rhg" path="res://Assets/Character/Holo/Pekora/UsadaPekora_ul_01.png" id="7_vvdjp"]
+[ext_resource type="Texture2D" uid="uid://cu57mhgffnysb" path="res://Assets/Character/Holo/Pekora/UsadaPekora_ur_01.png" id="8_ps3gx"]
+[ext_resource type="Texture2D" uid="uid://djumpgwc3ibsu" path="res://Assets/Character/Holo/Pekora/UsadaPekora_down_02.png" id="9_8qycu"]
+[ext_resource type="Texture2D" uid="uid://ygyam231cwbu" path="res://Assets/Character/Holo/Pekora/UsadaPekora_up_01.png" id="9_g1tvy"]
+[ext_resource type="Texture2D" uid="uid://de0mh5otwjtqm" path="res://Assets/Character/Holo/Pekora/UsadaPekora_down_03.png" id="10_7c2nx"]
+[ext_resource type="Texture2D" uid="uid://dkdo8avk7uifd" path="res://Assets/Character/Holo/Pekora/UsadaPekora_left_02.png" id="16_qmci1"]
+[ext_resource type="Texture2D" uid="uid://ixa7jtofxiih" path="res://Assets/Character/Holo/Pekora/UsadaPekora_left_03.png" id="17_u384x"]
+[ext_resource type="Texture2D" uid="uid://cbwe3ub3wjw8q" path="res://Assets/Character/Holo/Pekora/UsadaPekora_right_02.png" id="18_uodub"]
+[ext_resource type="Texture2D" uid="uid://usm6432wb42q" path="res://Assets/Character/Holo/Pekora/UsadaPekora_right_03.png" id="19_8vk5g"]
+[ext_resource type="Texture2D" uid="uid://dbylk34dwefc7" path="res://Assets/Character/Holo/Pekora/UsadaPekora_ul_02.png" id="20_86vyd"]
+[ext_resource type="Texture2D" uid="uid://s6kf7x6c5en1" path="res://Assets/Character/Holo/Pekora/UsadaPekora_ul_03.png" id="21_gdqcl"]
+[ext_resource type="Texture2D" uid="uid://c5bivhfyf2lc5" path="res://Assets/Character/Holo/Pekora/UsadaPekora_ur_02.png" id="22_gy6m2"]
+[ext_resource type="Texture2D" uid="uid://ro7pxk0tm2tl" path="res://Assets/Character/Holo/Pekora/UsadaPekora_ur_03.png" id="23_sb37c"]
+[ext_resource type="Texture2D" uid="uid://bagpol3wfd081" path="res://Assets/Character/Holo/Pekora/UsadaPekora_up_02.png" id="24_a12kc"]
+[ext_resource type="Texture2D" uid="uid://c0622b7ijgs3v" path="res://Assets/Character/Holo/Pekora/UsadaPekora_up_03.png" id="25_27ap4"]
[sub_resource type="SpriteFrames" id="SpriteFrames_fu51i"]
animations = [{
"frames": [{
"duration": 1.0,
-"texture": ExtResource("2_7c86j")
+"texture": ExtResource("2_jla7x")
}, {
"duration": 1.0,
-"texture": ExtResource("3_frmop")
+"texture": ExtResource("3_lxvmr")
}, {
"duration": 1.0,
-"texture": ExtResource("4_viays")
+"texture": ExtResource("2_jla7x")
}, {
"duration": 1.0,
-"texture": ExtResource("3_frmop")
+"texture": ExtResource("4_rba8x")
}],
"loop": true,
"name": &"bottom_left",
@@ -47,16 +47,16 @@ animations = [{
}, {
"frames": [{
"duration": 1.0,
-"texture": ExtResource("5_f3x6s")
+"texture": ExtResource("3_177dx")
}, {
"duration": 1.0,
-"texture": ExtResource("6_id2dl")
+"texture": ExtResource("6_hpvt1")
}, {
"duration": 1.0,
-"texture": ExtResource("7_snc6l")
+"texture": ExtResource("3_177dx")
}, {
"duration": 1.0,
-"texture": ExtResource("6_id2dl")
+"texture": ExtResource("7_66d3g")
}],
"loop": true,
"name": &"bottom_right",
@@ -64,16 +64,16 @@ animations = [{
}, {
"frames": [{
"duration": 1.0,
-"texture": ExtResource("8_6nrho")
+"texture": ExtResource("2_p4v8h")
}, {
"duration": 1.0,
-"texture": ExtResource("9_4r1t6")
+"texture": ExtResource("9_8qycu")
}, {
"duration": 1.0,
-"texture": ExtResource("10_0c5dt")
+"texture": ExtResource("2_p4v8h")
}, {
"duration": 1.0,
-"texture": ExtResource("9_4r1t6")
+"texture": ExtResource("10_7c2nx")
}],
"loop": true,
"name": &"down",
@@ -81,7 +81,7 @@ animations = [{
}, {
"frames": [{
"duration": 1.0,
-"texture": ExtResource("3_frmop")
+"texture": ExtResource("2_jla7x")
}],
"loop": true,
"name": &"idle_bottom_left",
@@ -89,7 +89,7 @@ animations = [{
}, {
"frames": [{
"duration": 1.0,
-"texture": ExtResource("6_id2dl")
+"texture": ExtResource("3_177dx")
}],
"loop": true,
"name": &"idle_bottom_right",
@@ -97,7 +97,7 @@ animations = [{
}, {
"frames": [{
"duration": 1.0,
-"texture": ExtResource("9_4r1t6")
+"texture": ExtResource("2_p4v8h")
}],
"loop": true,
"name": &"idle_down",
@@ -105,7 +105,7 @@ animations = [{
}, {
"frames": [{
"duration": 1.0,
-"texture": ExtResource("11_4vfbf")
+"texture": ExtResource("5_qp5pw")
}],
"loop": true,
"name": &"idle_left",
@@ -113,7 +113,7 @@ animations = [{
}, {
"frames": [{
"duration": 1.0,
-"texture": ExtResource("12_b74y7")
+"texture": ExtResource("6_swanx")
}],
"loop": true,
"name": &"idle_right",
@@ -121,7 +121,7 @@ animations = [{
}, {
"frames": [{
"duration": 1.0,
-"texture": ExtResource("13_t5fk2")
+"texture": ExtResource("7_vvdjp")
}],
"loop": true,
"name": &"idle_top_left",
@@ -129,7 +129,7 @@ animations = [{
}, {
"frames": [{
"duration": 1.0,
-"texture": ExtResource("14_ank74")
+"texture": ExtResource("8_ps3gx")
}],
"loop": true,
"name": &"idle_top_right",
@@ -137,7 +137,7 @@ animations = [{
}, {
"frames": [{
"duration": 1.0,
-"texture": ExtResource("15_an6q7")
+"texture": ExtResource("9_g1tvy")
}],
"loop": true,
"name": &"idle_up",
@@ -145,16 +145,16 @@ animations = [{
}, {
"frames": [{
"duration": 1.0,
-"texture": ExtResource("16_74r3r")
+"texture": ExtResource("5_qp5pw")
}, {
"duration": 1.0,
-"texture": ExtResource("11_4vfbf")
+"texture": ExtResource("16_qmci1")
}, {
"duration": 1.0,
-"texture": ExtResource("17_am4b3")
+"texture": ExtResource("5_qp5pw")
}, {
"duration": 1.0,
-"texture": ExtResource("11_4vfbf")
+"texture": ExtResource("17_u384x")
}],
"loop": true,
"name": &"left",
@@ -162,16 +162,16 @@ animations = [{
}, {
"frames": [{
"duration": 1.0,
-"texture": ExtResource("18_au0ca")
+"texture": ExtResource("6_swanx")
}, {
"duration": 1.0,
-"texture": ExtResource("12_b74y7")
+"texture": ExtResource("18_uodub")
}, {
"duration": 1.0,
-"texture": ExtResource("19_736tk")
+"texture": ExtResource("6_swanx")
}, {
"duration": 1.0,
-"texture": ExtResource("12_b74y7")
+"texture": ExtResource("19_8vk5g")
}],
"loop": true,
"name": &"right",
@@ -179,16 +179,16 @@ animations = [{
}, {
"frames": [{
"duration": 1.0,
-"texture": ExtResource("20_wtgma")
+"texture": ExtResource("7_vvdjp")
}, {
"duration": 1.0,
-"texture": ExtResource("13_t5fk2")
+"texture": ExtResource("20_86vyd")
}, {
"duration": 1.0,
-"texture": ExtResource("21_m2nht")
+"texture": ExtResource("7_vvdjp")
}, {
"duration": 1.0,
-"texture": ExtResource("13_t5fk2")
+"texture": ExtResource("21_gdqcl")
}],
"loop": true,
"name": &"top_left",
@@ -196,16 +196,16 @@ animations = [{
}, {
"frames": [{
"duration": 1.0,
-"texture": ExtResource("22_kojwu")
+"texture": ExtResource("8_ps3gx")
}, {
"duration": 1.0,
-"texture": ExtResource("14_ank74")
+"texture": ExtResource("22_gy6m2")
}, {
"duration": 1.0,
-"texture": ExtResource("23_fpo4g")
+"texture": ExtResource("8_ps3gx")
}, {
"duration": 1.0,
-"texture": ExtResource("14_ank74")
+"texture": ExtResource("23_sb37c")
}],
"loop": true,
"name": &"top_right",
@@ -213,16 +213,16 @@ animations = [{
}, {
"frames": [{
"duration": 1.0,
-"texture": ExtResource("24_tx0m0")
+"texture": ExtResource("9_g1tvy")
}, {
"duration": 1.0,
-"texture": ExtResource("15_an6q7")
+"texture": ExtResource("24_a12kc")
}, {
"duration": 1.0,
-"texture": ExtResource("25_6f86e")
+"texture": ExtResource("9_g1tvy")
}, {
"duration": 1.0,
-"texture": ExtResource("15_an6q7")
+"texture": ExtResource("25_27ap4")
}],
"loop": true,
"name": &"up",
@@ -230,8 +230,8 @@ animations = [{
}]
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_xsiww"]
-radius = 5.0
-height = 13.0
+radius = 6.0
+height = 15.0
[sub_resource type="RectangleShape2D" id="RectangleShape2D_c6666"]
size = Vector2(14, 14)
@@ -244,12 +244,11 @@ script = ExtResource("1_2xulf")
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
texture_filter = 1
-scale = Vector2(0.8, 0.8)
+position = Vector2(0, -3)
sprite_frames = SubResource("SpriteFrames_fu51i")
animation = &"idle_down"
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
-position = Vector2(0, 1)
shape = SubResource("CapsuleShape2D_xsiww")
[node name="Camera2D" type="Camera2D" parent="."]
@@ -261,6 +260,7 @@ collision_layer = 0
collision_mask = 4
[node name="CollisionShape2D" type="CollisionShape2D" parent="InteractionArea"]
+visible = false
position = Vector2(0, 1)
shape = SubResource("RectangleShape2D_c6666")