Spawn player from world index
This commit is contained in:
parent
77114f5551
commit
141d0240c2
2 changed files with 16 additions and 17 deletions
|
|
@ -2,27 +2,20 @@
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://duf0vlr2yin8l" path="res://scripts/gameplay/Player.cs" id="1_p0vlq"]
|
[ext_resource type="Script" uid="uid://duf0vlr2yin8l" path="res://scripts/gameplay/Player.cs" id="1_p0vlq"]
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_v6fml"]
|
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_p0vlq"]
|
||||||
|
|
||||||
[sub_resource type="Gradient" id="Gradient_p0vlq"]
|
|
||||||
|
|
||||||
[sub_resource type="GradientTexture2D" id="GradientTexture2D_v6fml"]
|
|
||||||
gradient = SubResource("Gradient_p0vlq")
|
|
||||||
width = 16
|
|
||||||
height = 16
|
|
||||||
|
|
||||||
[node name="Player" type="CharacterBody2D" unique_id=1675096620]
|
[node name="Player" type="CharacterBody2D" unique_id=1675096620]
|
||||||
script = ExtResource("1_p0vlq")
|
script = ExtResource("1_p0vlq")
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=1954630810]
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1337429488]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1337429488]
|
||||||
position = Vector2(-15, -16)
|
rotation = 1.5707964
|
||||||
shape = SubResource("CircleShape2D_v6fml")
|
shape = SubResource("CapsuleShape2D_p0vlq")
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="CollisionShape2D" unique_id=554119030]
|
[node name="Camera2D" type="Camera2D" parent="." unique_id=483897590]
|
||||||
position = Vector2(15, 16)
|
|
||||||
texture = SubResource("GradientTexture2D_v6fml")
|
|
||||||
|
|
||||||
[node name="ColorRect" type="ColorRect" parent="CollisionShape2D" unique_id=1178008943]
|
[node name="ColorRect" type="ColorRect" parent="." unique_id=2037024702]
|
||||||
anchors_preset = 8
|
anchors_preset = 8
|
||||||
anchor_left = 0.5
|
anchor_left = 0.5
|
||||||
anchor_top = 0.5
|
anchor_top = 0.5
|
||||||
|
|
@ -34,5 +27,3 @@ offset_right = 8.0
|
||||||
offset_bottom = 8.0
|
offset_bottom = 8.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
|
|
||||||
[node name="Camera2D" type="Camera2D" parent="." unique_id=483897590]
|
|
||||||
|
|
|
||||||
|
|
@ -51,9 +51,17 @@ public partial class ChunkManager : Node2D
|
||||||
GD.PrintErr("ChunkManager: Failed to parse world index.");
|
GD.PrintErr("ChunkManager: Failed to parse world index.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_chunkMap = _world.BuildChunkMap();
|
_chunkMap = _world.BuildChunkMap();
|
||||||
GD.Print($"World loaded: {_world.world_id}, chunks: {_chunkMap.Count}, chunk_size_px={_world.chunk_size_px}");
|
GD.Print($"World loaded: {_world.world_id}, chunks: {_chunkMap.Count}, chunk_size_px={_world.chunk_size_px}");
|
||||||
|
|
||||||
|
// After loading world index, set player spawn position
|
||||||
|
if (_player != null && _world.start_pos_px.Length == 2)
|
||||||
|
{
|
||||||
|
_player.GlobalPosition = new Vector2(
|
||||||
|
_world.start_pos_px[0],
|
||||||
|
_world.start_pos_px[1]
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _Process(double delta)
|
public override void _Process(double delta)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue