diff options
| -rw-r--r-- | assets/definitions/actor/Player.tres | 4 | ||||
| -rw-r--r-- | assets/definitions/actor/Skeleton.tres | 4 | ||||
| -rw-r--r-- | scenes/DungeonLevel.tscn | 17 | ||||
| -rw-r--r-- | scenes/Game.tscn | 4 | ||||
| -rw-r--r-- | scenes/Player.tscn | 4 | ||||
| -rw-r--r-- | scenes/Skeleton.tscn | 4 | ||||
| -rw-r--r-- | scripts/DungeonLevel.cs | 9 | ||||
| -rw-r--r-- | scripts/Enemy.cs | 4 | ||||
| -rw-r--r-- | scripts/Game.cs | 11 | ||||
| -rw-r--r-- | scripts/actors/Actor.cs | 11 | ||||
| -rw-r--r-- | scripts/actors/ActorDefinition.cs | 2 | ||||
| -rw-r--r-- | scripts/actors/Player.cs | 4 |
12 files changed, 46 insertions, 32 deletions
diff --git a/assets/definitions/actor/Player.tres b/assets/definitions/actor/Player.tres index 4b9b172..798bfde 100644 --- a/assets/definitions/actor/Player.tres +++ b/assets/definitions/actor/Player.tres @@ -1,9 +1,11 @@ -[gd_resource type="Resource" script_class="ActorDefinition" load_steps=2 format=3 uid="uid://cn6xnpwxjudbp"] +[gd_resource type="Resource" script_class="ActorDefinition" load_steps=3 format=3 uid="uid://cn6xnpwxjudbp"] [ext_resource type="Script" uid="uid://crxw1e37xlrrt" path="res://scripts/actors/ActorDefinition.cs" id="1_2k33r"] +[ext_resource type="Texture2D" uid="uid://dwky8qc2y602k" path="res://assets/sprites/character.png" id="2_2xyvf"] [resource] script = ExtResource("1_2k33r") name = "Jogador" +texture = ExtResource("2_2xyvf") blocksMovement = true metadata/_custom_type_script = "uid://crxw1e37xlrrt" diff --git a/assets/definitions/actor/Skeleton.tres b/assets/definitions/actor/Skeleton.tres index 687bcee..be38337 100644 --- a/assets/definitions/actor/Skeleton.tres +++ b/assets/definitions/actor/Skeleton.tres @@ -1,9 +1,11 @@ -[gd_resource type="Resource" script_class="ActorDefinition" load_steps=2 format=3 uid="uid://bphsl6o2nsb8x"] +[gd_resource type="Resource" script_class="ActorDefinition" load_steps=3 format=3 uid="uid://bphsl6o2nsb8x"] [ext_resource type="Script" uid="uid://crxw1e37xlrrt" path="res://scripts/actors/ActorDefinition.cs" id="1_m5x88"] +[ext_resource type="Texture2D" uid="uid://dh5sgjdwkps88" path="res://assets/sprites/skeleton.png" id="2_hhidw"] [resource] script = ExtResource("1_m5x88") name = "Eis que leto" +texture = ExtResource("2_hhidw") blocksMovement = true metadata/_custom_type_script = "uid://crxw1e37xlrrt" diff --git a/scenes/DungeonLevel.tscn b/scenes/DungeonLevel.tscn index 4a5fda0..201dd69 100644 --- a/scenes/DungeonLevel.tscn +++ b/scenes/DungeonLevel.tscn @@ -1,25 +1,14 @@ -[gd_scene load_steps=5 format=4 uid="uid://dnh8xgk1w76i2"] +[gd_scene load_steps=3 format=4 uid="uid://dnh8xgk1w76i2"] [ext_resource type="TileSet" uid="uid://biilh0ufacguh" path="res://assets/test_tileset.tres" id="1_bxfih"] [ext_resource type="Script" uid="uid://cy7qumrpks2kx" path="res://scripts/DungeonLevel.cs" id="1_u6mlv"] -[ext_resource type="PackedScene" uid="uid://c3wbuxeetj24a" path="res://scenes/Player.tscn" id="2_u6mlv"] -[ext_resource type="PackedScene" uid="uid://cnkx22hgs0b3p" path="res://scenes/Skeleton.tscn" id="4_8elbs"] -[node name="Map" type="Node2D" node_paths=PackedStringArray("Actors")] +[node name="Map" type="Node2D"] script = ExtResource("1_u6mlv") -Actors = [NodePath("Actors/Player"), NodePath("Actors/Skeleton")] [node name="Dungeon" type="TileMapLayer" parent="."] texture_filter = 1 -tile_map_data = PackedByteArray("AAAHAAcAAAAAAAAAAAAIAAcAAAAAAAAAAAAJAAcAAAAAAAAAAAAKAAcAAAAAAAAAAAALAAcAAAAAAAAAAAAMAAcAAAAAAAAAAAANAAcAAAAAAAAAAAAOAAcAAAAAAAAAAAAOAAgAAAAAAAAAAAANAAgAAAAAAAAAAAAMAAgAAAAAAAAAAAALAAgAAAAAAAAAAAAKAAgAAAAAAAA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AgAAAAAAAAAAAATAAgAAAAAAAAAAAAUAAkAAAAAAAAAAAATAAkAAAAAAAAAAAARAAcAAAAAAAAAAAAQAAcAAAAAAAAAAAAQAAYAAAAAAAAAAAAQAAUAAAAAAAAAAAARAAUAAAABAAAAAAARAAQAAAAAAAAAAAASAAQAAAAAAAAAAAATAAQAAAAAAAAAAAAUAAQAAAAAAAAAAAAUAAUAAAAAAAAAAAAVAAUAAAABAAAAAAAVAAYAAAAAAAAAAAAVAAcAAAABAAAAAAAVAAgAAAABAAAAAAAVAAkAAAAAAAAAAAASAAcAAAAAAAAAAAASAAYAAAABAAAAAAASAAUAAAABAAAAAAATAAUAAAAAAAAAAAAUAAYAAAAAAAAAAAAUAAcAAAABAAAAAAAUAAgAAAABAAAAAAATAAcAAAAAAAAAAAATAAYAAAAAAAAAAAAQAAQAAAAAAAAAAAAQAAgAAAAAAAAAAAARAAYAAAABAAAAAAASAAkAAAAAAAAAAAAWAAkAAAAAAAAAAAAWAAgAAAAAAAAAAAAWAAcAAAAAAAAAAAAWAAYAAAAAAAAAAAAWAAUAAAAAAAAAAAAWAAQAAAAAAAAAAAAVAAQAAAAAAAAAAAAKAAoAAAAAAAAAAAAJAAsAAAABAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAABAAEAAAAAAAAAAAABAAIAAAAAAAAAAAABAAMAAAAAAAAAAAABAAQAAAAAAAAAAAABAAUAAAAAAAAAAAABAAYAAAAAAAAAAAABAAcAAAAAAAAAAAABAAgAAAAAAAAAAAACAAgAAAAAAAAAAAADAAgAAAAAAAAAAAA=") tile_set = ExtResource("1_bxfih") [node name="Actors" type="Node2D" parent="."] - -[node name="Player" parent="Actors" node_paths=PackedStringArray("Map") instance=ExtResource("2_u6mlv")] -position = Vector2(144, 144) -Map = NodePath("../..") - -[node name="Skeleton" parent="Actors" node_paths=PackedStringArray("Map") instance=ExtResource("4_8elbs")] -position = Vector2(160, 128) -Map = NodePath("../..") diff --git a/scenes/Game.tscn b/scenes/Game.tscn index 6d1a2be..361f821 100644 --- a/scenes/Game.tscn +++ b/scenes/Game.tscn @@ -11,3 +11,7 @@ script = ExtResource("1_cpr0p") [node name="InputHandler" type="Node" parent="."] script = ExtResource("3_s0nni") + +[node name="Camera2D" type="Camera2D" parent="."] +offset = Vector2(8, 8) +zoom = Vector2(2, 2) diff --git a/scenes/Player.tscn b/scenes/Player.tscn index d95d726..4d9d5e5 100644 --- a/scenes/Player.tscn +++ b/scenes/Player.tscn @@ -1,14 +1,12 @@ -[gd_scene load_steps=4 format=3 uid="uid://c3wbuxeetj24a"] +[gd_scene load_steps=3 format=3 uid="uid://bwo8ju6quv6co"] [ext_resource type="Script" uid="uid://c840l08453pu2" path="res://scripts/actors/Player.cs" id="1_p0vlq"] [ext_resource type="Texture2D" uid="uid://dwky8qc2y602k" path="res://assets/sprites/character.png" id="1_v6fml"] -[ext_resource type="Resource" uid="uid://cn6xnpwxjudbp" path="res://assets/definitions/actor/Player.tres" id="3_3li8b"] [node name="Player" type="Sprite2D"] texture = ExtResource("1_v6fml") centered = false script = ExtResource("1_p0vlq") -definition = ExtResource("3_3li8b") [node name="Camera2D" type="Camera2D" parent="."] offset = Vector2(8, 8) diff --git a/scenes/Skeleton.tscn b/scenes/Skeleton.tscn index ad78474..fce5c1e 100644 --- a/scenes/Skeleton.tscn +++ b/scenes/Skeleton.tscn @@ -1,11 +1,9 @@ -[gd_scene load_steps=4 format=3 uid="uid://cnkx22hgs0b3p"] +[gd_scene load_steps=3 format=3 uid="uid://byyjwp5j4byux"] [ext_resource type="Texture2D" uid="uid://dh5sgjdwkps88" path="res://assets/sprites/skeleton.png" id="1_s4oxe"] [ext_resource type="Script" uid="uid://bef1fo3vgvxej" path="res://scripts/Enemy.cs" id="2_at7gs"] -[ext_resource type="Resource" uid="uid://bphsl6o2nsb8x" path="res://assets/definitions/actor/Skeleton.tres" id="3_at7gs"] [node name="Skeleton" type="Sprite2D"] texture = ExtResource("1_s4oxe") centered = false script = ExtResource("2_at7gs") -definition = ExtResource("3_at7gs") diff --git a/scripts/DungeonLevel.cs b/scripts/DungeonLevel.cs index cdafdca..68751c5 100644 --- a/scripts/DungeonLevel.cs +++ b/scripts/DungeonLevel.cs @@ -3,12 +3,9 @@ using System; public partial class DungeonLevel : Node2D { - public Player player; private TileMapLayer buildingLayer; - [Export] public Godot.Collections.Array<Actor> Actors { get; private set; } = []; - private Node2D actorsNode; public override void _Ready() @@ -17,7 +14,11 @@ public partial class DungeonLevel : Node2D buildingLayer = GetNode<TileMapLayer>("Dungeon"); actorsNode = GetNode<Node2D>("Actors"); - player = actorsNode.GetNode<Player>("Player"); + } + + public void InsertActor(Actor actor) { + Actors.Add(actor); + actorsNode.AddChild(actor); } public bool IsTileWalkable(Vector2I pos) { diff --git a/scripts/Enemy.cs b/scripts/Enemy.cs index 29a85b7..921cd86 100644 --- a/scripts/Enemy.cs +++ b/scripts/Enemy.cs @@ -3,5 +3,7 @@ using System; public partial class Enemy : Actor { - + public Enemy(Vector2I initialPosition, DungeonLevel map, ActorDefinition definition) : base(initialPosition, map, definition) + { + } } diff --git a/scripts/Game.cs b/scripts/Game.cs index 067f4a4..f5c5240 100644 --- a/scripts/Game.cs +++ b/scripts/Game.cs @@ -2,6 +2,7 @@ using Godot; using System; public partial class Game : Node { + private static readonly ActorDefinition playerDefinition = GD.Load<ActorDefinition>("res://assets/definitions/actor/Player.tres"); private Player player; public DungeonLevel Map { get; private set; } private InputHandler inputHandler; @@ -12,8 +13,14 @@ public partial class Game : Node { Map = GetNode<DungeonLevel>("Map"); inputHandler = GetNode<InputHandler>("InputHandler"); - - player = Map.player; + + player = new Player(new Vector2I(0, 0), Map, playerDefinition); + Camera2D camera = GetNode<Camera2D>("Camera2D"); + RemoveChild(camera); + + player.AddChild(camera); + + Map.InsertActor(player); } public override void _PhysicsProcess(double delta) { diff --git a/scripts/actors/Actor.cs b/scripts/actors/Actor.cs index f429ead..7e9ab04 100644 --- a/scripts/actors/Actor.cs +++ b/scripts/actors/Actor.cs @@ -3,11 +3,18 @@ using Godot; [GlobalClass] public abstract partial class Actor : Sprite2D { - [Export] private ActorDefinition definition; private Vector2I gridPosition = Vector2I.Zero; - [Export] public DungeonLevel Map { get; private set; } + + public Actor(Vector2I initialPosition, DungeonLevel map, ActorDefinition definition) { + GridPosition = initialPosition; + Map = map; + this.definition = definition; + Texture = definition.texture; + Centered = false; + } + public Vector2I GridPosition { set { gridPosition = value; diff --git a/scripts/actors/ActorDefinition.cs b/scripts/actors/ActorDefinition.cs index 58a749c..5678921 100644 --- a/scripts/actors/ActorDefinition.cs +++ b/scripts/actors/ActorDefinition.cs @@ -7,6 +7,8 @@ public partial class ActorDefinition : Resource [ExportCategory("Visuals")] [Export] public string name = "unnamed"; + [Export] + public Texture2D texture; [ExportCategory("Mechanics")] [Export] diff --git a/scripts/actors/Player.cs b/scripts/actors/Player.cs index c8abe12..590020d 100644 --- a/scripts/actors/Player.cs +++ b/scripts/actors/Player.cs @@ -4,5 +4,7 @@ using System; [GlobalClass] public partial class Player : Actor { - + public Player(Vector2I initialPosition, DungeonLevel map, ActorDefinition definition) : base(initialPosition, map, definition) + { + } } |
