From eb11047456bf71d67454c8ff74ce7b088e8f439f Mon Sep 17 00:00:00 2001 From: Exobyt Date: Sun, 8 Sep 2024 23:03:55 +0200 Subject: [PATCH] First Prototype --- Assets/Player/Player.ase | Bin 0 -> 1599 bytes Assets/Player/Player.ase.import | 14 ++++ Assets/Player/Player.png | Bin 0 -> 455 bytes Assets/Player/Player.png.import | 34 ++++++++ Assets/Tilemaps/Floor.png.import | 34 ++++++++ Assets/Tilemaps/FloorHexago.ase | Bin 0 -> 636 bytes Assets/Tilemaps/FloorHexago.ase.import | 14 ++++ Assets/Tilemaps/FloorHexago.png | Bin 0 -> 306 bytes Assets/Tilemaps/FloorHexago.png.import | 34 ++++++++ Assets/Tilemaps/FloorHexago.tres | 21 +++++ Assets/Tilemaps/Wall.png.import | 34 ++++++++ Assets/Tilemaps/WallHexagon.ase | Bin 0 -> 852 bytes Assets/Tilemaps/WallHexagon.ase.import | 14 ++++ Assets/Tilemaps/WallHexagon.png | Bin 0 -> 727 bytes Assets/Tilemaps/WallHexagon.png.import | 34 ++++++++ Assets/Tilemaps/WallHexagon.tres | 74 +++++++++++++++++ Assets/Tilemaps/Walls.ase | Bin 0 -> 571 bytes Assets/Tilemaps/Walls.ase.import | 14 ++++ Assets/Tilemaps/Walls.png | Bin 0 -> 121 bytes Assets/Tilemaps/Walls.png.import | 34 ++++++++ Assets/Tilemaps/Walls.tres | 26 ++++++ project.godot | 49 +++++++++++- scenes/GLOBAL.gd | 4 + scenes/game/entities/entity.gd | 47 +++++++++++ scenes/game/entities/entity.tscn | 17 ++++ scenes/game/entities/player/player.gd | 78 ++++++++++++++++++ scenes/game/entities/player/player.tres | 101 ++++++++++++++++++++++++ scenes/game/entities/player/player.tscn | 56 +++++++++++++ scenes/game/mainGame/main_game.gd | 1 - scenes/game/mainGame/main_game.tscn | 8 +- scenes/game/map/floorHexagon.tscn | 8 ++ scenes/game/map/map.tscn | 9 +++ scenes/game/map/wallsHexagon.tscn | 8 ++ scenes/main/main.gd | 11 +++ scenes/main/main.tscn | 5 +- 35 files changed, 779 insertions(+), 4 deletions(-) create mode 100644 Assets/Player/Player.ase create mode 100644 Assets/Player/Player.ase.import create mode 100644 Assets/Player/Player.png create mode 100644 Assets/Player/Player.png.import create mode 100644 Assets/Tilemaps/Floor.png.import create mode 100644 Assets/Tilemaps/FloorHexago.ase create mode 100644 Assets/Tilemaps/FloorHexago.ase.import create mode 100644 Assets/Tilemaps/FloorHexago.png create mode 100644 Assets/Tilemaps/FloorHexago.png.import create mode 100644 Assets/Tilemaps/FloorHexago.tres create mode 100644 Assets/Tilemaps/Wall.png.import create mode 100644 Assets/Tilemaps/WallHexagon.ase create mode 100644 Assets/Tilemaps/WallHexagon.ase.import create mode 100644 Assets/Tilemaps/WallHexagon.png create mode 100644 Assets/Tilemaps/WallHexagon.png.import create mode 100644 Assets/Tilemaps/WallHexagon.tres create mode 100644 Assets/Tilemaps/Walls.ase create mode 100644 Assets/Tilemaps/Walls.ase.import create mode 100644 Assets/Tilemaps/Walls.png create mode 100644 Assets/Tilemaps/Walls.png.import create mode 100644 Assets/Tilemaps/Walls.tres create mode 100644 scenes/GLOBAL.gd create mode 100644 scenes/game/entities/entity.gd create mode 100644 scenes/game/entities/entity.tscn create mode 100644 scenes/game/entities/player/player.gd create mode 100644 scenes/game/entities/player/player.tres create mode 100644 scenes/game/entities/player/player.tscn create mode 100644 scenes/game/map/floorHexagon.tscn create mode 100644 scenes/game/map/map.tscn create mode 100644 scenes/game/map/wallsHexagon.tscn create mode 100644 scenes/main/main.gd diff --git a/Assets/Player/Player.ase b/Assets/Player/Player.ase new file mode 100644 index 0000000000000000000000000000000000000000..0ad604a90f7fb7a03ea3f5329f079a95eff49e66 GIT binary patch literal 1599 zcmcJPeN4=89LGQDIzp(-d06g8k;dr3BAQ zrw6RrnAl>;JPbM1aQ?t{s6#}NtGloFPpdoqgEpVrz3%t0-{<}Me1G2^FD81WA50^N z!^eq;*5PX}&VKk`j*|neZaub5Rm7yL4VaQaOH;AU~&-yS3fX; z_g-{?3`JCQ{xY~nvmZ=XtHH$Oap2|!x!}3LK=64&GWc}cRZw?C2Ig+`XKKtM5>{9k z4ntr9=))c2u!b^xAq!Jz!V!Y7gBrXb1taJPE{wqf3dlz|k`aqc1R@PlQXz?R273w$ zG>{gr*_yJ63)qd5(VR=qJ^Tu<-JwJjy)GkV06BKRZD&#{VnyWmAg+pNks={RjP}2k zh!%%OCfKx6I2TfdvZo3=f6MV?m8#=m*o2cmX6~34TB%jCa*eTBy8g$`Z>-$5)apH-pEQ~Z zJ3m-ec-XONEYAPXwBDE&Hfnq$Unwot$V>;LORG%>mb|-|%`y*3o7#eev?znZRZQRZ zN^1JizgL={XDztnnIDmL*S)Adz1jAf;|sp5OMjp7FOH8MV$QG!gB?-K+&F`dlxm=|}fo`|c&L_;Rx_zT>{{nY_|VOgzV$ zXO@n&_|?)lrNK-1YjRwB<-fT5G~L$k8)<#k;O^mDkdUq~j{6=zw@W<77TK;dm+3V! ze`?5*)bu06K0%a0CwKF+T&VE&iJ4OMSjOvH$~JenWq0Y!(nf_`Sf$Ks2CtMpa|j#t zZ}*V4+U$EPDamp$M-rTK+7!Q{sjR`;Fz9;i2v%x|Y=0sbHmXOfq^2Js_CYcm6?s>x i+dSV-&oD>bExTw?RCHFjYj#iQUacd-YGph$c>M(YiQ1+B literal 0 HcmV?d00001 diff --git a/Assets/Player/Player.ase.import b/Assets/Player/Player.ase.import new file mode 100644 index 0000000..fe25ccb --- /dev/null +++ b/Assets/Player/Player.ase.import @@ -0,0 +1,14 @@ +[remap] + +importer="aseprite_wizard.plugin.noop" +type="PackedDataContainer" +uid="uid://c0p830yfqmsu3" +path="res://.godot/imported/Player.ase-327f2691d292d3d2542bc4967ad2e2d6.res" + +[deps] + +source_file="res://Assets/Player/Player.ase" +dest_files=["res://.godot/imported/Player.ase-327f2691d292d3d2542bc4967ad2e2d6.res"] + +[params] + diff --git a/Assets/Player/Player.png b/Assets/Player/Player.png new file mode 100644 index 0000000000000000000000000000000000000000..8cc63152a817b340b9dbd34b68b849d571b87046 GIT binary patch literal 455 zcmeAS@N?(olHy`uVBq!ia0vp^3P8MogAGXLp32i%uH66tgmlUviH?iEt@@eiF|3#UX{7| z?H3-L{;21h!tMfwYU8h_{R;=0Myg)56(>3?Ykc>Arcdbt5J|+F`)ehGp<+K zn^o`KJ0SBZtaMM8iYM}3zWv!$@a}w&*BKZt?6v>E Xa3*=_{eXB0MUa4}tDnm{r-UW|4{ovr literal 0 HcmV?d00001 diff --git a/Assets/Player/Player.png.import b/Assets/Player/Player.png.import new file mode 100644 index 0000000..be8bcb4 --- /dev/null +++ b/Assets/Player/Player.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b2xbgtcyxvi73" +path="res://.godot/imported/Player.png-1cdd804a9b0fdcfc546bbabf40de7758.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Player/Player.png" +dest_files=["res://.godot/imported/Player.png-1cdd804a9b0fdcfc546bbabf40de7758.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/Tilemaps/Floor.png.import b/Assets/Tilemaps/Floor.png.import new file mode 100644 index 0000000..1bcfaa6 --- /dev/null +++ b/Assets/Tilemaps/Floor.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://tiulht2m5b24" +path="res://.godot/imported/Floor.png-eb0d8e7badb1675ed9f141870f8d4783.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Tilemaps/Floor.png" +dest_files=["res://.godot/imported/Floor.png-eb0d8e7badb1675ed9f141870f8d4783.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/Tilemaps/FloorHexago.ase b/Assets/Tilemaps/FloorHexago.ase new file mode 100644 index 0000000000000000000000000000000000000000..3b5aff04ce5dce5440809949dbc6b78e36c16947 GIT binary patch literal 636 zcmcJMPe>GD96&#H-MtuwHxD{rA|Z5Wc9CRJSP~;xg-pzpkWF_Ta1JAit%-k#2uult zD55OvB6TR#Lzse+c2JQ{E-vbV3VKj+OzE_)PH&M_@a}Jz$2ZL3z28h{vJmS-N#Yro z6iGse0QdRG^W&wQVkn~rwlnJrmQ0zjDi@uW5IHg*-pMP1n%fEcs|w*-^L4oVS%c>9 z5Af*l7JR=|4)rM&7Q8WFY2!^;QJM=~MQ-Tvv_kdqbNI;Efc^ms`u=Rfh1D3e7$F9} zkHHt+J+M*NVNF#93>NpnZ!Q;He&~ncjtSWR&I|jRR7+hmtzSwAfI-^sV13T zVksq)MgplLjV_`nA}8KrSyYgKA30{UI1yq)rNm7#1tx|B;SgnY?F}u`*~>$!Jbh*H z`%g#G_4MQ3()bl|Ev@9f_jYLHc+8$LZI^++&a1D6de_oFy^ijvp<`{{r+oFd%%(nh zX_U{7?uP1uZ?jBOyZiG->#xWIM_2UU_Tra&%D(T!V_3f7*r1u^4M#RMv)gRr^^UpP MV0FYkGgLn`LHy}gn5kb#KnMfq)u z)7X|Jv1J|O=5;!upul;k^PXj_l=h|FOKq>zB!9NmvFP@D)>9_`uVi0H=+%!K;;Yo= z`bfUc{4q^n+w<8I?fC8s9V*)+o&M>AuHu^es{_UOfdW;weIGwRjCP8czwn5<=%LZzzy!Z;LjX i_WU8xC!~M_YB7u)f_4VJA6{C4^m)4axvX3v-ePn^#sspr5QUPWwP!bjV2Xld> zl7h*9VIYSES4S-F0P z9e7-7MUJpe5V-!}-*L?#<$#+hyXC*VtH`p~v~N(`_I#&rx0cb_wH9T~>*S~IKVxsd z?|u85uMI#>@Vlpq*|rN_yDy#jJBk0ruRzIjcW*H7stdWYQyV0F)aJV*NH}s{^?2C68?X?tXNsH;sSELlA4_ z;)%8s{NBI3FB-dU-rGi=D*ylMB#O$mvfs*HQm+yGPVR5!dH??bm+Et{qGh&O=e7IK z-n;z2zODA0UEI3j_AHK&sehj=c(wCu z^~RI675qJ~)!EhWZ=Ij&`|hl5M2x-VihcFdZFkQ9mQein3Bz1#pnvu}nfH6Ucz*Ho zzv=v2cV2w+N#N_>^wPYKhR?J31MTa-y|bPbD!1t0|CQB1vFTgcx0YYBol!g2Ir-_q zJJu)Ve9r6IJ-bllAfK`2cTd~idXqOlH-7JLv$g;B@8X8%$M4xoefx9cxBKCF^40${ zZhTIDFV9{UtHt+aF9ES%PAb!=312Q)KJ^^GY>T(o z%WuCvO|!GR|DONdNA(XM&+L`5|4`+`{$Q4UMQx?G=F%@8f7az+5qp2|r_8N_w{{!S z1WfkT`ZJ#JYFhB|xS>Qtj-PuKKExA zGFY%Pa`-Vc2{$}oQLun9|4DPq{4H>)9rJm3Qx&9b-!cJ&}EqUn{%1=F8Kvl8B*SVeZKG z%KXCjU~^`U!jfxo&R#F$8QyV=rSm&=D@U$OKbU%cqKWguw>L{Qu0~YsE|c`$E^%p} zuXym9HreB9t23uL_orWddd2h|`-<2PVR6UrEn<}iCPRE+)>rX`fl=i(X9Pn)$~;~D KT-G@yGywppn>nKZ literal 0 HcmV?d00001 diff --git a/Assets/Tilemaps/WallHexagon.png.import b/Assets/Tilemaps/WallHexagon.png.import new file mode 100644 index 0000000..6f95481 --- /dev/null +++ b/Assets/Tilemaps/WallHexagon.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bas12neil84t3" +path="res://.godot/imported/WallHexagon.png-72a945adebe9892b4fc2def9e4c26eeb.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Tilemaps/WallHexagon.png" +dest_files=["res://.godot/imported/WallHexagon.png-72a945adebe9892b4fc2def9e4c26eeb.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/Tilemaps/WallHexagon.tres b/Assets/Tilemaps/WallHexagon.tres new file mode 100644 index 0000000..7d8d294 --- /dev/null +++ b/Assets/Tilemaps/WallHexagon.tres @@ -0,0 +1,74 @@ +[gd_resource type="TileSet" load_steps=10 format=3 uid="uid://beqxnvupuy2rk"] + +[ext_resource type="Texture2D" uid="uid://c7fq0sv3tn88s" path="res://Assets/Tilemaps/Wall.png" id="1_s3a4i"] + +[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_ksoke"] + +[sub_resource type="NavigationPolygon" id="NavigationPolygon_epnhj"] +vertices = PackedVector2Array(16, -8, 16, 8, 0, 16, -16, 8, -16, -8, 0, -16) +polygons = Array[PackedInt32Array]([PackedInt32Array(0, 1, 2, 3, 4, 5)]) +outlines = Array[PackedVector2Array]([PackedVector2Array(-16, -8, 0, -16, 16, -8, 16, 8, 0, 16, -16, 8)]) +agent_radius = 0.0 + +[sub_resource type="NavigationPolygon" id="NavigationPolygon_jioix"] +vertices = PackedVector2Array(0, 16, -16, 8, -16, -8, 0, -16) +polygons = Array[PackedInt32Array]([PackedInt32Array(0, 1, 2, 3)]) +outlines = Array[PackedVector2Array]([PackedVector2Array(0, -16, -16, -8, -16, 8, 0, 16)]) +agent_radius = 0.0 + +[sub_resource type="NavigationPolygon" id="NavigationPolygon_osy5n"] +vertices = PackedVector2Array(16, -8, 16, 8, 1.79688, 15.1016, -16, 8, -16, -8, 0, -16) +polygons = Array[PackedInt32Array]([PackedInt32Array(0, 1, 2, 3, 4, 5)]) +outlines = Array[PackedVector2Array]([PackedVector2Array(0, -16, 16, -8, 16, 8, 1.8, 15.1, -16, 8, -16, -8)]) +agent_radius = 0.0 + +[sub_resource type="NavigationPolygon" id="NavigationPolygon_thqwj"] +vertices = PackedVector2Array(16, -8, 16, 8, 0, 16, 0, -16) +polygons = Array[PackedInt32Array]([PackedInt32Array(0, 1, 2, 3)]) +outlines = Array[PackedVector2Array]([PackedVector2Array(0, -16, 16, -8, 16, 8, 0, 16)]) +agent_radius = 0.0 + +[sub_resource type="NavigationPolygon" id="NavigationPolygon_tofi5"] +vertices = PackedVector2Array(16, -8, -16, -8, 0, -16) +polygons = Array[PackedInt32Array]([PackedInt32Array(0, 1, 2)]) +outlines = Array[PackedVector2Array]([PackedVector2Array(-16, -8, 0, -16, 16, -8)]) +agent_radius = 0.0 + +[sub_resource type="NavigationPolygon" id="NavigationPolygon_dalg8"] +vertices = PackedVector2Array(0, 16, -16, 8, 16, 8) +polygons = Array[PackedInt32Array]([PackedInt32Array(0, 1, 2)]) +outlines = Array[PackedVector2Array]([PackedVector2Array(-16, 8, 0, 16, 16, 8)]) +agent_radius = 0.0 + +[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_kqjqa"] +texture = ExtResource("1_s3a4i") +texture_region_size = Vector2i(32, 32) +0:0/next_alternative_id = 3 +0:0/0 = 0 +0:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(0, -16, -16, -8, -16, 8, 0, 16, 16, 8, 16, -8) +0:0/0/navigation_layer_0/polygon = SubResource("NavigationPolygon_epnhj") +1:0/0 = 0 +1:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -8, 0, -16, 16, -8, 16, 8, 0, 16, -16, 8) +1:0/0/navigation_layer_0/polygon = SubResource("NavigationPolygon_osy5n") +0:1/0 = 0 +0:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(0, -16, 0, 16, -16, 8, -16, -8) +0:1/0/navigation_layer_0/polygon = SubResource("NavigationPolygon_jioix") +1:1/0 = 0 +1:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(0, -16, 16, -8, 16, 8, 0, 16) +1:1/0/navigation_layer_0/polygon = SubResource("NavigationPolygon_thqwj") +2:1/0 = 0 +2:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(0, -16, -16, -8, 16, -8) +2:1/0/navigation_layer_0/polygon = SubResource("NavigationPolygon_tofi5") +3:1/0 = 0 +3:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, 8, 0, 16, 16, 8) +3:1/0/navigation_layer_0/polygon = SubResource("NavigationPolygon_dalg8") +2:0/0 = 0 + +[resource] +tile_shape = 3 +tile_size = Vector2i(32, 32) +physics_layer_0/collision_layer = 1 +physics_layer_0/collision_mask = 2 +physics_layer_0/physics_material = SubResource("PhysicsMaterial_ksoke") +navigation_layer_0/layers = 2 +sources/0 = SubResource("TileSetAtlasSource_kqjqa") diff --git a/Assets/Tilemaps/Walls.ase b/Assets/Tilemaps/Walls.ase new file mode 100644 index 0000000000000000000000000000000000000000..97c4f737c64681c180d4bdc505cd4b8db66fe347 GIT binary patch literal 571 zcmcJNze@sf96&#sAyNN8lSf3gbskcPf)E6e4dGx#Lq9CR8;m5P2n-?!TwH=E8(P|O zYA6b7XbN!-b1d{p{g=CQ zlpn8-U+XQFcCBu8{dFpl4$T7xd;Bo!b;ESn2TO}xuy7EC&sTe}^414;A4Z{hp~L>| zI1I*mVJO%M4Zjx#0!vVz-hh+wGK^#toXX$BT=5esMkJFxft$%K7&A>c5e~uSffPJ4 z3|JV8z?-!*nBEzNsRdn`?BWpCwU%QEHXxsN!l@>iUScUFlSTrmBaJSiC?dydQHlx@ z@FT~J7AHb%s9cswYl8J5L7Xx&vpS#9+(SGxYqeL3&tDts2UyvE%DZi%x7l@1xm0|d d^?MWD*SYax%Vp{1z4Dc;Ue>>Z&eLq`@ehd*px*!h literal 0 HcmV?d00001 diff --git a/Assets/Tilemaps/Walls.ase.import b/Assets/Tilemaps/Walls.ase.import new file mode 100644 index 0000000..21d6221 --- /dev/null +++ b/Assets/Tilemaps/Walls.ase.import @@ -0,0 +1,14 @@ +[remap] + +importer="aseprite_wizard.plugin.noop" +type="PackedDataContainer" +uid="uid://8nakjbmxfybw" +path="res://.godot/imported/Walls.ase-3e27fd0f4db2952123bde42b18b33d12.res" + +[deps] + +source_file="res://Assets/Tilemaps/Walls.ase" +dest_files=["res://.godot/imported/Walls.ase-3e27fd0f4db2952123bde42b18b33d12.res"] + +[params] + diff --git a/Assets/Tilemaps/Walls.png b/Assets/Tilemaps/Walls.png new file mode 100644 index 0000000000000000000000000000000000000000..17f9f69ffb84d3cbfdb809c9f7ec41983fe724ae GIT binary patch literal 121 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz2TvErkcif|*9`?340sMZEDd*g z*snNc)>fW99xQ)Wb62qJX1FUWIbYH*<)?Q810xd)hk$|ugrRZhdkteo2&?_Y1W|FI OSqz@8elF{r5}E)#6d void: + health -= damage + damaged.emit() + if health <= 0: + health = 0 + death.emit() + +func heal(heal : int) -> void: + health += heal + healed.emit() + if health >= maxHealth: + health = maxHealth + +func resetSpeed(): + speed = normalSpeed + +func resetHealth(): + health = health + +func setSpeed(n): + speed = n diff --git a/scenes/game/entities/entity.tscn b/scenes/game/entities/entity.tscn new file mode 100644 index 0000000..bc9212a --- /dev/null +++ b/scenes/game/entities/entity.tscn @@ -0,0 +1,17 @@ +[gd_scene load_steps=2 format=3 uid="uid://b18cf4i8v6a1"] + +[ext_resource type="Script" path="res://scenes/game/entities/entity.gd" id="1_s7hj7"] + +[node name="Entity" type="CharacterBody2D" groups=["Entity"]] +collision_layer = 2 +script = ExtResource("1_s7hj7") + +[node name="Area2D" type="Area2D" parent="." groups=["Entity"]] +collision_layer = 8 +collision_mask = 16 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] + +[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] diff --git a/scenes/game/entities/player/player.gd b/scenes/game/entities/player/player.gd new file mode 100644 index 0000000..97b973c --- /dev/null +++ b/scenes/game/entities/player/player.gd @@ -0,0 +1,78 @@ +extends "res://scenes/game/entities/entity.gd" + +@onready var rollTimer = $RollTimer +@onready var rollCooldownTimer = $RollCooldownTimer + +@onready var animatedSprite = $AnimatedSprite2D + +var rollSpeed = maxSpeed * 5 + +const rollCooldown = 5.0 +const rollTime = 0.4 + +var rolling = false + +var canRoll = true + +var lastDirection : Vector2 +var lastdirectionVector : Vector2 + +func _physics_process(delta: float) -> void: + + var direction : Vector2 = Input.get_vector("MOVE_LEFT", "MOVE_RIGHT", "MOVE_UP", "MOVE_DOWN").normalized() + #var direction : Vector2 = Vector2( + #Input.get_action_strength("MOVE_RIGHT") - Input.get_action_strength("MOVE_LEFT"), + #Input.get_action_strength("MOVE_DOWN") - Input.get_action_strength("MOVE_UP") + #) + var directionVector : Vector2 = position.direction_to(position + direction) + + if direction != Vector2.ZERO and not rolling: + lastDirection = direction + lastdirectionVector = directionVector + if Input.is_action_just_pressed("ROLL") and lastDirection != Vector2.ZERO: + roll() + if rolling: + move(lastdirectionVector * speed, acceleration) + else: + move(directionVector * speed, acceleration) + setAnimation() + move_and_slide() + +func move(newVelocity : Vector2, acc): + velocity.x = move_toward(velocity.x, + newVelocity.x, + acc) + velocity.y = move_toward(velocity.y, + newVelocity.y, + acc) + +func roll(): + if not rolling and canRoll: + canRoll = false + setSpeed(rollSpeed) + invincible = true + rolling = true + rollTimer.start(rollTime) + +func _on_roll_timeout() -> void: + resetSpeed() + invincible = false + rolling = false + rollCooldownTimer.start(rollCooldown) + + +func _on_roll_cooldown_timer_timeout() -> void: + canRoll = true + +func setAnimation(): + if not rolling: + if Input.is_action_pressed("MOVE_LEFT") and not Input.is_action_pressed("MOVE_RIGHT") and animatedSprite.animation != "LEFT": + animatedSprite.play("LEFT") + elif Input.is_action_pressed("MOVE_RIGHT") and not Input.is_action_pressed("MOVE_LEFT") and animatedSprite.animation != "RIGHT": + animatedSprite.play("RIGHT") + elif Input.is_action_pressed("MOVE_UP") and animatedSprite.animation != "UP" and not Input.is_action_pressed("MOVE_LEFT") and not Input.is_action_pressed("MOVE_RIGHT"): + animatedSprite.play("UP") + elif Input.is_action_pressed("MOVE_DOWN") and animatedSprite.animation != "DOWN" and not Input.is_action_pressed("MOVE_LEFT") and not Input.is_action_pressed("MOVE_RIGHT"): + animatedSprite.play("DOWN") + elif not (Input.is_action_pressed("MOVE_UP") or Input.is_action_pressed("MOVE_RIGHT") or Input.is_action_pressed("MOVE_DOWN") or Input.is_action_pressed("MOVE_LEFT")): + animatedSprite.play("IDLE") diff --git a/scenes/game/entities/player/player.tres b/scenes/game/entities/player/player.tres new file mode 100644 index 0000000..ea24f78 --- /dev/null +++ b/scenes/game/entities/player/player.tres @@ -0,0 +1,101 @@ +[gd_resource type="SpriteFrames" load_steps=12 format=3 uid="uid://dv18sf3aj0n1h"] + +[ext_resource type="Texture2D" uid="uid://b2xbgtcyxvi73" path="res://Assets/Player/Player.png" id="1_21ptg"] + +[sub_resource type="AtlasTexture" id="AtlasTexture_m3bgq"] +atlas = ExtResource("1_21ptg") +region = Rect2(0, 64, 16, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_6rhbk"] +atlas = ExtResource("1_21ptg") +region = Rect2(16, 64, 16, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_51ijx"] +atlas = ExtResource("1_21ptg") +region = Rect2(0, 0, 16, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ydp1x"] +atlas = ExtResource("1_21ptg") +region = Rect2(16, 0, 16, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_l7ggo"] +atlas = ExtResource("1_21ptg") +region = Rect2(0, 128, 16, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_404j7"] +atlas = ExtResource("1_21ptg") +region = Rect2(16, 128, 16, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_csdks"] +atlas = ExtResource("1_21ptg") +region = Rect2(0, 96, 16, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_yahsm"] +atlas = ExtResource("1_21ptg") +region = Rect2(16, 96, 16, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_8pkt3"] +atlas = ExtResource("1_21ptg") +region = Rect2(0, 32, 16, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_rq2en"] +atlas = ExtResource("1_21ptg") +region = Rect2(16, 32, 16, 32) + +[resource] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_m3bgq") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_6rhbk") +}], +"loop": true, +"name": &"DOWN", +"speed": 5.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_51ijx") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ydp1x") +}], +"loop": true, +"name": &"IDLE", +"speed": 5.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_l7ggo") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_404j7") +}], +"loop": true, +"name": &"LEFT", +"speed": 5.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_csdks") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_yahsm") +}], +"loop": true, +"name": &"RIGHT", +"speed": 5.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_8pkt3") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_rq2en") +}], +"loop": true, +"name": &"UP", +"speed": 5.0 +}] diff --git a/scenes/game/entities/player/player.tscn b/scenes/game/entities/player/player.tscn new file mode 100644 index 0000000..c468f82 --- /dev/null +++ b/scenes/game/entities/player/player.tscn @@ -0,0 +1,56 @@ +[gd_scene load_steps=6 format=3 uid="uid://0duodsosmfpq"] + +[ext_resource type="PackedScene" uid="uid://b18cf4i8v6a1" path="res://scenes/game/entities/entity.tscn" id="1_kmfws"] +[ext_resource type="Script" path="res://scenes/game/entities/player/player.gd" id="2_s0pfn"] +[ext_resource type="SpriteFrames" uid="uid://dv18sf3aj0n1h" path="res://scenes/game/entities/player/player.tres" id="3_mlsai"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_gk017"] +size = Vector2(16, 16) + +[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_upmug"] +radius = 8.0 +height = 16.0 + +[node name="Player" groups=["Player"] instance=ExtResource("1_kmfws")] +script = ExtResource("2_s0pfn") + +[node name="Area2D" parent="." index="0" groups=["Player"]] + +[node name="CollisionShape2D" parent="Area2D" index="0"] +position = Vector2(0, 8) +shape = SubResource("RectangleShape2D_gk017") + +[node name="CollisionShape2D" parent="." index="1"] +position = Vector2(0, 8) +shape = SubResource("CapsuleShape2D_upmug") + +[node name="AnimatedSprite2D" parent="." index="2"] +sprite_frames = ExtResource("3_mlsai") +animation = &"DOWN" +metadata/_aseprite_wizard_config_ = { +"layer": "", +"o_ex_p": "", +"o_folder": "", +"o_name": "", +"only_visible": false, +"slice": "", +"source": "res://Assets/Player/Player.ase" +} +metadata/_aseprite_wizard_interface_config_ = { +"layer_section": false, +"slice_section": false +} + +[node name="Camera2D" type="Camera2D" parent="." index="3"] +zoom = Vector2(3, 3) +limit_smoothed = true +position_smoothing_enabled = true + +[node name="RollTimer" type="Timer" parent="." index="4"] +one_shot = true + +[node name="RollCooldownTimer" type="Timer" parent="." index="5"] +one_shot = true + +[connection signal="timeout" from="RollTimer" to="." method="_on_roll_timeout"] +[connection signal="timeout" from="RollCooldownTimer" to="." method="_on_roll_cooldown_timer_timeout"] diff --git a/scenes/game/mainGame/main_game.gd b/scenes/game/mainGame/main_game.gd index d0e27c1..88e0050 100644 --- a/scenes/game/mainGame/main_game.gd +++ b/scenes/game/mainGame/main_game.gd @@ -4,7 +4,6 @@ extends Node2D # Called when the node enters the scene tree for the first time. func _ready() -> void: pass # Replace with function body. - print() # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: diff --git a/scenes/game/mainGame/main_game.tscn b/scenes/game/mainGame/main_game.tscn index d4ffa9c..5d3612f 100644 --- a/scenes/game/mainGame/main_game.tscn +++ b/scenes/game/mainGame/main_game.tscn @@ -1,6 +1,12 @@ -[gd_scene load_steps=2 format=3 uid="uid://dgxw2n4ei2ahe"] +[gd_scene load_steps=4 format=3 uid="uid://dgxw2n4ei2ahe"] [ext_resource type="Script" path="res://scenes/game/mainGame/main_game.gd" id="1_napbe"] +[ext_resource type="PackedScene" uid="uid://0duodsosmfpq" path="res://scenes/game/entities/player/player.tscn" id="3_sjgkj"] +[ext_resource type="PackedScene" uid="uid://br7eqr6jomsg4" path="res://scenes/game/map/map.tscn" id="3_vpriv"] [node name="mainGame" type="Node2D"] script = ExtResource("1_napbe") + +[node name="Map" parent="." instance=ExtResource("3_vpriv")] + +[node name="Player" parent="." instance=ExtResource("3_sjgkj")] diff --git a/scenes/game/map/floorHexagon.tscn b/scenes/game/map/floorHexagon.tscn new file mode 100644 index 0000000..9e60578 --- /dev/null +++ b/scenes/game/map/floorHexagon.tscn @@ -0,0 +1,8 @@ +[gd_scene load_steps=2 format=4 uid="uid://4bbmk4wy0a1b"] + +[ext_resource type="TileSet" path="res://Assets/Tilemaps/Floor.tres" id="1_557um"] + +[node name="Floor" type="TileMapLayer"] +position = Vector2(16, 32) +tile_map_data = PackedByteArray("AAD+//3/AAAAAAAAAAD+//7/AAAAAAAAAAD9//7/AAAAAAAAAAD///3/AAAAAAAAAAAAAP7/AAAAAAAAAAD///7/AAAAAAAAAAD9////AAAAAAAAAAD8////AAAAAAAAAAD/////AAAAAAAAAAD9/wAAAAAAAAAAAAD+////AAAAAAAAAAA=") +tile_set = ExtResource("1_557um") diff --git a/scenes/game/map/map.tscn b/scenes/game/map/map.tscn new file mode 100644 index 0000000..c429361 --- /dev/null +++ b/scenes/game/map/map.tscn @@ -0,0 +1,9 @@ +[gd_scene load_steps=2 format=4 uid="uid://br7eqr6jomsg4"] + +[ext_resource type="TileSet" uid="uid://64vn4umcy2ke" path="res://Assets/Tilemaps/Walls.tres" id="1_gju0a"] + +[node name="Map" type="Node2D"] + +[node name="Walls" type="TileMapLayer" parent="."] +tile_map_data = PackedByteArray("AAD///7/AAAAAAAAAAAAAP7/AAAAAAAAAAD+////AAAAAAAAAAD+/wAAAAAAAAAAAAD+//7/AAAAAAAAAAABAP7/AAAAAAAAAAACAP7/AAAAAAAAAAD+/wEAAAAAAAAAAAD+/wIAAAAAAAAAAAD+/wMAAAAAAAAAAAADAP7/AAAAAAAAAAAEAP7/AAAAAAAAAAA=") +tile_set = ExtResource("1_gju0a") diff --git a/scenes/game/map/wallsHexagon.tscn b/scenes/game/map/wallsHexagon.tscn new file mode 100644 index 0000000..8033c99 --- /dev/null +++ b/scenes/game/map/wallsHexagon.tscn @@ -0,0 +1,8 @@ +[gd_scene load_steps=2 format=4 uid="uid://m3sgr6auims"] + +[ext_resource type="TileSet" path="res://Assets/Tilemaps/Wall.tres" id="1_8k7fq"] + +[node name="Walls" type="TileMapLayer"] +position = Vector2(16, 32) +tile_map_data = PackedByteArray("AAD8//v/AAAAAAEAAAD8//z/AAABAAAAAAD7//3/AAABAAEAAAD7//v/AAABAAEAAAD8//r/AAADAAEAAAD9//z/AAADAAEAAAD8//7/AAABAAAAAAD7////AAABAAEAAAD8////AAAAAAEAAAD8/wAAAAAAAAAAAAD9//3/AAAAAAEAAAD9//7/AAACAAEAAAD8//3/AAABAAAAAAA=") +tile_set = ExtResource("1_8k7fq") diff --git a/scenes/main/main.gd b/scenes/main/main.gd new file mode 100644 index 0000000..a13afe0 --- /dev/null +++ b/scenes/main/main.gd @@ -0,0 +1,11 @@ +extends Node + +func _ready() -> void: + loadGame() + + +func loadGame(): + G.resetValues() + for i in get_children(): + i.queue_free() + add_child(load("res://scenes/game/mainGame/main_game.tscn").instantiate()) diff --git a/scenes/main/main.tscn b/scenes/main/main.tscn index 4c0b614..0588537 100644 --- a/scenes/main/main.tscn +++ b/scenes/main/main.tscn @@ -1,3 +1,6 @@ -[gd_scene format=3 uid="uid://bwsbkfnkncfhp"] +[gd_scene load_steps=2 format=3 uid="uid://bwsbkfnkncfhp"] + +[ext_resource type="Script" path="res://scenes/main/main.gd" id="1_1blp2"] [node name="Main" type="Node"] +script = ExtResource("1_1blp2")