diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2024-04-14 21:49:20 +0200 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2024-04-14 21:49:20 +0200 |
commit | f27937e6e9b6a7146dd09fc711d2d293ecf5abbf (patch) | |
tree | e0ddd5e6d356000e4f29af6211a736284a4972ee /Scenes/Components/MapArea.gd | |
parent | 96d36cee33d6321834565f0a5d412ef95c5ceffd (diff) |
update
Diffstat (limited to 'Scenes/Components/MapArea.gd')
-rw-r--r-- | Scenes/Components/MapArea.gd | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/Scenes/Components/MapArea.gd b/Scenes/Components/MapArea.gd index f46216a..6aaa811 100644 --- a/Scenes/Components/MapArea.gd +++ b/Scenes/Components/MapArea.gd @@ -1,8 +1,10 @@ extends Area2D + + func _ready(): - self.add_area_edges() + pass func add_area_edges(): @@ -45,21 +47,44 @@ func _on_player_entered(player: Player): if exited_area: exited_area.get_node("TileMap").process_mode = PROCESS_MODE_DISABLED + # animate sprite + var sprite: AnimatedSprite2D = player.get_node("AnimatedSprite2D") + var bounds: Rect2 = Utilities.get_collision_shape_bounds($CollisionShape2D) + + var sprite_direction = "" + if player.position.x <= bounds.position.x: + sprite_direction = "right" + elif player.position.x >= bounds.end.x: + sprite_direction = "left" + elif player.position.y <= bounds.position.y: + sprite_direction = "down" + elif player.position.y >= bounds.end.y: + sprite_direction = "up" + + var sprite_tween = get_tree().create_tween().set_loops(5) + sprite_tween.tween_interval(0.25) + sprite_tween.tween_callback(func(): + sprite.play(sprite_direction) + ) + var tween = get_tree().create_tween() tween.tween_property( player, "position", player.position + player.DIRECTION * 16, 1.25 ) tween.tween_callback(func(): exited_area.get_node("TileMap").visible = false + sprite_tween.kill() + sprite.play("idle_" + sprite_direction) ) Global.last_area = self + + # TODO: handle different child entity groups inside TileMap func adjust_camera_to_area(player: Player) -> Camera2D: var camera: Camera2D = player.get_node("Camera2D") var bounds: Rect2 = Utilities.get_collision_shape_bounds($CollisionShape2D) - #var enter_direction_vector = player.position - collision_shape.position var duration = 0 if Global.last_area: |