summaryrefslogtreecommitdiff
path: root/Scenes/Components
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-05-03 13:59:15 +0200
committerDaniel Weipert <git@mail.dweipert.de>2024-05-03 13:59:15 +0200
commit8c0e8b5bf73caaf2fd6f04fb97b9c13f2970c431 (patch)
tree990b6e09eb2f6b3cb494cca17726ceae1bc7891f /Scenes/Components
parent516d22c1737a9c94026b5ff0c9856bc5549aa416 (diff)
update
Diffstat (limited to 'Scenes/Components')
-rw-r--r--Scenes/Components/MapArea.gd29
-rw-r--r--Scenes/Components/TileMap.tscn16
2 files changed, 34 insertions, 11 deletions
diff --git a/Scenes/Components/MapArea.gd b/Scenes/Components/MapArea.gd
index 4a69815..31e567a 100644
--- a/Scenes/Components/MapArea.gd
+++ b/Scenes/Components/MapArea.gd
@@ -40,11 +40,21 @@ func _on_body_entered(body):
func _on_player_entered(player: Player):
var exited_area = Global.last_area
+ if Global.last_area == self:
+ return
+
+ if exited_area:
+ exited_area.set_collision_mask_value(Utilities.Collision.Layer.PLAYER, false)
+
$TileMap.process_mode = PROCESS_MODE_INHERIT
$TileMap.visible = true
self.adjust_camera_to_area(player)
+ if not player.get_parent() == $TileMap:
+ (func(): player.reparent($TileMap)).call_deferred()
+
+ var position_tween: Tween
if exited_area:
exited_area.get_node("TileMap").process_mode = PROCESS_MODE_DISABLED
@@ -53,13 +63,13 @@ func _on_player_entered(player: Player):
var bounds: Rect2 = Utilities.get_collision_shape_bounds($CollisionShape2D)
var sprite_direction = ""
- if player.position.x <= bounds.position.x:
+ if player.global_position.x <= bounds.position.x:
sprite_direction = "right"
- elif player.position.x >= bounds.end.x:
+ elif player.global_position.x >= bounds.end.x:
sprite_direction = "left"
- elif player.position.y <= bounds.position.y:
+ elif player.global_position.y <= bounds.position.y:
sprite_direction = "down"
- elif player.position.y >= bounds.end.y:
+ elif player.global_position.y >= bounds.end.y:
sprite_direction = "up"
var sprite_tween = get_tree().create_tween().set_loops(5)
@@ -68,16 +78,17 @@ func _on_player_entered(player: Player):
sprite.play(sprite_direction)
)
- var tween = get_tree().create_tween()
- tween.tween_property(
- player, "position", player.position + player.DIRECTION * 16, 1.25
+ position_tween = get_tree().create_tween()
+ position_tween.tween_property(
+ player, "global_position", player.global_position + player.DIRECTION * 16, 1.25
)
- tween.tween_callback(func():
+ position_tween.tween_callback(func():
exited_area.get_node("TileMap").visible = false
sprite_tween.kill()
sprite.play("idle_" + sprite_direction)
+ exited_area.set_collision_mask_value(Utilities.Collision.Layer.PLAYER, true)
)
-
+
Global.last_area = self
# TODO: handle different child entity groups inside TileMap
diff --git a/Scenes/Components/TileMap.tscn b/Scenes/Components/TileMap.tscn
index b1938a6..469c501 100644
--- a/Scenes/Components/TileMap.tscn
+++ b/Scenes/Components/TileMap.tscn
@@ -7565,6 +7565,7 @@ texture = ExtResource("4_gspqb")
31:8/0/physics_layer_1/linear_velocity = Vector2(0, 0)
31:8/0/physics_layer_1/angular_velocity = 0.0
32:8/0 = 0
+32:8/0/y_sort_origin = -8
32:8/0/physics_layer_0/linear_velocity = Vector2(0, 0)
32:8/0/physics_layer_0/angular_velocity = 0.0
32:8/0/physics_layer_1/linear_velocity = Vector2(0, 0)
@@ -8407,6 +8408,7 @@ texture = ExtResource("4_gspqb")
12:12/0/physics_layer_1/linear_velocity = Vector2(0, 0)
12:12/0/physics_layer_1/angular_velocity = 0.0
13:12/0 = 0
+13:12/0/y_sort_origin = -8
13:12/0/physics_layer_0/linear_velocity = Vector2(0, 0)
13:12/0/physics_layer_0/angular_velocity = 0.0
13:12/0/physics_layer_1/linear_velocity = Vector2(0, 0)
@@ -8436,6 +8438,7 @@ texture = ExtResource("4_gspqb")
17:12/0/physics_layer_1/linear_velocity = Vector2(0, 0)
17:12/0/physics_layer_1/angular_velocity = 0.0
18:12/0 = 0
+18:12/0/y_sort_origin = -8
18:12/0/physics_layer_0/linear_velocity = Vector2(0, 0)
18:12/0/physics_layer_0/angular_velocity = 0.0
18:12/0/physics_layer_1/linear_velocity = Vector2(0, 0)
@@ -14400,6 +14403,7 @@ texture = ExtResource("5_8fova")
8:5/0/physics_layer_1/linear_velocity = Vector2(0, 0)
8:5/0/physics_layer_1/angular_velocity = 0.0
9:5/0 = 0
+9:5/0/y_sort_origin = -7
9:5/0/physics_layer_0/linear_velocity = Vector2(0, 0)
9:5/0/physics_layer_0/angular_velocity = 0.0
9:5/0/physics_layer_1/linear_velocity = Vector2(0, 0)
@@ -51910,6 +51914,7 @@ texture = ExtResource("4_gfgm6")
19:28/0/terrain = 1
19:28/0/physics_layer_0/linear_velocity = Vector2(0, 0)
19:28/0/physics_layer_0/angular_velocity = 0.0
+19:28/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -5.5, 6.125, -5.625, 6.125, 5.125, -8, 5.125)
19:28/0/physics_layer_1/linear_velocity = Vector2(0, 0)
19:28/0/physics_layer_1/angular_velocity = 0.0
19:28/0/terrains_peering_bit/left_side = 1
@@ -51918,6 +51923,7 @@ texture = ExtResource("4_gfgm6")
20:28/0/terrain = 1
20:28/0/physics_layer_0/linear_velocity = Vector2(0, 0)
20:28/0/physics_layer_0/angular_velocity = 0.0
+20:28/0/physics_layer_0/polygon_0/points = PackedVector2Array(-6.125, -4.625, 8, -4.875, 8, 4.625, -6.375, 4.875)
20:28/0/physics_layer_1/linear_velocity = Vector2(0, 0)
20:28/0/physics_layer_1/angular_velocity = 0.0
20:28/0/terrains_peering_bit/right_side = 1
@@ -65175,7 +65181,6 @@ pattern_3 = SubResource("TileMapPattern_yvluu")
pattern_4 = SubResource("TileMapPattern_8dacc")
[node name="TileMap" type="TileMap"]
-process_mode = 4
z_index = -1
y_sort_enabled = true
texture_filter = 1
@@ -65188,6 +65193,7 @@ layer_1/y_sort_enabled = true
layer_1/z_index = 1
layer_1/tile_data = PackedInt32Array()
layer_2/name = "Environment Bottom"
+layer_2/y_sort_enabled = true
layer_2/tile_data = PackedInt32Array()
layer_3/name = "Environment Middle"
layer_3/y_sort_enabled = true
@@ -65197,9 +65203,15 @@ layer_4/name = "Environment Top"
layer_4/z_index = 2
layer_4/tile_data = PackedInt32Array()
layer_5/name = "Mountain"
-layer_5/z_index = -1
+layer_5/y_sort_enabled = true
layer_5/tile_data = PackedInt32Array()
layer_6/name = "Mountain 2"
layer_6/z_index = -1
layer_6/tile_data = PackedInt32Array()
+layer_7/name = "Mountain 3"
+layer_7/z_index = 2
+layer_7/tile_data = PackedInt32Array()
+layer_8/name = "Mountain 4"
+layer_8/z_index = 4
+layer_8/tile_data = PackedInt32Array()
script = ExtResource("3_e12vf")