diff options
| author | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-08-16 00:12:15 -0300 |
|---|---|---|
| committer | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-08-16 00:12:15 -0300 |
| commit | 579a2fe0f837236eec5d9f9347baa8f6a49f6458 (patch) | |
| tree | b91dc6db5dccb537600aba743bd565c43c59f2da | |
| parent | e159be9bbbf005785bd2d60af8b5c3df608f28b2 (diff) | |
Personagem que anda
| -rw-r--r-- | assets/sprites/character.png | bin | 0 -> 277 bytes | |||
| -rw-r--r-- | assets/sprites/character.png.import | 34 | ||||
| -rw-r--r-- | assets/sprites/tilemap.png | bin | 0 -> 397 bytes | |||
| -rw-r--r-- | assets/sprites/tilemap.png.import | 34 | ||||
| -rw-r--r-- | assets/test_tileset.tres | 14 | ||||
| -rw-r--r-- | project.godot | 26 | ||||
| -rw-r--r-- | projeto-fantasia.csproj | 7 | ||||
| -rw-r--r-- | projeto-fantasia.sln | 19 | ||||
| -rw-r--r-- | scenes/character.tscn | 7 | ||||
| -rw-r--r-- | scenes/test_map.tscn | 21 | ||||
| -rw-r--r-- | scripts/Character.cs | 42 | ||||
| -rw-r--r-- | scripts/Character.cs.uid | 1 |
12 files changed, 204 insertions, 1 deletions
diff --git a/assets/sprites/character.png b/assets/sprites/character.png Binary files differnew file mode 100644 index 0000000..184119a --- /dev/null +++ b/assets/sprites/character.png 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 Binary files differnew file mode 100644 index 0000000..dece7ed --- /dev/null +++ b/assets/sprites/tilemap.png 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") diff --git a/project.godot b/project.godot index 154fdf2..fb9e219 100644 --- a/project.godot +++ b/project.godot @@ -11,9 +11,33 @@ config_version=5 [application] config/name="projeto-fantasia" -config/features=PackedStringArray("4.4", "Forward Plus") +run/main_scene="uid://u5h6iqyi8wd0" +config/features=PackedStringArray("4.4", "C#", "Forward Plus") config/icon="res://icon.svg" [dotnet] project/assembly_name="projeto-fantasia" + +[input] + +walk-up={ +"deadzone": 0.2, +"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":4194320,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +walk-down={ +"deadzone": 0.2, +"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":4194322,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +walk-left={ +"deadzone": 0.2, +"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":4194319,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +walk-right={ +"deadzone": 0.2, +"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) +] +} diff --git a/projeto-fantasia.csproj b/projeto-fantasia.csproj new file mode 100644 index 0000000..800a3c6 --- /dev/null +++ b/projeto-fantasia.csproj @@ -0,0 +1,7 @@ +<Project Sdk="Godot.NET.Sdk/4.4.1"> + <PropertyGroup> + <TargetFramework>net8.0</TargetFramework> + <EnableDynamicLoading>true</EnableDynamicLoading> + <RootNamespace>projetofantasia</RootNamespace> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/projeto-fantasia.sln b/projeto-fantasia.sln new file mode 100644 index 0000000..1097a72 --- /dev/null +++ b/projeto-fantasia.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "projeto-fantasia", "projeto-fantasia.csproj", "{3C8F29E9-A5E7-47BA-9DFC-53821760AA87}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + ExportDebug|Any CPU = ExportDebug|Any CPU + ExportRelease|Any CPU = ExportRelease|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3C8F29E9-A5E7-47BA-9DFC-53821760AA87}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3C8F29E9-A5E7-47BA-9DFC-53821760AA87}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3C8F29E9-A5E7-47BA-9DFC-53821760AA87}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU + {3C8F29E9-A5E7-47BA-9DFC-53821760AA87}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU + {3C8F29E9-A5E7-47BA-9DFC-53821760AA87}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU + {3C8F29E9-A5E7-47BA-9DFC-53821760AA87}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU + EndGlobalSection +EndGlobal diff --git a/scenes/character.tscn b/scenes/character.tscn new file mode 100644 index 0000000..c99e194 --- /dev/null +++ b/scenes/character.tscn @@ -0,0 +1,7 @@ +[gd_scene load_steps=2 format=3 uid="uid://bl01llfbscv6r"] + +[ext_resource type="Texture2D" uid="uid://dwky8qc2y602k" path="res://assets/sprites/character.png" id="1_agfs1"] + +[node name="Character" type="Sprite2D"] +texture_filter = 1 +texture = ExtResource("1_agfs1") diff --git a/scenes/test_map.tscn b/scenes/test_map.tscn new file mode 100644 index 0000000..427fd21 --- /dev/null +++ b/scenes/test_map.tscn @@ -0,0 +1,21 @@ +[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="Script" uid="uid://c840l08453pu2" path="res://scripts/Character.cs" id="3_57l66"] + +[node name="Node2D" type="Node2D"] + +[node name="Map" type="TileMapLayer" parent="."] +texture_filter = 1 +tile_map_data = PackedByteArray("AAAHAAcAAAAAAAAAAAAIAAcAAAAAAAAAAAAJAAcAAAAAAAAAAAAKAAcAAAAAAAAAAAALAAcAAAAAAAAAAAAMAAcAAAAAAAAAAAANAAcAAAAAAAAAAAAOAAcAAAAAAAAAAAAOAAgAAAAAAAAAAAANAAgAAAAAAAAAAAAMAAgAAAAAAAAAAAALAAgAAAAAAAAAAAAKAAgAAAAAAAAAAAAJAAgAAAAAAAAAAAAIAAgAAAAAAAAAAAAHAAgAAAAAAAAAAAAHAAkAAAAAAAAAAAAIAAkAAAAAAAAAAAAKAAkAAAAAAAAAAAALAAkAAAAAAAAAAAAMAAkAAAAAAAAAAAANAAkAAAAAAAAAAAAOAAkAAAAAAAAAAAAJAAkAAAAAAAAAAAAGAAYAAAABAAAAAAAGAAcAAAABAAAAAAAGAAgAAAAAAAAAAAAGAAkAAAABAAAAAAAGAAoAAAABAAAAAAAHAAoAAAABAAAAAAAIAAoAAAABAAAAAAAJAAoAAAABAAAAAAANAAoAAAABAAAAAAAOAAoAAAABAAAAAAAPAAoAAAABAAAAAAAPAAkAAAABAAAA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AAAAAAAAAAAVAAgAAAAAAAAAAAAVAAkAAAAAAAAAAAASAAcAAAAAAAAAAAASAAYAAAAAAAAAAAASAAUAAAAAAAAAAAATAAUAAAAAAAAAAAAUAAYAAAAAAAAAAAAUAAcAAAAAAAAAAAAUAAgAAAAAAAAAAAATAAcAAAAAAAAAAAATAAYAAAAAAAAAAAAQAAQAAAAAAAAAAAAQAAgAAAAAAAAAAAARAAYAAAAAAAAAAAASAAkAAAAAAAAAAAAWAAkAAAAAAAAAAAAWAAgAAAAAAAAAAAAWAAcAAAAAAAAAAAAWAAYAAAAAAAAAAAAWAAUAAAAAAAAAAAAWAAQAAAAAAAAAAAAVAAQAAAAAAAAAAAA=") +tile_set = ExtResource("1_57l66") + +[node name="Character" parent="." node_paths=PackedStringArray("map") instance=ExtResource("2_fn2sa")] +position = Vector2(152, 136) +script = ExtResource("3_57l66") +map = NodePath("../Map") + +[node name="Camera2D" type="Camera2D" parent="."] +anchor_mode = 0 +zoom = Vector2(2, 2) diff --git a/scripts/Character.cs b/scripts/Character.cs new file mode 100644 index 0000000..d1865f1 --- /dev/null +++ b/scripts/Character.cs @@ -0,0 +1,42 @@ +using Godot; +using System; + +public partial class Character : Sprite2D { + [Export] + public TileMapLayer map; + public override void _Process(double delta) { + base._Process(delta); + + Vector2I offset = Vector2I.Zero; + + if (Input.IsActionJustPressed("walk-up")) { + offset += Vector2I.Up; + } + if (Input.IsActionJustPressed("walk-down")) { + offset += Vector2I.Down; + } + if (Input.IsActionJustPressed("walk-left")) { + offset += Vector2I.Left; + } + if (Input.IsActionJustPressed("walk-right")) { + offset += Vector2I.Right; + } + + if (offset != Vector2I.Zero) { + Walk(offset); + } + } + + private void Walk(Vector2I offset) { + Vector2I gridCoords = map.LocalToMap(Position); + gridCoords += offset; + + TileData tile = map.GetCellTileData(gridCoords); + + + if (tile.HasCustomData("isWalkable") && (bool) tile.GetCustomData("isWalkable")) { + GD.Print(gridCoords); + Position = map.MapToLocal(gridCoords); + } + } +} diff --git a/scripts/Character.cs.uid b/scripts/Character.cs.uid new file mode 100644 index 0000000..8229b7f --- /dev/null +++ b/scripts/Character.cs.uid @@ -0,0 +1 @@ +uid://c840l08453pu2 |
