End of lesson 29
This commit is contained in:
parent
75cbdf40b2
commit
2d87794af9
|
|
@ -31,6 +31,11 @@ window/size/window_height_override=720
|
||||||
window/stretch/mode="viewport"
|
window/stretch/mode="viewport"
|
||||||
window/stretch/scale_mode="integer"
|
window/stretch/scale_mode="integer"
|
||||||
|
|
||||||
|
[layer_names]
|
||||||
|
|
||||||
|
2d_physics/layer_1="Map"
|
||||||
|
2d_physics/layer_2="Player"
|
||||||
|
|
||||||
[rendering]
|
[rendering]
|
||||||
|
|
||||||
textures/canvas_textures/default_texture_filter=0
|
textures/canvas_textures/default_texture_filter=0
|
||||||
|
|
|
||||||
|
|
@ -141,12 +141,10 @@ frame_progress = 0.497982
|
||||||
[node name="CollisionRayCast_1" type="RayCast2D" parent="."]
|
[node name="CollisionRayCast_1" type="RayCast2D" parent="."]
|
||||||
position = Vector2(8, 8)
|
position = Vector2(8, 8)
|
||||||
target_position = Vector2(0, 16)
|
target_position = Vector2(0, 16)
|
||||||
collide_with_areas = true
|
|
||||||
|
|
||||||
[node name="CollisionRayCast_2" type="RayCast2D" parent="."]
|
[node name="CollisionRayCast_2" type="RayCast2D" parent="."]
|
||||||
position = Vector2(8, 8)
|
position = Vector2(8, 8)
|
||||||
target_position = Vector2(0, 16)
|
target_position = Vector2(0, 16)
|
||||||
collide_with_areas = true
|
|
||||||
|
|
||||||
[node name="Area2D" type="Area2D" parent="."]
|
[node name="Area2D" type="Area2D" parent="."]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,4 +8,4 @@ script = ExtResource("2_us7jc")
|
||||||
camera = NodePath("Camera2D")
|
camera = NodePath("Camera2D")
|
||||||
|
|
||||||
[node name="Camera2D" type="Camera2D" parent="." index="3"]
|
[node name="Camera2D" type="Camera2D" parent="." index="3"]
|
||||||
zoom = Vector2(1.5, 1.5)
|
zoom = Vector2(2, 2)
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -18,4 +18,10 @@ func spawnPlayerAtPosition(position, facing):
|
||||||
|
|
||||||
super.spawnPlayerAtPosition(position, facing)
|
super.spawnPlayerAtPosition(position, facing)
|
||||||
|
|
||||||
return player
|
player.updateFacing(facing)
|
||||||
|
|
||||||
|
get_node("Entities").add_child(player)
|
||||||
|
|
||||||
|
|
||||||
|
func playerCanMoveTo(position:Vector2) -> bool:
|
||||||
|
return !player.wouldCollideAt(position)
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ func _process(delta: float) -> void:
|
||||||
|
|
||||||
call_deferred("add_child", map)
|
call_deferred("add_child", map)
|
||||||
|
|
||||||
map.spawnPlayerAtPosition(newSpawnpoint, newSpawnpoint)
|
map.spawnPlayerAtPosition(newSpawnpoint, newFacing)
|
||||||
|
|
||||||
CommandDispatcher.LOAD_COMPLETE.emit()
|
CommandDispatcher.LOAD_COMPLETE.emit()
|
||||||
CommandDispatcher.WAIT_FOR_COMMAND.emit()
|
CommandDispatcher.WAIT_FOR_COMMAND.emit()
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
extends Map2d
|
||||||
|
|
||||||
|
class_name TownMap
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
uid://dcg3hnc5yq61d
|
||||||
|
|
@ -54,3 +54,29 @@ func updateAnimation(direction):
|
||||||
animator.frame = 0
|
animator.frame = 0
|
||||||
else:
|
else:
|
||||||
animator.frame += 1
|
animator.frame += 1
|
||||||
|
|
||||||
|
|
||||||
|
func updateFacing(direction):
|
||||||
|
var sequence
|
||||||
|
|
||||||
|
match(direction):
|
||||||
|
Map.Direction.East:
|
||||||
|
sequence = "Idle Right"
|
||||||
|
Map.Direction.West:
|
||||||
|
sequence = "Idle Left"
|
||||||
|
Map.Direction.North:
|
||||||
|
sequence = "Idle Up"
|
||||||
|
Map.Direction.South:
|
||||||
|
sequence = "Idle Down"
|
||||||
|
|
||||||
|
animator.animation = sequence
|
||||||
|
animator.frame = 0
|
||||||
|
|
||||||
|
|
||||||
|
func wouldCollideAt(destination):
|
||||||
|
updateRaycasts(destination)
|
||||||
|
|
||||||
|
if collisionRay_1.is_colliding() || collisionRay_2.is_colliding():
|
||||||
|
CommandDispatcher.DISPLAY_MESSAGE.emit("Your path is blocked.")
|
||||||
|
|
||||||
|
return true
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,9 @@ texture = ExtResource("1_wune4")
|
||||||
7:0/0 = 0
|
7:0/0 = 0
|
||||||
8:0/0 = 0
|
8:0/0 = 0
|
||||||
9:0/0 = 0
|
9:0/0 = 0
|
||||||
|
9:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(8, -8, 8, 8, -8, 8, -2.69788, -2.87774)
|
||||||
10:0/0 = 0
|
10:0/0 = 0
|
||||||
|
10:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 3.23746, -2.1583, 8, 8, -8, 8)
|
||||||
11:0/0 = 0
|
11:0/0 = 0
|
||||||
12:0/0 = 0
|
12:0/0 = 0
|
||||||
13:0/0 = 0
|
13:0/0 = 0
|
||||||
|
|
@ -38,7 +40,9 @@ texture = ExtResource("1_wune4")
|
||||||
7:1/0 = 0
|
7:1/0 = 0
|
||||||
8:1/0 = 0
|
8:1/0 = 0
|
||||||
9:1/0 = 0
|
9:1/0 = 0
|
||||||
|
9:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 3.95689, 1.07915, -0.359718, 8, 5.2159, 4.85619, 8, 8, 8, -8)
|
||||||
10:1/0 = 0
|
10:1/0 = 0
|
||||||
|
10:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, 6.29506, -4.85619, 4.13675, -0.539576, 5.57562, -4.13675, -1.43887, 3.23746, -3.95689, 6.47491, -8, -8, -8)
|
||||||
11:1/0 = 0
|
11:1/0 = 0
|
||||||
12:1/0 = 0
|
12:1/0 = 0
|
||||||
13:1/0 = 0
|
13:1/0 = 0
|
||||||
|
|
@ -54,6 +58,7 @@ texture = ExtResource("1_wune4")
|
||||||
1:2/0 = 0
|
1:2/0 = 0
|
||||||
1:2/0/custom_data_0 = "Forest"
|
1:2/0/custom_data_0 = "Forest"
|
||||||
2:2/0 = 0
|
2:2/0 = 0
|
||||||
|
2:2/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
|
||||||
3:2/0 = 0
|
3:2/0 = 0
|
||||||
4:2/0 = 0
|
4:2/0 = 0
|
||||||
5:2/0 = 0
|
5:2/0 = 0
|
||||||
|
|
@ -272,15 +277,20 @@ texture = ExtResource("1_wune4")
|
||||||
6:14/0 = 0
|
6:14/0 = 0
|
||||||
7:14/0 = 0
|
7:14/0 = 0
|
||||||
8:14/0 = 0
|
8:14/0 = 0
|
||||||
|
8:14/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
|
||||||
9:14/0 = 0
|
9:14/0 = 0
|
||||||
10:14/0 = 0
|
10:14/0 = 0
|
||||||
11:14/0 = 0
|
11:14/0 = 0
|
||||||
12:14/0 = 0
|
12:14/0 = 0
|
||||||
15:14/0 = 0
|
15:14/0 = 0
|
||||||
16:14/0 = 0
|
16:14/0 = 0
|
||||||
|
16:14/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
|
||||||
17:14/0 = 0
|
17:14/0 = 0
|
||||||
|
17:14/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
|
||||||
18:14/0 = 0
|
18:14/0 = 0
|
||||||
|
18:14/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
|
||||||
19:14/0 = 0
|
19:14/0 = 0
|
||||||
|
19:14/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
|
||||||
22:14/0 = 0
|
22:14/0 = 0
|
||||||
23:14/0 = 0
|
23:14/0 = 0
|
||||||
24:14/0 = 0
|
24:14/0 = 0
|
||||||
|
|
@ -299,7 +309,9 @@ texture = ExtResource("1_wune4")
|
||||||
14:15/0 = 0
|
14:15/0 = 0
|
||||||
15:15/0 = 0
|
15:15/0 = 0
|
||||||
16:15/0 = 0
|
16:15/0 = 0
|
||||||
|
16:15/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
|
||||||
19:15/0 = 0
|
19:15/0 = 0
|
||||||
|
19:15/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
|
||||||
20:15/0 = 0
|
20:15/0 = 0
|
||||||
22:15/0 = 0
|
22:15/0 = 0
|
||||||
24:15/0 = 0
|
24:15/0 = 0
|
||||||
|
|
@ -313,9 +325,12 @@ texture = ExtResource("1_wune4")
|
||||||
14:16/0 = 0
|
14:16/0 = 0
|
||||||
15:16/0 = 0
|
15:16/0 = 0
|
||||||
16:16/0 = 0
|
16:16/0 = 0
|
||||||
|
16:16/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
|
||||||
17:16/0 = 0
|
17:16/0 = 0
|
||||||
18:16/0 = 0
|
18:16/0 = 0
|
||||||
|
18:16/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
|
||||||
19:16/0 = 0
|
19:16/0 = 0
|
||||||
|
19:16/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
|
||||||
20:16/0 = 0
|
20:16/0 = 0
|
||||||
21:16/0 = 0
|
21:16/0 = 0
|
||||||
22:16/0 = 0
|
22:16/0 = 0
|
||||||
|
|
@ -385,7 +400,9 @@ texture = ExtResource("1_wune4")
|
||||||
27:20/0 = 0
|
27:20/0 = 0
|
||||||
28:20/0 = 0
|
28:20/0 = 0
|
||||||
0:21/0 = 0
|
0:21/0 = 0
|
||||||
|
0:21/0/physics_layer_0/polygon_0/points = PackedVector2Array(8, 8, -6.29506, 8, -1.43887, -3.0576, 8, -8)
|
||||||
1:21/0 = 0
|
1:21/0 = 0
|
||||||
|
1:21/0/physics_layer_0/polygon_0/points = PackedVector2Array(-2.33816, -8, 8, 8, -8, 8, -8, -8)
|
||||||
2:21/0 = 0
|
2:21/0 = 0
|
||||||
3:21/0 = 0
|
3:21/0 = 0
|
||||||
4:21/0 = 0
|
4:21/0 = 0
|
||||||
|
|
@ -411,7 +428,9 @@ texture = ExtResource("1_wune4")
|
||||||
27:21/0 = 0
|
27:21/0 = 0
|
||||||
28:21/0 = 0
|
28:21/0 = 0
|
||||||
0:22/0 = 0
|
0:22/0 = 0
|
||||||
|
0:22/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 2.69788, -0.359716, -0.719435, 6.1152, 8, 6.29506, 8, -8)
|
||||||
1:22/0 = 0
|
1:22/0 = 0
|
||||||
|
1:22/0/physics_layer_0/polygon_0/points = PackedVector2Array(5.93534, -8, -2.1583, -1.79859, 0.719435, 4.85619, -8, 5.03605, -8, -8)
|
||||||
2:22/0 = 0
|
2:22/0 = 0
|
||||||
3:22/0 = 0
|
3:22/0 = 0
|
||||||
4:22/0 = 0
|
4:22/0 = 0
|
||||||
|
|
@ -1964,6 +1983,8 @@ texture = ExtResource("2_rj42e")
|
||||||
48:21/0 = 0
|
48:21/0 = 0
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
|
physics_layer_0/collision_layer = 1
|
||||||
|
physics_layer_0/collision_mask = 2
|
||||||
custom_data_layer_0/name = "TerrainType"
|
custom_data_layer_0/name = "TerrainType"
|
||||||
custom_data_layer_0/type = 4
|
custom_data_layer_0/type = 4
|
||||||
sources/0 = SubResource("TileSetAtlasSource_no1mq")
|
sources/0 = SubResource("TileSetAtlasSource_no1mq")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue