diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2024-04-22 16:34:25 +0200 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2024-04-22 16:34:25 +0200 |
commit | c8a316e4b8987dad963656a34665fa0e23dedcb1 (patch) | |
tree | 569af4b4f37d21079b6aedfad5164e94b50b6cb8 /Scenes/Entities/Enemies | |
parent | f27937e6e9b6a7146dd09fc711d2d293ecf5abbf (diff) |
update
Diffstat (limited to 'Scenes/Entities/Enemies')
-rw-r--r-- | Scenes/Entities/Enemies/Balloon.tscn | 9 | ||||
-rw-r--r-- | Scenes/Entities/Enemies/Components/Movement.gd | 10 |
2 files changed, 14 insertions, 5 deletions
diff --git a/Scenes/Entities/Enemies/Balloon.tscn b/Scenes/Entities/Enemies/Balloon.tscn index 85b68c1..71f6e5d 100644 --- a/Scenes/Entities/Enemies/Balloon.tscn +++ b/Scenes/Entities/Enemies/Balloon.tscn @@ -98,11 +98,12 @@ animations = [{ [sub_resource type="CapsuleShape2D" id="CapsuleShape2D_abul4"] radius = 6.0 -height = 18.0 +height = 15.0 [node name="Balloon" type="CharacterBody2D"] collision_layer = 16 -collision_mask = 62 +collision_mask = 60 +motion_mode = 1 script = ExtResource("1_8q3w8") health = 1 @@ -111,12 +112,14 @@ sprite_frames = SubResource("SpriteFrames_nxaqi") animation = &"down" [node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2(0, -1) shape = SubResource("CapsuleShape2D_abul4") [node name="Movement" parent="." instance=ExtResource("15_fwetl")] entityPath = NodePath("..") spritePath = NodePath("../AnimatedSprite2D") -SPEED = 2 +SPEED = 5 +timer_time = 10.0 [node name="Collision" parent="." instance=ExtResource("16_yau34")] entityPath = NodePath("..") diff --git a/Scenes/Entities/Enemies/Components/Movement.gd b/Scenes/Entities/Enemies/Components/Movement.gd index 0b30820..6ded026 100644 --- a/Scenes/Entities/Enemies/Components/Movement.gd +++ b/Scenes/Entities/Enemies/Components/Movement.gd @@ -1,5 +1,6 @@ extends Node + signal direction_changed @export_node_path("CharacterBody2D") var entityPath: NodePath @@ -13,11 +14,12 @@ signal direction_changed const DIRECTIONS = [Vector2.UP, Vector2.RIGHT, Vector2.DOWN, Vector2.LEFT] var CURRENT_DIRECTION = Vector2.UP +@export var timer_time: float = 3.0 @onready var MovementTimer: Timer = Timer.new() func _ready(): - MovementTimer.wait_time = 3.0 + MovementTimer.wait_time = timer_time MovementTimer.autostart = true MovementTimer.connect("timeout", Callable(_on_movement_timer_timeout)) add_child(MovementTimer) @@ -38,7 +40,11 @@ func physics_process(delta): sprite.play("right") var collision = entity.move_and_collide(entity.velocity * delta) - entity.velocity = entity.velocity.lerp(Vector2(0, 0), 1) + entity.velocity = entity.velocity.lerp(Vector2(0, 0), 1) # speed too low => no collision + + if collision: + if MovementTimer.time_left > 0: + _on_movement_timer_timeout() return collision |