summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatheus <matheus.guedes.mg.m@gmail.com>2025-08-16 14:22:04 -0300
committerMatheus <matheus.guedes.mg.m@gmail.com>2025-08-16 14:22:04 -0300
commitc411c496394c7a782854e03f2be8fab4cc1e2a81 (patch)
tree6cecaa0f70c9b3fd49a9fce9b383d46c27c41dcd
parent588a80a339a64f15b2e3bada550beb14e16abe3e (diff)
Herança e preparativos para o sistema de turnos
-rw-r--r--assets/sprites/skeleton.pngbin0 -> 215 bytes
-rw-r--r--assets/sprites/skeleton.png.import34
-rw-r--r--assets/sprites/skeleton.pxobin0 -> 838 bytes
-rw-r--r--project.godot4
-rw-r--r--scenes/skeleton.tscn8
-rw-r--r--scenes/test_map.tscn11
-rw-r--r--scripts/Actor.cs18
-rw-r--r--scripts/Actor.cs.uid1
-rw-r--r--scripts/Character.cs16
-rw-r--r--scripts/Enemy.cs6
-rw-r--r--scripts/Enemy.cs.uid1
11 files changed, 81 insertions, 18 deletions
diff --git a/assets/sprites/skeleton.png b/assets/sprites/skeleton.png
new file mode 100644
index 0000000..224afc6
--- /dev/null
+++ b/assets/sprites/skeleton.png
Binary files differ
diff --git a/assets/sprites/skeleton.png.import b/assets/sprites/skeleton.png.import
new file mode 100644
index 0000000..4b41cb3
--- /dev/null
+++ b/assets/sprites/skeleton.png.import
@@ -0,0 +1,34 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://dh5sgjdwkps88"
+path="res://.godot/imported/skeleton.png-3c82138048422abf990547c960b9a428.ctex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://assets/sprites/skeleton.png"
+dest_files=["res://.godot/imported/skeleton.png-3c82138048422abf990547c960b9a428.ctex"]
+
+[params]
+
+compress/mode=0
+compress/high_quality=false
+compress/lossy_quality=0.7
+compress/hdr_compression=1
+compress/normal_map=0
+compress/channel_pack=0
+mipmaps/generate=false
+mipmaps/limit=-1
+roughness/mode=0
+roughness/src_normal=""
+process/fix_alpha_border=true
+process/premult_alpha=false
+process/normal_map_invert_y=false
+process/hdr_as_srgb=false
+process/hdr_clamp_exposure=false
+process/size_limit=0
+detect_3d/compress_to=1
diff --git a/assets/sprites/skeleton.pxo b/assets/sprites/skeleton.pxo
new file mode 100644
index 0000000..d2cfbf3
--- /dev/null
+++ b/assets/sprites/skeleton.pxo
Binary files differ
diff --git a/project.godot b/project.godot
index fb9e219..bace009 100644
--- a/project.godot
+++ b/project.godot
@@ -41,3 +41,7 @@ walk-right={
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194321,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
]
}
+
+[rendering]
+
+textures/canvas_textures/default_texture_filter=0
diff --git a/scenes/skeleton.tscn b/scenes/skeleton.tscn
new file mode 100644
index 0000000..8471909
--- /dev/null
+++ b/scenes/skeleton.tscn
@@ -0,0 +1,8 @@
+[gd_scene load_steps=3 format=3 uid="uid://bsn4a4tfensy8"]
+
+[ext_resource type="Texture2D" uid="uid://dh5sgjdwkps88" path="res://assets/sprites/skeleton.png" id="1_pbvs3"]
+[ext_resource type="Script" uid="uid://bef1fo3vgvxej" path="res://scripts/Enemy.cs" id="2_txkty"]
+
+[node name="Skeleton" type="Sprite2D"]
+texture = ExtResource("1_pbvs3")
+script = ExtResource("2_txkty")
diff --git a/scenes/test_map.tscn b/scenes/test_map.tscn
index 14a3aa4..446e6d7 100644
--- a/scenes/test_map.tscn
+++ b/scenes/test_map.tscn
@@ -1,7 +1,8 @@
-[gd_scene load_steps=3 format=4 uid="uid://u5h6iqyi8wd0"]
+[gd_scene load_steps=4 format=4 uid="uid://u5h6iqyi8wd0"]
[ext_resource type="TileSet" uid="uid://biilh0ufacguh" path="res://assets/test_tileset.tres" id="1_57l66"]
[ext_resource type="PackedScene" uid="uid://bl01llfbscv6r" path="res://scenes/character.tscn" id="2_fn2sa"]
+[ext_resource type="PackedScene" uid="uid://bsn4a4tfensy8" path="res://scenes/skeleton.tscn" id="3_57l66"]
[node name="Node2D" type="Node2D"]
@@ -14,6 +15,10 @@ tile_set = ExtResource("1_57l66")
anchor_mode = 0
zoom = Vector2(2, 2)
-[node name="Character" parent="." node_paths=PackedStringArray("map") instance=ExtResource("2_fn2sa")]
+[node name="Character" parent="." node_paths=PackedStringArray("Map") instance=ExtResource("2_fn2sa")]
position = Vector2(135, 135)
-map = NodePath("../Map")
+Map = NodePath("../Map")
+
+[node name="Skeleon" parent="." node_paths=PackedStringArray("Map") instance=ExtResource("3_57l66")]
+position = Vector2(184, 136)
+Map = NodePath("../Map")
diff --git a/scripts/Actor.cs b/scripts/Actor.cs
new file mode 100644
index 0000000..fc69edf
--- /dev/null
+++ b/scripts/Actor.cs
@@ -0,0 +1,18 @@
+using Godot;
+
+public partial class Actor : Node2D {
+ [Export]
+ public TileMapLayer Map { get; set; }
+
+ protected void Walk(Vector2I offset) {
+ Vector2I toMovePos = Map.LocalToMap(Position);
+ toMovePos += offset;
+
+ TileData tile = Map.GetCellTileData(toMovePos);
+
+ if (tile.HasCustomData("isWalkable") && (bool) tile.GetCustomData("isWalkable")) {
+ GD.Print(toMovePos);
+ Position = Map.MapToLocal(toMovePos);
+ }
+ }
+} \ No newline at end of file
diff --git a/scripts/Actor.cs.uid b/scripts/Actor.cs.uid
new file mode 100644
index 0000000..cf29b40
--- /dev/null
+++ b/scripts/Actor.cs.uid
@@ -0,0 +1 @@
+uid://c0cm4woy8lawl
diff --git a/scripts/Character.cs b/scripts/Character.cs
index 1e11fcc..e3707f5 100644
--- a/scripts/Character.cs
+++ b/scripts/Character.cs
@@ -1,9 +1,7 @@
using Godot;
using System;
-public partial class Character : Sprite2D {
- [Export]
- public TileMapLayer map;
+public partial class Character : Actor {
public override void _Input(InputEvent @event)
{
@@ -30,16 +28,4 @@ public partial class Character : Sprite2D {
Walk(offset);
}
}
-
- private void Walk(Vector2I offset) {
- Vector2I toMovePos = map.LocalToMap(Position);
- toMovePos += offset;
-
- TileData tile = map.GetCellTileData(toMovePos);
-
- if (tile.HasCustomData("isWalkable") && (bool) tile.GetCustomData("isWalkable")) {
- GD.Print(toMovePos);
- Position = map.MapToLocal(toMovePos);
- }
- }
}
diff --git a/scripts/Enemy.cs b/scripts/Enemy.cs
new file mode 100644
index 0000000..6f48bd1
--- /dev/null
+++ b/scripts/Enemy.cs
@@ -0,0 +1,6 @@
+using Godot;
+using System;
+
+public partial class Enemy : Actor {
+
+}
diff --git a/scripts/Enemy.cs.uid b/scripts/Enemy.cs.uid
new file mode 100644
index 0000000..93255b7
--- /dev/null
+++ b/scripts/Enemy.cs.uid
@@ -0,0 +1 @@
+uid://bef1fo3vgvxej