From 579a2fe0f837236eec5d9f9347baa8f6a49f6458 Mon Sep 17 00:00:00 2001 From: Matheus Date: Sat, 16 Aug 2025 00:12:15 -0300 Subject: Personagem que anda --- assets/sprites/character.png | Bin 0 -> 277 bytes assets/sprites/character.png.import | 34 ++++++++++++++++++++++++++++++++++ assets/sprites/tilemap.png | Bin 0 -> 397 bytes assets/sprites/tilemap.png.import | 34 ++++++++++++++++++++++++++++++++++ assets/test_tileset.tres | 14 ++++++++++++++ 5 files changed, 82 insertions(+) create mode 100644 assets/sprites/character.png create mode 100644 assets/sprites/character.png.import create mode 100644 assets/sprites/tilemap.png create mode 100644 assets/sprites/tilemap.png.import create mode 100644 assets/test_tileset.tres (limited to 'assets') diff --git a/assets/sprites/character.png b/assets/sprites/character.png new file mode 100644 index 0000000..184119a Binary files /dev/null and b/assets/sprites/character.png differ diff --git a/assets/sprites/character.png.import b/assets/sprites/character.png.import new file mode 100644 index 0000000..81e46a6 --- /dev/null +++ b/assets/sprites/character.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dwky8qc2y602k" +path="res://.godot/imported/character.png-529a34c9bb84961fe0878b6df0db59b4.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/sprites/character.png" +dest_files=["res://.godot/imported/character.png-529a34c9bb84961fe0878b6df0db59b4.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/tilemap.png b/assets/sprites/tilemap.png new file mode 100644 index 0000000..dece7ed Binary files /dev/null and b/assets/sprites/tilemap.png differ diff --git a/assets/sprites/tilemap.png.import b/assets/sprites/tilemap.png.import new file mode 100644 index 0000000..639070f --- /dev/null +++ b/assets/sprites/tilemap.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://8lincth7scjr" +path="res://.godot/imported/tilemap.png-97bf26cbe4098c4ccdc8ca24f9406864.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/sprites/tilemap.png" +dest_files=["res://.godot/imported/tilemap.png-97bf26cbe4098c4ccdc8ca24f9406864.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/test_tileset.tres b/assets/test_tileset.tres new file mode 100644 index 0000000..0c582c4 --- /dev/null +++ b/assets/test_tileset.tres @@ -0,0 +1,14 @@ +[gd_resource type="TileSet" load_steps=3 format=3 uid="uid://biilh0ufacguh"] + +[ext_resource type="Texture2D" uid="uid://8lincth7scjr" path="res://assets/sprites/tilemap.png" id="1_sdj6w"] + +[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_siwt3"] +texture = ExtResource("1_sdj6w") +0:0/0 = 0 +0:0/0/custom_data_0 = true +1:0/0 = 0 + +[resource] +custom_data_layer_0/name = "isWalkable" +custom_data_layer_0/type = 1 +sources/0 = SubResource("TileSetAtlasSource_siwt3") -- cgit v1.2.3 From c411c496394c7a782854e03f2be8fab4cc1e2a81 Mon Sep 17 00:00:00 2001 From: Matheus Date: Sat, 16 Aug 2025 14:22:04 -0300 Subject: Herança e preparativos para o sistema de turnos MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/sprites/skeleton.png | Bin 0 -> 215 bytes assets/sprites/skeleton.png.import | 34 ++++++++++++++++++++++++++++++++++ assets/sprites/skeleton.pxo | Bin 0 -> 838 bytes project.godot | 4 ++++ scenes/skeleton.tscn | 8 ++++++++ scenes/test_map.tscn | 11 ++++++++--- scripts/Actor.cs | 18 ++++++++++++++++++ scripts/Actor.cs.uid | 1 + scripts/Character.cs | 16 +--------------- scripts/Enemy.cs | 6 ++++++ scripts/Enemy.cs.uid | 1 + 11 files changed, 81 insertions(+), 18 deletions(-) create mode 100644 assets/sprites/skeleton.png create mode 100644 assets/sprites/skeleton.png.import create mode 100644 assets/sprites/skeleton.pxo create mode 100644 scenes/skeleton.tscn create mode 100644 scripts/Actor.cs create mode 100644 scripts/Actor.cs.uid create mode 100644 scripts/Enemy.cs create mode 100644 scripts/Enemy.cs.uid (limited to 'assets') diff --git a/assets/sprites/skeleton.png b/assets/sprites/skeleton.png new file mode 100644 index 0000000..224afc6 Binary files /dev/null and b/assets/sprites/skeleton.png 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 Binary files /dev/null and b/assets/sprites/skeleton.pxo 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 -- cgit v1.2.3