First commit
Add simple player movement with a finite state machine. Add enemy that can move to target point. Add ground through a tilemap and wall that player and enemy cannot cross.
2
.gitattributes
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
# Normalize EOL for all files that Git considers text files.
|
||||||
|
* text=auto eol=lf
|
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
# Godot 4+ specific ignores
|
||||||
|
.godot/
|
BIN
art/Owlet_Monster_Idle_4.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
34
art/Owlet_Monster_Idle_4.png.import
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://bi7ceeuwhg5mp"
|
||||||
|
path="res://.godot/imported/Owlet_Monster_Idle_4.png-e97c7439f6908603cd036944f8ec35c0.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://art/Owlet_Monster_Idle_4.png"
|
||||||
|
dest_files=["res://.godot/imported/Owlet_Monster_Idle_4.png-e97c7439f6908603cd036944f8ec35c0.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
|
BIN
art/Owlet_Monster_Run_6.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
34
art/Owlet_Monster_Run_6.png.import
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://cjxkidkeka7yp"
|
||||||
|
path="res://.godot/imported/Owlet_Monster_Run_6.png-91009248b6c6292786c9507b39f56504.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://art/Owlet_Monster_Run_6.png"
|
||||||
|
dest_files=["res://.godot/imported/Owlet_Monster_Run_6.png-91009248b6c6292786c9507b39f56504.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
|
BIN
art/Owlet_Monster_Throw_4.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
34
art/Owlet_Monster_Throw_4.png.import
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://dbrr63tv6i2ek"
|
||||||
|
path="res://.godot/imported/Owlet_Monster_Throw_4.png-b0e6d7a8b3f3e05fa0a65ca1d572b1b3.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://art/Owlet_Monster_Throw_4.png"
|
||||||
|
dest_files=["res://.godot/imported/Owlet_Monster_Throw_4.png-b0e6d7a8b3f3e05fa0a65ca1d572b1b3.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
|
BIN
art/Owlet_Monster_Walk_6.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
34
art/Owlet_Monster_Walk_6.png.import
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://bqkvmyqo86dtj"
|
||||||
|
path="res://.godot/imported/Owlet_Monster_Walk_6.png-f3db40d07a0bf1fd7998c83382ca48f1.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://art/Owlet_Monster_Walk_6.png"
|
||||||
|
dest_files=["res://.godot/imported/Owlet_Monster_Walk_6.png-f3db40d07a0bf1fd7998c83382ca48f1.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
|
BIN
art/Pink_Monster_Walk_6.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
34
art/Pink_Monster_Walk_6.png.import
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://bbwsdd0jddmck"
|
||||||
|
path="res://.godot/imported/Pink_Monster_Walk_6.png-56f137427307346e616efca3c76723df.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://art/Pink_Monster_Walk_6.png"
|
||||||
|
dest_files=["res://.godot/imported/Pink_Monster_Walk_6.png-56f137427307346e616efca3c76723df.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
|
BIN
art/pilko.png
Normal file
After Width: | Height: | Size: 119 B |
34
art/pilko.png.import
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://dl8qfp3u18nkx"
|
||||||
|
path="res://.godot/imported/pilko.png-8aabfc83bdded6cb5f6dd16640cb8b5e.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://art/pilko.png"
|
||||||
|
dest_files=["res://.godot/imported/pilko.png-8aabfc83bdded6cb5f6dd16640cb8b5e.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
|
BIN
art/tile.png
Normal file
After Width: | Height: | Size: 323 B |
34
art/tile.png.import
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://cm58s70te836m"
|
||||||
|
path="res://.godot/imported/tile.png-73ea3a56b72978ec382fa65704c5659d.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://art/tile.png"
|
||||||
|
dest_files=["res://.godot/imported/tile.png-73ea3a56b72978ec382fa65704c5659d.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
|
BIN
art/wall.png
Normal file
After Width: | Height: | Size: 318 B |
34
art/wall.png.import
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://lnt0clkwms52"
|
||||||
|
path="res://.godot/imported/wall.png-a390048f5e12dd0b271d636d681186c9.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://art/wall.png"
|
||||||
|
dest_files=["res://.godot/imported/wall.png-a390048f5e12dd0b271d636d681186c9.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
|
1
icon.svg
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<svg height="128" width="128" xmlns="http://www.w3.org/2000/svg"><g transform="translate(32 32)"><path d="m-16-32c-8.86 0-16 7.13-16 15.99v95.98c0 8.86 7.13 15.99 16 15.99h96c8.86 0 16-7.13 16-15.99v-95.98c0-8.85-7.14-15.99-16-15.99z" fill="#363d52"/><path d="m-16-32c-8.86 0-16 7.13-16 15.99v95.98c0 8.86 7.13 15.99 16 15.99h96c8.86 0 16-7.13 16-15.99v-95.98c0-8.85-7.14-15.99-16-15.99zm0 4h96c6.64 0 12 5.35 12 11.99v95.98c0 6.64-5.35 11.99-12 11.99h-96c-6.64 0-12-5.35-12-11.99v-95.98c0-6.64 5.36-11.99 12-11.99z" fill-opacity=".4"/></g><g stroke-width="9.92746" transform="matrix(.10073078 0 0 .10073078 12.425923 2.256365)"><path d="m0 0s-.325 1.994-.515 1.976l-36.182-3.491c-2.879-.278-5.115-2.574-5.317-5.459l-.994-14.247-27.992-1.997-1.904 12.912c-.424 2.872-2.932 5.037-5.835 5.037h-38.188c-2.902 0-5.41-2.165-5.834-5.037l-1.905-12.912-27.992 1.997-.994 14.247c-.202 2.886-2.438 5.182-5.317 5.46l-36.2 3.49c-.187.018-.324-1.978-.511-1.978l-.049-7.83 30.658-4.944 1.004-14.374c.203-2.91 2.551-5.263 5.463-5.472l38.551-2.75c.146-.01.29-.016.434-.016 2.897 0 5.401 2.166 5.825 5.038l1.959 13.286h28.005l1.959-13.286c.423-2.871 2.93-5.037 5.831-5.037.142 0 .284.005.423.015l38.556 2.75c2.911.209 5.26 2.562 5.463 5.472l1.003 14.374 30.645 4.966z" fill="#fff" transform="matrix(4.162611 0 0 -4.162611 919.24059 771.67186)"/><path d="m0 0v-47.514-6.035-5.492c.108-.001.216-.005.323-.015l36.196-3.49c1.896-.183 3.382-1.709 3.514-3.609l1.116-15.978 31.574-2.253 2.175 14.747c.282 1.912 1.922 3.329 3.856 3.329h38.188c1.933 0 3.573-1.417 3.855-3.329l2.175-14.747 31.575 2.253 1.115 15.978c.133 1.9 1.618 3.425 3.514 3.609l36.182 3.49c.107.01.214.014.322.015v4.711l.015.005v54.325c5.09692 6.4164715 9.92323 13.494208 13.621 19.449-5.651 9.62-12.575 18.217-19.976 26.182-6.864-3.455-13.531-7.369-19.828-11.534-3.151 3.132-6.7 5.694-10.186 8.372-3.425 2.751-7.285 4.768-10.946 7.118 1.09 8.117 1.629 16.108 1.846 24.448-9.446 4.754-19.519 7.906-29.708 10.17-4.068-6.837-7.788-14.241-11.028-21.479-3.842.642-7.702.88-11.567.926v.006c-.027 0-.052-.006-.075-.006-.024 0-.049.006-.073.006v-.006c-3.872-.046-7.729-.284-11.572-.926-3.238 7.238-6.956 14.642-11.03 21.479-10.184-2.264-20.258-5.416-29.703-10.17.216-8.34.755-16.331 1.848-24.448-3.668-2.35-7.523-4.367-10.949-7.118-3.481-2.678-7.036-5.24-10.188-8.372-6.297 4.165-12.962 8.079-19.828 11.534-7.401-7.965-14.321-16.562-19.974-26.182 4.4426579-6.973692 9.2079702-13.9828876 13.621-19.449z" fill="#478cbf" transform="matrix(4.162611 0 0 -4.162611 104.69892 525.90697)"/><path d="m0 0-1.121-16.063c-.135-1.936-1.675-3.477-3.611-3.616l-38.555-2.751c-.094-.007-.188-.01-.281-.01-1.916 0-3.569 1.406-3.852 3.33l-2.211 14.994h-31.459l-2.211-14.994c-.297-2.018-2.101-3.469-4.133-3.32l-38.555 2.751c-1.936.139-3.476 1.68-3.611 3.616l-1.121 16.063-32.547 3.138c.015-3.498.06-7.33.06-8.093 0-34.374 43.605-50.896 97.781-51.086h.066.067c54.176.19 97.766 16.712 97.766 51.086 0 .777.047 4.593.063 8.093z" fill="#478cbf" transform="matrix(4.162611 0 0 -4.162611 784.07144 817.24284)"/><path d="m0 0c0-12.052-9.765-21.815-21.813-21.815-12.042 0-21.81 9.763-21.81 21.815 0 12.044 9.768 21.802 21.81 21.802 12.048 0 21.813-9.758 21.813-21.802" fill="#fff" transform="matrix(4.162611 0 0 -4.162611 389.21484 625.67104)"/><path d="m0 0c0-7.994-6.479-14.473-14.479-14.473-7.996 0-14.479 6.479-14.479 14.473s6.483 14.479 14.479 14.479c8 0 14.479-6.485 14.479-14.479" fill="#414042" transform="matrix(4.162611 0 0 -4.162611 367.36686 631.05679)"/><path d="m0 0c-3.878 0-7.021 2.858-7.021 6.381v20.081c0 3.52 3.143 6.381 7.021 6.381s7.028-2.861 7.028-6.381v-20.081c0-3.523-3.15-6.381-7.028-6.381" fill="#fff" transform="matrix(4.162611 0 0 -4.162611 511.99336 724.73954)"/><path d="m0 0c0-12.052 9.765-21.815 21.815-21.815 12.041 0 21.808 9.763 21.808 21.815 0 12.044-9.767 21.802-21.808 21.802-12.05 0-21.815-9.758-21.815-21.802" fill="#fff" transform="matrix(4.162611 0 0 -4.162611 634.78706 625.67104)"/><path d="m0 0c0-7.994 6.477-14.473 14.471-14.473 8.002 0 14.479 6.479 14.479 14.473s-6.477 14.479-14.479 14.479c-7.994 0-14.471-6.485-14.471-14.479" fill="#414042" transform="matrix(4.162611 0 0 -4.162611 656.64056 631.05679)"/></g></svg>
|
After Width: | Height: | Size: 4.1 KiB |
37
icon.svg.import
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://b4qf03u00t17v"
|
||||||
|
path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://icon.svg"
|
||||||
|
dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.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
|
||||||
|
svg/scale=1.0
|
||||||
|
editor/scale_with_editor_scale=false
|
||||||
|
editor/convert_colors_with_editor_theme=false
|
54
project.godot
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
; Engine configuration file.
|
||||||
|
; It's best edited using the editor UI and not directly,
|
||||||
|
; since the parameters that go here are not all obvious.
|
||||||
|
;
|
||||||
|
; Format:
|
||||||
|
; [section] ; section goes between []
|
||||||
|
; param=value ; assign values to parameters
|
||||||
|
|
||||||
|
config_version=5
|
||||||
|
|
||||||
|
[application]
|
||||||
|
|
||||||
|
config/name="bovido"
|
||||||
|
run/main_scene="res://scenes/main.tscn"
|
||||||
|
config/features=PackedStringArray("4.0", "Forward Plus")
|
||||||
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
|
[display]
|
||||||
|
|
||||||
|
window/size/viewport_width=1280
|
||||||
|
window/size/viewport_height=720
|
||||||
|
window/stretch/scale=1.8
|
||||||
|
|
||||||
|
[input]
|
||||||
|
|
||||||
|
move_right={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":105,"echo":false,"script":null)
|
||||||
|
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
move_left={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"echo":false,"script":null)
|
||||||
|
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194319,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
move_up={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":233,"echo":false,"script":null)
|
||||||
|
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
move_down={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":117,"echo":false,"script":null)
|
||||||
|
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
[layer_names]
|
||||||
|
|
||||||
|
2d_physics/layer_1="walls"
|
||||||
|
2d_physics/layer_2="player"
|
47
scenes/enemy.tscn
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
[gd_scene load_steps=6 format=3 uid="uid://bktg1ypaav3q3"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://bbwsdd0jddmck" path="res://art/Pink_Monster_Walk_6.png" id="1_e5603"]
|
||||||
|
[ext_resource type="Script" path="res://scripts/enemy.gd" id="1_l5lyv"]
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_etqki"]
|
||||||
|
resource_name = "walk"
|
||||||
|
length = 0.6
|
||||||
|
loop_mode = 1
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Sprite2D:frame")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5),
|
||||||
|
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [0, 1, 2, 3, 4, 5]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="AnimationLibrary" id="AnimationLibrary_gnukq"]
|
||||||
|
_data = {
|
||||||
|
"walk": SubResource("Animation_etqki")
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_rlijp"]
|
||||||
|
size = Vector2(17, 10)
|
||||||
|
|
||||||
|
[node name="Enemy" type="CharacterBody2D"]
|
||||||
|
script = ExtResource("1_l5lyv")
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
|
position = Vector2(0, -16)
|
||||||
|
texture = ExtResource("1_e5603")
|
||||||
|
flip_h = true
|
||||||
|
hframes = 6
|
||||||
|
|
||||||
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||||
|
libraries = {
|
||||||
|
"": SubResource("AnimationLibrary_gnukq")
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
|
position = Vector2(-0.5, -5)
|
||||||
|
shape = SubResource("RectangleShape2D_rlijp")
|
21
scenes/main.tscn
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
[gd_scene load_steps=4 format=3 uid="uid://cdwgmtyq2y8sm"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://m8uyi35gr3qd" path="res://scenes/tile_map.tscn" id="2_c6bkg"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://ba1t35yyot4jl" path="res://scenes/player.tscn" id="2_idv37"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bktg1ypaav3q3" path="res://scenes/enemy.tscn" id="3_2xcd4"]
|
||||||
|
|
||||||
|
[node name="Main" type="Node2D"]
|
||||||
|
y_sort_enabled = true
|
||||||
|
|
||||||
|
[node name="TileMap" parent="." instance=ExtResource("2_c6bkg")]
|
||||||
|
position = Vector2(324, 82)
|
||||||
|
|
||||||
|
[node name="Enemy" parent="TileMap" instance=ExtResource("3_2xcd4")]
|
||||||
|
z_index = 1
|
||||||
|
y_sort_enabled = true
|
||||||
|
position = Vector2(0, 40)
|
||||||
|
|
||||||
|
[node name="Player" parent="TileMap" instance=ExtResource("2_idv37")]
|
||||||
|
z_index = 1
|
||||||
|
z_as_relative = false
|
||||||
|
y_sort_enabled = true
|
217
scenes/player.tscn
Normal file
|
@ -0,0 +1,217 @@
|
||||||
|
[gd_scene load_steps=16 format=3 uid="uid://ba1t35yyot4jl"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://bqkvmyqo86dtj" path="res://art/Owlet_Monster_Walk_6.png" id="1_e23l4"]
|
||||||
|
[ext_resource type="Script" path="res://scripts/player.gd" id="1_fmx2p"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://cjxkidkeka7yp" path="res://art/Owlet_Monster_Run_6.png" id="2_qq5i7"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://bi7ceeuwhg5mp" path="res://art/Owlet_Monster_Idle_4.png" id="4_orj3a"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dbrr63tv6i2ek" path="res://art/Owlet_Monster_Throw_4.png" id="5_2s1mg"]
|
||||||
|
[ext_resource type="Script" path="res://scripts/state_machine.gd" id="6_hl63m"]
|
||||||
|
[ext_resource type="Script" path="res://scripts/player_idle_state.gd" id="7_0nfrc"]
|
||||||
|
[ext_resource type="Script" path="res://scripts/player_walk_state.gd" id="7_gcd3q"]
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_rh7n7"]
|
||||||
|
length = 0.001
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_7igie"]
|
||||||
|
resource_name = "idle"
|
||||||
|
length = 0.4
|
||||||
|
loop_mode = 1
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Sprite2D:texture")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [ExtResource("4_orj3a")]
|
||||||
|
}
|
||||||
|
tracks/1/type = "value"
|
||||||
|
tracks/1/imported = false
|
||||||
|
tracks/1/enabled = true
|
||||||
|
tracks/1/path = NodePath("Sprite2D:hframes")
|
||||||
|
tracks/1/interp = 1
|
||||||
|
tracks/1/loop_wrap = true
|
||||||
|
tracks/1/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [4]
|
||||||
|
}
|
||||||
|
tracks/2/type = "value"
|
||||||
|
tracks/2/imported = false
|
||||||
|
tracks/2/enabled = true
|
||||||
|
tracks/2/path = NodePath("Sprite2D:frame")
|
||||||
|
tracks/2/interp = 1
|
||||||
|
tracks/2/loop_wrap = true
|
||||||
|
tracks/2/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3),
|
||||||
|
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [0, 1, 2, 3]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_xfiuh"]
|
||||||
|
resource_name = "run"
|
||||||
|
length = 0.6
|
||||||
|
loop_mode = 1
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Sprite2D:texture")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [ExtResource("2_qq5i7")]
|
||||||
|
}
|
||||||
|
tracks/1/type = "value"
|
||||||
|
tracks/1/imported = false
|
||||||
|
tracks/1/enabled = true
|
||||||
|
tracks/1/path = NodePath("Sprite2D:hframes")
|
||||||
|
tracks/1/interp = 1
|
||||||
|
tracks/1/loop_wrap = true
|
||||||
|
tracks/1/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [6]
|
||||||
|
}
|
||||||
|
tracks/2/type = "value"
|
||||||
|
tracks/2/imported = false
|
||||||
|
tracks/2/enabled = true
|
||||||
|
tracks/2/path = NodePath("Sprite2D:frame")
|
||||||
|
tracks/2/interp = 1
|
||||||
|
tracks/2/loop_wrap = true
|
||||||
|
tracks/2/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5),
|
||||||
|
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [0, 1, 2, 3, 4, 5]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_gswgu"]
|
||||||
|
resource_name = "throw"
|
||||||
|
length = 0.4
|
||||||
|
loop_mode = 1
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Sprite2D:texture")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [ExtResource("5_2s1mg")]
|
||||||
|
}
|
||||||
|
tracks/1/type = "value"
|
||||||
|
tracks/1/imported = false
|
||||||
|
tracks/1/enabled = true
|
||||||
|
tracks/1/path = NodePath("Sprite2D:hframes")
|
||||||
|
tracks/1/interp = 1
|
||||||
|
tracks/1/loop_wrap = true
|
||||||
|
tracks/1/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [4]
|
||||||
|
}
|
||||||
|
tracks/2/type = "value"
|
||||||
|
tracks/2/imported = false
|
||||||
|
tracks/2/enabled = true
|
||||||
|
tracks/2/path = NodePath("Sprite2D:frame")
|
||||||
|
tracks/2/interp = 1
|
||||||
|
tracks/2/loop_wrap = true
|
||||||
|
tracks/2/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3),
|
||||||
|
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [0, 1, 2, 3]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_pjkea"]
|
||||||
|
resource_name = "walk"
|
||||||
|
length = 0.6
|
||||||
|
loop_mode = 1
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Sprite2D:texture")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [ExtResource("1_e23l4")]
|
||||||
|
}
|
||||||
|
tracks/1/type = "value"
|
||||||
|
tracks/1/imported = false
|
||||||
|
tracks/1/enabled = true
|
||||||
|
tracks/1/path = NodePath("Sprite2D:hframes")
|
||||||
|
tracks/1/interp = 1
|
||||||
|
tracks/1/loop_wrap = true
|
||||||
|
tracks/1/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [6]
|
||||||
|
}
|
||||||
|
tracks/2/type = "value"
|
||||||
|
tracks/2/imported = false
|
||||||
|
tracks/2/enabled = true
|
||||||
|
tracks/2/path = NodePath("Sprite2D:frame")
|
||||||
|
tracks/2/interp = 1
|
||||||
|
tracks/2/loop_wrap = true
|
||||||
|
tracks/2/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5),
|
||||||
|
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [0, 1, 2, 3, 4, 5]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="AnimationLibrary" id="AnimationLibrary_ldfyt"]
|
||||||
|
_data = {
|
||||||
|
"RESET": SubResource("Animation_rh7n7"),
|
||||||
|
"idle": SubResource("Animation_7igie"),
|
||||||
|
"run": SubResource("Animation_xfiuh"),
|
||||||
|
"throw": SubResource("Animation_gswgu"),
|
||||||
|
"walk": SubResource("Animation_pjkea")
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_hocsq"]
|
||||||
|
size = Vector2(21, 7.5)
|
||||||
|
|
||||||
|
[node name="Player" type="CharacterBody2D"]
|
||||||
|
script = ExtResource("1_fmx2p")
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
|
position = Vector2(0, -16)
|
||||||
|
texture = ExtResource("4_orj3a")
|
||||||
|
hframes = 4
|
||||||
|
|
||||||
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||||
|
libraries = {
|
||||||
|
"": SubResource("AnimationLibrary_ldfyt")
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
|
y_sort_enabled = true
|
||||||
|
position = Vector2(-2.5, -3.75)
|
||||||
|
shape = SubResource("RectangleShape2D_hocsq")
|
||||||
|
|
||||||
|
[node name="StateMachine" type="Node" parent="." node_paths=PackedStringArray("state")]
|
||||||
|
script = ExtResource("6_hl63m")
|
||||||
|
state = NodePath("Idle")
|
||||||
|
|
||||||
|
[node name="Idle" type="Node" parent="StateMachine"]
|
||||||
|
script = ExtResource("7_0nfrc")
|
||||||
|
|
||||||
|
[node name="Walk" type="Node" parent="StateMachine"]
|
||||||
|
script = ExtResource("7_gcd3q")
|
43
scenes/tile_map.tscn
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
[gd_scene load_steps=7 format=3 uid="uid://m8uyi35gr3qd"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://cm58s70te836m" path="res://art/tile.png" id="1_2goti"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://lnt0clkwms52" path="res://art/wall.png" id="2_xllgf"]
|
||||||
|
[ext_resource type="Script" path="res://scripts/tile_map.gd" id="3_067ya"]
|
||||||
|
|
||||||
|
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_wq1n0"]
|
||||||
|
texture = ExtResource("1_2goti")
|
||||||
|
texture_region_size = Vector2i(32, 32)
|
||||||
|
0:0/0 = 0
|
||||||
|
0:0/0/physics_layer_0/linear_velocity = Vector2(0, 0)
|
||||||
|
0:0/0/physics_layer_0/angular_velocity = 0.0
|
||||||
|
|
||||||
|
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_u0t08"]
|
||||||
|
texture = ExtResource("2_xllgf")
|
||||||
|
texture_region_size = Vector2i(32, 32)
|
||||||
|
0:0/0 = 0
|
||||||
|
0:0/0/physics_layer_0/linear_velocity = Vector2(0, 0)
|
||||||
|
0:0/0/physics_layer_0/angular_velocity = 0.0
|
||||||
|
0:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, 8.5, 0, 1.5, 15.5, 9, 0, 16)
|
||||||
|
|
||||||
|
[sub_resource type="TileSet" id="TileSet_kwgeq"]
|
||||||
|
tile_shape = 1
|
||||||
|
tile_layout = 5
|
||||||
|
tile_size = Vector2i(32, 16)
|
||||||
|
physics_layer_0/collision_layer = 1
|
||||||
|
sources/0 = SubResource("TileSetAtlasSource_wq1n0")
|
||||||
|
sources/1 = SubResource("TileSetAtlasSource_u0t08")
|
||||||
|
|
||||||
|
[node name="TileMap" type="TileMap"]
|
||||||
|
y_sort_enabled = true
|
||||||
|
tile_set = SubResource("TileSet_kwgeq")
|
||||||
|
format = 2
|
||||||
|
layer_0/name = "ground"
|
||||||
|
layer_0/y_sort_enabled = true
|
||||||
|
layer_1/name = "wall"
|
||||||
|
layer_1/enabled = true
|
||||||
|
layer_1/modulate = Color(1, 1, 1, 1)
|
||||||
|
layer_1/y_sort_enabled = true
|
||||||
|
layer_1/y_sort_origin = 0
|
||||||
|
layer_1/z_index = 1
|
||||||
|
layer_1/tile_data = PackedInt32Array()
|
||||||
|
script = ExtResource("3_067ya")
|
36
scripts/enemy.gd
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
extends CharacterBody2D
|
||||||
|
|
||||||
|
@onready var tile_map: TileMap = get_parent()
|
||||||
|
@onready var animation_player = $AnimationPlayer
|
||||||
|
@export var speed = 80
|
||||||
|
var y_spawn_offset = -8
|
||||||
|
var is_moving = false
|
||||||
|
var destination: Vector2 = Vector2.ZERO
|
||||||
|
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
var spawn_cell: Vector2i = tile_map.get_top_spawn_cell()
|
||||||
|
position = tile_map.map_to_local(spawn_cell)
|
||||||
|
position.y += y_spawn_offset
|
||||||
|
|
||||||
|
func _process(_delta):
|
||||||
|
if is_moving:
|
||||||
|
animation_player.play("walk")
|
||||||
|
else:
|
||||||
|
animation_player.stop()
|
||||||
|
|
||||||
|
func _physics_process(delta):
|
||||||
|
move_to_rand_cell(delta)
|
||||||
|
|
||||||
|
func move_to_rand_cell(delta):
|
||||||
|
if !is_moving:
|
||||||
|
var rand_cell: Vector2i = tile_map.get_random_top_cell()
|
||||||
|
tile_map.set_cell(0, Vector2i(rand_cell.x, rand_cell.y), 1, Vector2i(0, 0), 0) # debug purpose
|
||||||
|
destination = tile_map.map_to_local(rand_cell)
|
||||||
|
destination.y += y_spawn_offset
|
||||||
|
|
||||||
|
is_moving = true
|
||||||
|
position = position.move_toward(destination, delta * speed)
|
||||||
|
|
||||||
|
if position == destination:
|
||||||
|
is_moving = false
|
13
scripts/player.gd
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
class_name Player
|
||||||
|
extends CharacterBody2D
|
||||||
|
|
||||||
|
@export var speed = 120
|
||||||
|
var y_spawn_offset = -8
|
||||||
|
@onready var animation_player = $AnimationPlayer
|
||||||
|
@onready var sprite = $Sprite2D
|
||||||
|
@onready var tile_map: TileMap = get_parent()
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
var spawn_cell: Vector2i = tile_map.get_bottom_spawn_cell()
|
||||||
|
position = tile_map.map_to_local(spawn_cell)
|
||||||
|
position.y += y_spawn_offset
|
13
scripts/player_idle_state.gd
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
class_name PlayerIdleState
|
||||||
|
extends PlayerState
|
||||||
|
|
||||||
|
func enter(_msg := {}):
|
||||||
|
player.velocity = Vector2.ZERO
|
||||||
|
player.animation_player.play("idle")
|
||||||
|
|
||||||
|
func update(_delta):
|
||||||
|
if get_input_direction() != Vector2.ZERO:
|
||||||
|
state_machine.transition_to("Walk")
|
||||||
|
|
||||||
|
func get_input_direction():
|
||||||
|
return Input.get_vector("move_left", "move_right", "move_up", "move_down")
|
9
scripts/player_state.gd
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
class_name PlayerState
|
||||||
|
extends State
|
||||||
|
|
||||||
|
var player: Player
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
await owner.ready
|
||||||
|
player = owner as Player
|
||||||
|
assert(player != null)
|
24
scripts/player_walk_state.gd
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
class_name PlayerWalkState
|
||||||
|
extends PlayerState
|
||||||
|
|
||||||
|
func enter(_msg := {}):
|
||||||
|
player.animation_player.play("walk")
|
||||||
|
|
||||||
|
func physics_update(_delta):
|
||||||
|
var direction = get_input_direction()
|
||||||
|
player.velocity = direction * player.speed
|
||||||
|
|
||||||
|
player.move_and_slide() # this method calculate with delta, we don’t need to do it
|
||||||
|
|
||||||
|
if player.velocity == Vector2.ZERO:
|
||||||
|
state_machine.transition_to("Idle")
|
||||||
|
|
||||||
|
func get_input_direction():
|
||||||
|
var direction = Input.get_vector("move_left", "move_right", "move_up", "move_down")
|
||||||
|
|
||||||
|
if Input.is_action_pressed("move_left"):
|
||||||
|
player.sprite.flip_h = true
|
||||||
|
elif Input.is_action_pressed("move_right"):
|
||||||
|
player.sprite.flip_h = false
|
||||||
|
|
||||||
|
return direction
|
19
scripts/state.gd
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
class_name State
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
var state_machine = null
|
||||||
|
|
||||||
|
func handle_input(_event: InputEvent):
|
||||||
|
pass
|
||||||
|
|
||||||
|
func update(_delta: float):
|
||||||
|
pass
|
||||||
|
|
||||||
|
func physics_update(_delta: float):
|
||||||
|
pass
|
||||||
|
|
||||||
|
func enter(_msg: Dictionary = {}):
|
||||||
|
pass
|
||||||
|
|
||||||
|
func exit():
|
||||||
|
pass
|
34
scripts/state_machine.gd
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
class_name StateMachine
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
signal transitioned(state_name)
|
||||||
|
@export var state: State
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
await owner.ready
|
||||||
|
|
||||||
|
for child in get_children():
|
||||||
|
child.state_machine = self
|
||||||
|
|
||||||
|
state.enter()
|
||||||
|
|
||||||
|
func _unhandled_input(event):
|
||||||
|
state.handle_input(event)
|
||||||
|
|
||||||
|
func _process(delta):
|
||||||
|
state.update(delta)
|
||||||
|
|
||||||
|
func _physics_process(delta):
|
||||||
|
state.physics_update(delta)
|
||||||
|
|
||||||
|
func transition_to(target_state_name: String, msg: Dictionary = {}):
|
||||||
|
if not has_node(target_state_name):
|
||||||
|
push_warning("No state with name " + target_state_name)
|
||||||
|
return
|
||||||
|
|
||||||
|
state.exit()
|
||||||
|
state = get_node(target_state_name)
|
||||||
|
state.enter(msg)
|
||||||
|
emit_signal("transitioned", state.name)
|
||||||
|
|
||||||
|
|
38
scripts/tile_map.gd
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
extends TileMap
|
||||||
|
|
||||||
|
@export var map_width = 13 # keep to a odd value
|
||||||
|
@export var map_height = 19 # keep to a odd value
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
draw_map()
|
||||||
|
|
||||||
|
func draw_map():
|
||||||
|
draw_ground()
|
||||||
|
draw_separation()
|
||||||
|
get_random_top_cell()
|
||||||
|
|
||||||
|
func draw_ground():
|
||||||
|
for x in range(map_width):
|
||||||
|
for y in range(map_height):
|
||||||
|
set_cell(0, Vector2i(x, y), 0, Vector2i(0, 0), 0)
|
||||||
|
|
||||||
|
# The tilemap is initially divided in two section
|
||||||
|
# One for the player (bottom section)
|
||||||
|
# One for the enemy (top section)
|
||||||
|
func draw_separation():
|
||||||
|
var middle_height = floor(map_height / 2.0)
|
||||||
|
for x in range(map_width):
|
||||||
|
set_cell(1, Vector2i(x - 1, middle_height - 1), 1, Vector2i(0, 0), 0) # why have we to add -1?
|
||||||
|
|
||||||
|
func get_top_spawn_cell() -> Vector2i:
|
||||||
|
return Vector2i(floor(map_width / 2.0), 1)
|
||||||
|
|
||||||
|
func get_bottom_spawn_cell() -> Vector2i:
|
||||||
|
return Vector2i(floor(map_width / 2.0), map_height - 2)
|
||||||
|
|
||||||
|
func get_random_top_cell() -> Vector2i:
|
||||||
|
var middle_height = floor(map_height / 2.0)
|
||||||
|
var rand_width = randi_range(0, map_width - 1)
|
||||||
|
var rand_height = randi_range(0, middle_height - 1)
|
||||||
|
#set_cell(0, Vector2i(rand_width, rand_height), 1, Vector2i(0, 0), 0)
|
||||||
|
return Vector2i(rand_width, rand_height)
|