From 67c5b9b9e2fa9e17e1df374968e1d3c2d60af90b Mon Sep 17 00:00:00 2001 From: AndreaTerenz Date: Mon, 3 Oct 2022 15:27:12 +0200 Subject: [PATCH] Added dumbass falena --- ASSETS/enemy_spritesheet.png | Bin 0 -> 1879 bytes ASSETS/enemy_spritesheet.png.import | 35 ++++++ Giovanna.gd | 8 +- Level1.tscn | 48 +++++++- enemies/Enemy.gd | 174 ++++++++++++++++++++++++++++ enemies/Enemy.tscn | 82 +++++++++++++ project.godot | 22 ++++ 7 files changed, 366 insertions(+), 3 deletions(-) create mode 100644 ASSETS/enemy_spritesheet.png create mode 100644 ASSETS/enemy_spritesheet.png.import create mode 100644 enemies/Enemy.gd create mode 100644 enemies/Enemy.tscn diff --git a/ASSETS/enemy_spritesheet.png b/ASSETS/enemy_spritesheet.png new file mode 100644 index 0000000000000000000000000000000000000000..94ed80f3a572bacf6e068a59ff3ba65cb2b15e43 GIT binary patch literal 1879 zcmV-d2dMaoP)Px+5lKWrRCr$PT(OQMMGWnUkRT&M;v*m+0_n)mAsu2bAwl9hAVNg&9Y`ccaEmwz ziHwsVhL1oZA_IwNkehLz+v956Rd&@j+nbzjre|K+etx#AYx*=De}@MS4;&tFdf?=| zetPuu=8T_t_V{-Gy!4v)d$sEi+{4crM{3?bcvZ(MmvEqyQ81`z(AR1Lxb>L>_eF3I zKgY4_;8i`Z%)&9!$yy7eTt4&B zE8oqe!Sy7H#|oD(8rE@1#Asq!acAG)x~RBIu`-C-Zg4UFz(IpuCB9khO^q+*GqER9 zJm&Rh=C4aQBoQG35+xo>a4(6vz;b6?1SB2z=kw>w8c?)gEe!--bq*+!++GQnRx3^n z9v@|WML*vqTogyJwK2(D_V$P`6~kFIY#pMd2#dlInZIt~`11C*1^=^~H)t>;5_lEd z^Z7iTPNxZo3<-;l{{8P?r>}oJ!9GWnN*8gZDB)TH0$qg*NyOv8*Qr$I-QdEw2t0$o zhHj(E-pu%B^I7URz=u)!ySX{a!2$G>_g;+Fkh~Doz{)=d7%K1c*FK&e{PE397!(ey zw%@+>Fhw{d+#bT=!3AHG;(%*4ROX_eOZJY!Md2{mv{i}S_6Btv!}yH3Lc7w){8fbm z7J%Rg41xgyk|i8~N!xa8o#~kH!JqG^bsWe*+OkttW_27ET$;c<4p@~9ZLiq2Z`nHv zR}hYx&em;jq;QPjvoz91=CA2?EOs7|id85NSDRO_zx?LvQcT(`;Xp8sn=Kqx+^x#b zs`Aztr}~-OI|?^iIIMn-7LF2b7N2SSGV*szy_YtNwmp1C3LI0=))lEG;UG?_sXnEa zb`uvr6xeN;?4`K0BiNW#w*+IwCwk|qB$Qz9XxxUqjVgPCM8gzca);0ww-SH(>#6yx zCEodR*lJ#swBeE<95WQ);yA?ro z9svm0s5J3vRD3T!*7DIn;ngK+`Kxvuuncks<4Qadgk!1vbcUzmLH0i)9j)SmFYq3G z5RqpxW92W|i@1__v?T8ya2xCsD=_j|DoUf`+k?+oY@?1e6!$o28;cR(2eIJwVBruC z=+HJgskKvalSUO6t|A;B5#0@LP`~&7n=4sU~eIKRI0(1{O9%mE^x`Mc&~lMjsy8DIk9(q*`8S{pCj|v)NxSJNZ#kT zA~W3t1g}EUvfr(=5^6OrAgMSmk_^wS1XU%~UXIJVj>=YkSGWN`F>u@4E55z>Oph|~ z6UQ}EgQ?@d8I0c60Yc-6z8c_-mSYLBw9}t-`)VZ~Teo7dA_Wo4jf=v8!p2VTdMehY zpD{jY??~L}apf+>w+Ejy@>lIRBv3p(nt1>Wi3=F?4;4E590$kk(Q)9$og}K*>G1Ou z7z1bLaW#8u_Kw1ZyG`G}`a|pQINbII6$TYIo6lMKt9BfGLxmm!OAromY@mtML!m7* za1gOnd!@=R#Q?5zR%X{8M@cxcahY&cM9ej_CZ= zHWtN)#YAkbNRcJ4iMO!|&*ji;P@qQ%BH86wude_9!g`yLt>+;TZ{*@6r-zWv5s+@}C4|c?{qDyn{gD zn8~%_9Q5t-oCS8G(kmFMpDz~-$HguyNH|=6?h#*hhj6X|o+L3`o07jZi(EZ{D%iQ2 zAEe}}u|dPp-Vc8sr3QF;e|dyn@)Owja)#ov#q@}GulSDOb4dQS1Ro;)fBqqx^gyaGT=Ul5|bL7N#oK^r{Nt#572-?xS#IwC@`IMhHi5 zJ~!oWt#Cv?%vB4d*g6kPUYwO{{pYoJwI_jlOufg%QMhcsrNwui&-N6LA)+xWvi&aH z%6Bcq?`O9JJip6oqHHQZd5A4hX{{o3Srk4^_ R->m=u002ovPDHLkV1mOfo5}zH literal 0 HcmV?d00001 diff --git a/ASSETS/enemy_spritesheet.png.import b/ASSETS/enemy_spritesheet.png.import new file mode 100644 index 0000000..978c183 --- /dev/null +++ b/ASSETS/enemy_spritesheet.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/enemy_spritesheet.png-19f607fcb568e42bb08c4d53fd65c460.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ASSETS/enemy_spritesheet.png" +dest_files=[ "res://.import/enemy_spritesheet.png-19f607fcb568e42bb08c4d53fd65c460.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/Giovanna.gd b/Giovanna.gd index a049710..8987d72 100644 --- a/Giovanna.gd +++ b/Giovanna.gd @@ -1,11 +1,17 @@ +class_name Giovanna extends KinematicBody2D +export(float, 0.01, 2.0, 0.01) var stopping_force = 1.0 + var ammo = 6 var velocity = Vector2(0,0) const max_speed = 150 const GRAVITY = 30 const JUMPFORCE = -500 +func _ready(): + owner.set_meta("player", self) + func _physics_process(delta): if Input.is_action_pressed("right"): velocity.x = max_speed @@ -26,5 +32,5 @@ func _physics_process(delta): if Input.is_action_just_pressed("jump") and is_on_floor(): velocity.y = JUMPFORCE velocity = move_and_slide(velocity,Vector2.UP) - velocity.x = lerp(velocity.x,0,0.2) + velocity.x = lerp(velocity.x,0,stopping_force) diff --git a/Level1.tscn b/Level1.tscn index 36e34a9..9d2f5b6 100644 --- a/Level1.tscn +++ b/Level1.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=10 format=2] +[gd_scene load_steps=14 format=2] [ext_resource path="res://icon.png" type="Texture" id=1] [ext_resource path="res://Giovanna.tscn" type="PackedScene" id=2] @@ -7,6 +7,19 @@ [ext_resource path="res://ASSETS/Background/Skyline2.png" type="Texture" id=5] [ext_resource path="res://ASSETS/Background/Skyline1.png" type="Texture" id=6] [ext_resource path="res://ASSETS/Background/Sun total.png" type="Texture" id=7] +[ext_resource path="res://enemies/Enemy.tscn" type="PackedScene" id=8] + +[sub_resource type="GDScript" id=3] +script/source = "extends Node2D + +func _input(event): + if Input.is_action_just_pressed(\"quit\"): + get_tree().quit() + + +func _on_DeathZone_entered(body): + get_tree().reload_current_scene() +" [sub_resource type="RectangleShape2D" id=1] extents = Vector2( 32, 32 ) @@ -19,9 +32,22 @@ animations = [ { "speed": 5.0 } ] +[sub_resource type="GDScript" id=5] +script/source = "extends Area2D + +func _process(delta): + var p = owner.get_meta(\"player\") + position.x = p.position.x +" + +[sub_resource type="RectangleShape2D" id=4] +extents = Vector2( 212, 31 ) + [node name="Level1" type="Node2D"] +script = SubResource( 3 ) [node name="Block1" type="RigidBody2D" parent="."] +visible = false position = Vector2( 398, 147 ) rotation = 0.730756 gravity_scale = 12.0 @@ -36,6 +62,7 @@ texture = ExtResource( 1 ) shape = SubResource( 1 ) [node name="Block2" type="RigidBody2D" parent="."] +visible = false position = Vector2( 339, 51 ) rotation = 0.730756 gravity_scale = 12.0 @@ -50,6 +77,7 @@ texture = ExtResource( 1 ) shape = SubResource( 1 ) [node name="Block3" type="RigidBody2D" parent="."] +visible = false position = Vector2( 86, -20 ) rotation = 0.730756 gravity_scale = 12.0 @@ -64,6 +92,7 @@ texture = ExtResource( 1 ) shape = SubResource( 1 ) [node name="Block4" type="RigidBody2D" parent="."] +visible = false position = Vector2( 527, -503 ) rotation = 0.730756 gravity_scale = 12.0 @@ -90,7 +119,7 @@ drag_margin_h_enabled = true tile_set = ExtResource( 3 ) cell_size = Vector2( 16, 16 ) format = 1 -tile_data = PoolIntArray( 131074, 20, 0, 262148, 20, 0, 393241, 1, 0, 393242, 2, 0, 393243, 17, 0, 393245, 1, 0, 393246, 15, 0, 393247, 15, 0, 393248, 15, 0, 393249, 15, 0, 393250, 15, 0, 393251, 15, 0, 393252, 17, 0, 458777, 4, 0, 458778, 7, 0, 458779, 8, 0, 458781, 4, 0, 458782, 10, 0, 458783, 9, 0, 458784, 10, 0, 458785, 9, 0, 458786, 10, 0, 458787, 9, 0, 458788, 16, 0, 458789, 17, 0, 524291, 20, 0, 524309, 1, 0, 524310, 2, 0, 524311, 3, 0, 524317, 19, 0, 524319, 19, 0, 524321, 19, 0, 524323, 4, 0, 524324, 10, 0, 524325, 16, 0, 524326, 17, 0, 589845, 6, 0, 589846, 7, 0, 589847, 8, 0, 589853, 19, 0, 589855, 19, 0, 589857, 19, 0, 589859, 19, 0, 589861, 13, 0, 589862, 16, 0, 589863, 17, 0, 655360, 3, 0, 655378, 1, 0, 655379, 3, 0, 655389, 19, 0, 655391, 19, 0, 655393, 19, 0, 655395, 19, 0, 655397, 4, 0, 655398, 10, 0, 655399, 16, 0, 655400, 17, 0, 720896, 12, 0, 720897, 20, 0, 720914, 6, 0, 720915, 8, 0, 720925, 19, 0, 720927, 19, 0, 720929, 19, 0, 720931, 19, 0, 720933, 19, 0, 720935, 13, 0, 720936, 10, 0, 720937, 17, 0, 720941, 25, 0, 720942, 2, 0, 720943, 24, 0, 786432, 12, 0, 786436, 20, 0, 786442, 18, 0, 786443, 1, 0, 786444, 2, 0, 786445, 2, 0, 786446, 2, 0, 786447, 2, 0, 786448, 3, 0, 786461, 19, 0, 786463, 19, 0, 786465, 19, 0, 786467, 19, 0, 786469, 19, 0, 786471, 19, 0, 786473, 19, 0, 786478, 19, 0, 851968, 12, 0, 851977, 18, 0, 851978, 16, 0, 851979, 6, 0, 851980, 7, 0, 851981, 7, 0, 851982, 7, 0, 851983, 7, 0, 851984, 8, 0, 851997, 19, 0, 851999, 19, 0, 852001, 19, 0, 852003, 19, 0, 852005, 19, 0, 852007, 19, 0, 852009, 19, 0, 852014, 19, 0, 983030, 20, 0, 917504, 12, 0, 917506, 20, 0, 917512, 18, 0, 917513, 16, 0, 917514, 0, 0, 917515, 5, 0, 917533, 19, 0, 917535, 19, 0, 917537, 19, 0, 917539, 19, 0, 917541, 19, 0, 917543, 19, 0, 917545, 19, 0, 917550, 19, 0, 983040, 12, 0, 983047, 18, 0, 983048, 16, 0, 983049, 0, 0, 983050, 0, 0, 983051, 5, 0, 983069, 19, 0, 983071, 19, 0, 983073, 19, 0, 983075, 19, 0, 983077, 19, 0, 983079, 19, 0, 983081, 19, 0, 983086, 19, 0, 1048576, 14, 0, 1048577, 2, 0, 1048578, 2, 0, 1048579, 2, 0, 1048580, 2, 0, 1048581, 2, 0, 1048582, 2, 0, 1048583, 2, 0, 1048584, 2, 0, 1048585, 2, 0, 1048586, 2, 0, 1048587, 2, 0, 1048588, 2, 0, 1048589, 2, 0, 1048590, 2, 0, 1048591, 2, 0, 1048592, 2, 0, 1048593, 2, 0, 1048594, 2, 0, 1048595, 2, 0, 1048596, 2, 0, 1048597, 2, 0, 1048598, 2, 0, 1048599, 2, 0, 1048600, 2, 0, 1048601, 3, 0, 1048604, 1, 0, 1048605, 5, 0, 1048607, 19, 0, 1048609, 19, 0, 1048611, 19, 0, 1048613, 19, 0, 1048615, 19, 0, 1048617, 19, 0, 1048622, 19, 0, 1048623, 23, 0, 1048624, 23, 0, 1048625, 23, 0, 1048626, 23, 0, 1048627, 23, 0, 1048628, 23, 0, 1048629, 23, 0, 1048630, 23, 0, 1048631, 23, 0, 1048632, 23, 0, 1048633, 23, 0, 1048634, 23, 0, 1048635, 23, 0, 1048636, 23, 0, 1048637, 23, 0, 1048638, 23, 0, 1048639, 23, 0, 1048640, 23, 0, 1048641, 23, 0, 1048642, 23, 0, 1048643, 23, 0, 1048644, 23, 0, 1048645, 23, 0, 1048646, 23, 0, 1048647, 23, 0, 1048648, 23, 0, 1048649, 23, 0, 1048650, 23, 0, 1048651, 23, 0, 1048652, 23, 0, 1048653, 23, 0, 1048654, 23, 0, 1048655, 23, 0, 1048656, 23, 0, 1048657, 23, 0, 1048658, 23, 0, 1048659, 23, 0, 1048660, 23, 0, 1048661, 23, 0, 1048662, 23, 0, 1048663, 23, 0, 1048664, 23, 0, 1048665, 23, 0, 1048666, 23, 0, 1048667, 23, 0, 1048668, 23, 0, 1048669, 23, 0, 1048670, 23, 0, 1048671, 23, 0, 1048672, 23, 0, 1048673, 23, 0, 1048674, 23, 0, 1048675, 23, 0, 1048676, 23, 0, 1048677, 23, 0, 1048678, 23, 0, 1048679, 23, 0, 1048680, 23, 0, 1048681, 23, 0, 1048682, 23, 0, 1048683, 23, 0, 1048684, 23, 0, 1048685, 23, 0, 1048686, 23, 0, 1048687, 23, 0, 1048688, 23, 0, 1048689, 23, 0, 1048690, 23, 0, 1048691, 23, 0, 1048692, 23, 0, 1048693, 23, 0, 1048694, 23, 0, 1048695, 23, 0, 1048696, 23, 0, 1048697, 23, 0, 1048698, 23, 0, 1048699, 23, 0, 1048700, 23, 0, 1048701, 23, 0, 1048702, 23, 0, 1048703, 23, 0, 1048704, 23, 0, 1048705, 23, 0, 1048706, 23, 0, 1048707, 23, 0, 1048708, 23, 0, 1048709, 23, 0, 1048710, 23, 0, 1048711, 23, 0, 1048712, 23, 0, 1048713, 23, 0, 1048714, 23, 0, 1048715, 23, 0, 1048716, 23, 0, 1048717, 23, 0, 1048718, 23, 0, 1048719, 23, 0, 1048720, 23, 0, 1048721, 23, 0, 1048722, 23, 0, 1048723, 23, 0, 1048724, 23, 0, 1048725, 23, 0, 1048726, 23, 0, 1048727, 23, 0, 1048728, 23, 0, 1048729, 23, 0, 1048730, 23, 0, 1048731, 23, 0, 1048732, 23, 0, 1048733, 23, 0, 1048734, 23, 0, 1048735, 23, 0, 1048736, 23, 0, 1048737, 23, 0, 1048738, 23, 0, 1048739, 23, 0, 1048740, 23, 0, 1048741, 23, 0, 1048742, 23, 0, 1048743, 23, 0, 1048744, 23, 0, 1048745, 23, 0, 1048746, 23, 0, 1048747, 23, 0, 1048748, 23, 0, 1048749, 23, 0, 1048750, 23, 0, 1048751, 23, 0, 1048752, 23, 0, 1048753, 23, 0, 1048754, 23, 0, 1048755, 23, 0, 1048756, 23, 0, 1048757, 23, 0, 1048758, 23, 0, 1048759, 23, 0, 1048760, 23, 0, 1048761, 23, 0, 1048762, 23, 0, 1048763, 23, 0, 1048764, 23, 0, 1048765, 23, 0, 1048766, 23, 0, 1048767, 23, 0, 1048768, 23, 0, 1048769, 23, 0, 1048770, 23, 0, 1048771, 23, 0, 1048772, 23, 0, 1048773, 23, 0, 1048774, 23, 0, 1048775, 23, 0, 1048776, 23, 0, 1048777, 23, 0, 1048778, 23, 0, 1048779, 23, 0, 1048780, 23, 0, 1048781, 23, 0, 1048782, 23, 0, 1048783, 23, 0, 1048784, 23, 0, 1048785, 23, 0, 1048786, 23, 0, 1048787, 23, 0, 1048788, 23, 0, 1048789, 23, 0, 1048790, 23, 0, 1048791, 23, 0, 1048792, 23, 0, 1048793, 23, 0, 1048794, 23, 0, 1048795, 23, 0, 1048796, 23, 0, 1048797, 23, 0, 1048798, 23, 0, 1048799, 23, 0, 1048800, 23, 0, 1048801, 23, 0, 1048802, 23, 0, 1048803, 23, 0, 1048804, 23, 0, 1048805, 23, 0, 1048806, 23, 0, 1048807, 23, 0, 1048808, 23, 0, 1048809, 23, 0, 1048810, 23, 0, 1048811, 23, 0, 1048812, 23, 0, 1048813, 23, 0, 1048814, 23, 0, 1048815, 23, 0, 1048816, 23, 0, 1048817, 23, 0, 1048818, 23, 0, 1048819, 23, 0, 1048820, 23, 0, 1048821, 23, 0, 1048822, 23, 0, 1048823, 23, 0, 1048824, 23, 0, 1048825, 23, 0, 1048826, 23, 0, 1048827, 23, 0, 1048828, 23, 0, 1048829, 23, 0, 1114140, 6, 0, 1114141, 7, 0, 1114142, 23, 0, 1114143, 10, 0, 1114144, 23, 0, 1114145, 10, 0, 1114146, 23, 0, 1114147, 10, 0, 1114148, 23, 0, 1114149, 10, 0, 1114150, 23, 0, 1114151, 10, 0, 1114152, 23, 0, 1114153, 8, 0, 1114158, 19, 0 ) +tile_data = PoolIntArray( 131074, 20, 0, 262148, 20, 0, 393241, 1, 0, 393242, 2, 0, 393243, 17, 0, 393245, 1, 0, 393246, 15, 0, 393247, 15, 0, 393248, 15, 0, 393249, 15, 0, 393250, 15, 0, 393251, 15, 0, 393252, 17, 0, 458777, 4, 0, 458778, 7, 0, 458779, 8, 0, 458781, 4, 0, 458782, 10, 0, 458783, 9, 0, 458784, 10, 0, 458785, 9, 0, 458786, 10, 0, 458787, 9, 0, 458788, 16, 0, 458789, 17, 0, 524291, 20, 0, 524309, 1, 0, 524310, 2, 0, 524311, 3, 0, 524317, 19, 0, 524319, 19, 0, 524321, 19, 0, 524323, 4, 0, 524324, 10, 0, 524325, 16, 0, 524326, 17, 0, 589845, 6, 0, 589846, 7, 0, 589847, 8, 0, 589853, 19, 0, 589855, 19, 0, 589857, 19, 0, 589859, 19, 0, 589861, 13, 0, 589862, 16, 0, 589863, 17, 0, 655360, 3, 0, 655378, 1, 0, 655379, 3, 0, 655389, 19, 0, 655391, 19, 0, 655393, 19, 0, 655395, 19, 0, 655397, 4, 0, 655398, 10, 0, 655399, 16, 0, 655400, 17, 0, 720896, 12, 0, 720897, 20, 0, 720914, 6, 0, 720915, 8, 0, 720925, 19, 0, 720927, 19, 0, 720929, 19, 0, 720931, 19, 0, 720933, 19, 0, 720935, 13, 0, 720936, 10, 0, 720937, 17, 0, 720941, 25, 0, 720942, 2, 0, 720943, 24, 0, 786432, 12, 0, 786436, 20, 0, 786442, 18, 0, 786443, 1, 0, 786444, 2, 0, 786445, 2, 0, 786446, 2, 0, 786447, 2, 0, 786448, 3, 0, 786461, 19, 0, 786463, 19, 0, 786465, 19, 0, 786467, 19, 0, 786469, 19, 0, 786471, 19, 0, 786473, 19, 0, 786478, 19, 0, 851968, 12, 0, 851977, 18, 0, 851978, 16, 0, 851979, 6, 0, 851980, 7, 0, 851981, 7, 0, 851982, 7, 0, 851983, 7, 0, 851984, 8, 0, 851997, 19, 0, 851999, 19, 0, 852001, 19, 0, 852003, 19, 0, 852005, 19, 0, 852007, 19, 0, 852009, 19, 0, 852014, 19, 0, 983030, 20, 0, 917504, 12, 0, 917506, 20, 0, 917512, 18, 0, 917513, 16, 0, 917514, 0, 0, 917515, 5, 0, 917533, 19, 0, 917535, 19, 0, 917537, 19, 0, 917539, 19, 0, 917541, 19, 0, 917543, 19, 0, 917545, 19, 0, 917550, 19, 0, 983040, 12, 0, 983047, 18, 0, 983048, 16, 0, 983049, 0, 0, 983050, 0, 0, 983051, 5, 0, 983069, 19, 0, 983071, 19, 0, 983073, 19, 0, 983075, 19, 0, 983077, 19, 0, 983079, 19, 0, 983081, 19, 0, 983086, 19, 0, 1048576, 14, 0, 1048577, 2, 0, 1048578, 2, 0, 1048579, 2, 0, 1048580, 2, 0, 1048581, 2, 0, 1048582, 2, 0, 1048583, 2, 0, 1048584, 2, 0, 1048585, 2, 0, 1048586, 2, 0, 1048587, 2, 0, 1048588, 2, 0, 1048589, 2, 0, 1048590, 2, 0, 1048591, 2, 0, 1048592, 2, 0, 1048593, 2, 0, 1048594, 2, 0, 1048595, 2, 0, 1048596, 2, 0, 1048597, 2, 0, 1048598, 2, 0, 1048599, 2, 0, 1048600, 2, 0, 1048601, 2, 0, 1048602, 2, 0, 1048603, 2, 0, 1048604, 2, 0, 1048605, 5, 0, 1048607, 19, 0, 1048609, 19, 0, 1048611, 19, 0, 1048613, 19, 0, 1048615, 19, 0, 1048617, 19, 0, 1048622, 19, 0, 1048623, 23, 0, 1048624, 23, 0, 1048625, 23, 0, 1048626, 23, 0, 1048627, 23, 0, 1048628, 23, 0, 1048629, 23, 0, 1048630, 23, 0, 1048631, 23, 0, 1048632, 23, 0, 1048633, 23, 0, 1048634, 23, 0, 1048635, 23, 0, 1048636, 23, 0, 1048637, 23, 0, 1048638, 23, 0, 1048639, 23, 0, 1048640, 23, 0, 1048641, 23, 0, 1048642, 23, 0, 1048643, 23, 0, 1048644, 23, 0, 1048645, 23, 0, 1048646, 23, 0, 1048647, 23, 0, 1048648, 23, 0, 1048649, 23, 0, 1048650, 23, 0, 1048651, 23, 0, 1048652, 23, 0, 1048653, 23, 0, 1048654, 23, 0, 1048655, 23, 0, 1048656, 23, 0, 1048657, 23, 0, 1048658, 23, 0, 1048659, 23, 0, 1048660, 23, 0, 1048661, 23, 0, 1048662, 23, 0, 1048663, 23, 0, 1048664, 23, 0, 1048665, 23, 0, 1048666, 23, 0, 1048667, 23, 0, 1048668, 23, 0, 1048669, 23, 0, 1048670, 23, 0, 1048671, 23, 0, 1048672, 23, 0, 1048673, 23, 0, 1048674, 23, 0, 1048675, 23, 0, 1048676, 23, 0, 1048677, 23, 0, 1048678, 23, 0, 1048679, 23, 0, 1048680, 23, 0, 1048681, 23, 0, 1048682, 23, 0, 1048683, 23, 0, 1048684, 23, 0, 1048685, 23, 0, 1048686, 23, 0, 1048687, 23, 0, 1048688, 23, 0, 1048689, 23, 0, 1048690, 23, 0, 1048691, 23, 0, 1048692, 23, 0, 1048693, 23, 0, 1048694, 23, 0, 1048695, 23, 0, 1048696, 23, 0, 1048697, 23, 0, 1048698, 23, 0, 1048699, 23, 0, 1048700, 23, 0, 1048701, 23, 0, 1048702, 23, 0, 1048703, 23, 0, 1048704, 23, 0, 1048705, 23, 0, 1048706, 23, 0, 1048707, 23, 0, 1048708, 23, 0, 1048709, 23, 0, 1048710, 23, 0, 1048711, 23, 0, 1048712, 23, 0, 1048713, 23, 0, 1048714, 23, 0, 1048715, 23, 0, 1048716, 23, 0, 1048717, 23, 0, 1048718, 23, 0, 1048719, 23, 0, 1048720, 23, 0, 1048721, 23, 0, 1048722, 23, 0, 1048723, 23, 0, 1048724, 23, 0, 1048725, 23, 0, 1048726, 23, 0, 1048727, 23, 0, 1048728, 23, 0, 1048729, 23, 0, 1048730, 23, 0, 1048731, 23, 0, 1048732, 23, 0, 1048733, 23, 0, 1048734, 23, 0, 1048735, 23, 0, 1048736, 23, 0, 1048737, 23, 0, 1048738, 23, 0, 1048739, 23, 0, 1048740, 23, 0, 1048741, 23, 0, 1048742, 23, 0, 1048743, 23, 0, 1048744, 23, 0, 1048745, 23, 0, 1048746, 23, 0, 1048747, 23, 0, 1048748, 23, 0, 1048749, 23, 0, 1048750, 23, 0, 1048751, 23, 0, 1048752, 23, 0, 1048753, 23, 0, 1048754, 23, 0, 1048755, 23, 0, 1048756, 23, 0, 1048757, 23, 0, 1048758, 23, 0, 1048759, 23, 0, 1048760, 23, 0, 1048761, 23, 0, 1048762, 23, 0, 1048763, 23, 0, 1048764, 23, 0, 1048765, 23, 0, 1048766, 23, 0, 1048767, 23, 0, 1048768, 23, 0, 1048769, 23, 0, 1048770, 23, 0, 1048771, 23, 0, 1048772, 23, 0, 1048773, 23, 0, 1048774, 23, 0, 1048775, 23, 0, 1048776, 23, 0, 1048777, 23, 0, 1048778, 23, 0, 1048779, 23, 0, 1048780, 23, 0, 1048781, 23, 0, 1048782, 23, 0, 1048783, 23, 0, 1048784, 23, 0, 1048785, 23, 0, 1048786, 23, 0, 1048787, 23, 0, 1048788, 23, 0, 1048789, 23, 0, 1048790, 23, 0, 1048791, 23, 0, 1048792, 23, 0, 1048793, 23, 0, 1048794, 23, 0, 1048795, 23, 0, 1048796, 23, 0, 1048797, 23, 0, 1048798, 23, 0, 1048799, 23, 0, 1048800, 23, 0, 1048801, 23, 0, 1048802, 23, 0, 1048803, 23, 0, 1048804, 23, 0, 1048805, 23, 0, 1048806, 23, 0, 1048807, 23, 0, 1048808, 23, 0, 1048809, 23, 0, 1048810, 23, 0, 1048811, 23, 0, 1048812, 23, 0, 1048813, 23, 0, 1048814, 23, 0, 1048815, 23, 0, 1048816, 23, 0, 1048817, 23, 0, 1048818, 23, 0, 1048819, 23, 0, 1048820, 23, 0, 1048821, 23, 0, 1048822, 23, 0, 1048823, 23, 0, 1048824, 23, 0, 1048825, 23, 0, 1048826, 23, 0, 1048827, 23, 0, 1048828, 23, 0, 1048829, 23, 0, 1114140, 6, 0, 1114141, 7, 0, 1114142, 23, 0, 1114143, 10, 0, 1114144, 23, 0, 1114145, 10, 0, 1114146, 23, 0, 1114147, 10, 0, 1114148, 23, 0, 1114149, 10, 0, 1114150, 23, 0, 1114151, 10, 0, 1114152, 23, 0, 1114153, 8, 0, 1114158, 19, 0 ) [node name="ParallaxBackground" type="ParallaxBackground" parent="."] @@ -122,3 +151,18 @@ motion_mirroring = Vector2( 1920, 0 ) [node name="Sprite" type="Sprite" parent="ParallaxBackground/ParallaxLayer"] texture = ExtResource( 5 ) + +[node name="Enemy" parent="." instance=ExtResource( 8 )] +position = Vector2( 229, 77 ) + +[node name="DeathZone" type="Area2D" parent="."] +position = Vector2( 1, 328 ) +script = SubResource( 5 ) +__meta__ = { +"_edit_group_": true +} + +[node name="CollisionShape2D" type="CollisionShape2D" parent="DeathZone"] +shape = SubResource( 4 ) + +[connection signal="body_entered" from="DeathZone" to="." method="_on_DeathZone_entered"] diff --git a/enemies/Enemy.gd b/enemies/Enemy.gd new file mode 100644 index 0000000..d39c96f --- /dev/null +++ b/enemies/Enemy.gd @@ -0,0 +1,174 @@ +class_name Enemy +extends KinematicBody2D + +enum STATES { + SPAWN, + ROAM, # fly around until player is in reach + AGGRO, # get mad because you saw the player + CHARGE, #RUN to the player + ATTACK #fuck up the player if the sucker didnt run away +} + +export(float, 2.0, 150.0, 0.1) var attack_dist = 150.0 +export(float, 1.0, 500.0, 0.1) var roam_max_speed = 100.0 +export(float, 1.0, 200.0, 0.1) var attack_speed_mul = 10.0 +export(float, 0.01, 1.0, 0.01) var roam_acceleration = 0.4 +export(float, 0.01, 5.0, 0.01) var aggro_timer_len = 2.0 + +onready var ray := $RayCast2D +onready var anim_sprite := $AnimatedSprite + +var aggro_timer := Timer.new() +var noise_idx := 0.0 +var noise := OpenSimplexNoise.new() +var state = STATES.SPAWN +var player : Giovanna = null +var velocity := Vector2.ZERO +var dir := Vector2.RIGHT +var charge_target := Vector2.ZERO +var charge_collision : KinematicCollision2D = null +var charge_done := false +var spawn_done := false + +func _ready(): + add_child(aggro_timer) + aggro_timer.one_shot = true + aggro_timer.wait_time = aggro_timer_len + + anim_sprite.animation = "spawning" + anim_sprite.playing = true + + # Configure noise + randomize() + noise.seed = randi() + noise.octaves = 2 + noise.period = 20.0 + noise.persistence = 0.8 + +# yield(get_tree(), "idle_frame") + # Gets reference to the player from the root node + player = owner.get_meta("player") + + +func _physics_process(delta): + var new_s = check_state() + + if state != new_s: + state = new_s + init_state() + + run_state(delta) + +func check_state(): + if not player: + return STATES.ROAM + + match state: + STATES.SPAWN: + if spawn_done: + return STATES.ROAM + STATES.ROAM: + var p_pos = player.global_position + # let's be efficient and use the squared distance + var dist = global_position.distance_squared_to(p_pos) + + if dist <= pow(attack_dist, 2): + # it's in range + ray.cast_to = ray.to_local(p_pos) + ray.force_raycast_update() + + var coll = ray.get_collider() + if coll and coll == player: + # LADIES N GENTLEMEN WE GOT HIM + return STATES.AGGRO + STATES.AGGRO: + if aggro_timer.time_left <= 0.0: + return STATES.CHARGE + STATES.CHARGE: + charge_done = charge_collision and charge_collision.collider == player + if charge_done: + return STATES.ATTACK + STATES.ATTACK: + return state + if dist_to_player() > 20.0: + return STATES.ROAM + + return state + +func init_state(): + # Things to do when the state changes + match state: + STATES.SPAWN: + # nothing to do + pass + STATES.ROAM: + anim_sprite.modulate = Color.white + velocity *= 0.0 + dir = Vector2.RIGHT + anim_sprite.animation = "roaming" + anim_sprite.playing = true + STATES.AGGRO: + velocity *= 0.0 + dir = Vector2.RIGHT + aggro_timer.start() + charge_target = player.position + STATES.CHARGE: + charge_done = false + anim_sprite.offset *= 0.0 + STATES.ATTACK: + ## TEMP + velocity *= 0.0 + anim_sprite.modulate = Color.red + +func run_state(delta): + match state: + STATES.SPAWN: + # nothing to do + pass + STATES.ROAM: + noise_idx += delta * 100 + var _n = noise.get_noise_1d(noise_idx) + var n = range_lerp(_n, -1.0, 1.0, -TAU/4.0, TAU/4.0) + + dir = dir.linear_interpolate(dir.rotated(n * 0.1), 0.5) + + velocity = velocity.linear_interpolate(dir * roam_max_speed, roam_acceleration) + + var coll = move_and_collide(velocity * delta) + + var coll_horizontal := false + if coll: + var norm = coll.normal + if norm.y == 0: + # vertical wall + dir.x *= -1 + velocity.x *= -1 + else: + dir.y *= -1 + velocity.y *= -1 + + anim_sprite.flip_h = (velocity.x > 0) + STATES.AGGRO: + var r = 2.0 + anim_sprite.offset = Vector2(rand_range(-r, r), rand_range(-r, r)) + STATES.CHARGE: + var target_dist = position.distance_squared_to(charge_target) + var target_dir = position.direction_to(charge_target) + var speed = roam_max_speed * attack_speed_mul + var fac = target_dist/pow(attack_dist, 2) + + velocity = velocity.linear_interpolate(target_dir * speed, fac) + + move_and_slide(velocity) + + if get_slide_count() > 0: + charge_collision = get_slide_collision(0) + STATES.ATTACK: + pass + +func dist_to_player(): + return position.distance_to(player.position) + +func _on_AnimatedSprite_animation_finished(): + if anim_sprite.animation == "spawning": + spawn_done = true diff --git a/enemies/Enemy.tscn b/enemies/Enemy.tscn new file mode 100644 index 0000000..ff576ea --- /dev/null +++ b/enemies/Enemy.tscn @@ -0,0 +1,82 @@ +[gd_scene load_steps=13 format=2] + +[ext_resource path="res://ASSETS/enemy_spritesheet.png" type="Texture" id=1] +[ext_resource path="res://enemies/Enemy.gd" type="Script" id=2] + +[sub_resource type="AtlasTexture" id=8] +atlas = ExtResource( 1 ) +region = Rect2( 0, 0, 30, 30 ) + +[sub_resource type="AtlasTexture" id=9] +atlas = ExtResource( 1 ) +region = Rect2( 30, 0, 30, 30 ) + +[sub_resource type="AtlasTexture" id=10] +atlas = ExtResource( 1 ) +region = Rect2( 60, 0, 30, 30 ) + +[sub_resource type="AtlasTexture" id=11] +atlas = ExtResource( 1 ) +region = Rect2( 90, 0, 30, 30 ) + +[sub_resource type="SpriteFrames" id=1] +animations = [ { +"frames": [ SubResource( 8 ), SubResource( 9 ), SubResource( 10 ), SubResource( 11 ), SubResource( 10 ), SubResource( 9 ), SubResource( 8 ) ], +"loop": true, +"name": "roaming", +"speed": 30.0 +}, { +"frames": [ SubResource( 8 ), SubResource( 9 ), SubResource( 10 ), SubResource( 11 ) ], +"loop": false, +"name": "spawning", +"speed": 4.0 +} ] + +[sub_resource type="CircleShape2D" id=2] +radius = 42.0 + +[sub_resource type="Gradient" id=3] + +[sub_resource type="GradientTexture" id=4] +gradient = SubResource( 3 ) +width = 100 + +[sub_resource type="Gradient" id=5] +offsets = PoolRealArray( 0 ) +colors = PoolColorArray( 1, 0, 0, 1 ) + +[sub_resource type="GradientTexture" id=6] +gradient = SubResource( 5 ) +width = 100 + +[node name="Enemy" type="KinematicBody2D"] +scale = Vector2( 0.5, 0.5 ) +collision_mask = 5 +script = ExtResource( 2 ) + +[node name="AnimatedSprite" type="AnimatedSprite" parent="."] +scale = Vector2( 2, 2 ) +frames = SubResource( 1 ) +animation = "spawning" +flip_h = true + +[node name="RayCast2D" type="RayCast2D" parent="."] +enabled = true +cast_to = Vector2( 50, 0 ) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource( 2 ) + +[node name="DEBUG_Dir" type="Sprite" parent="."] +visible = false +scale = Vector2( 1, 4 ) +texture = SubResource( 4 ) +offset = Vector2( 50, 0 ) + +[node name="DEBUG_Vel" type="Sprite" parent="."] +visible = false +scale = Vector2( 0.48, 4 ) +texture = SubResource( 6 ) +offset = Vector2( 50, 0 ) + +[connection signal="animation_finished" from="AnimatedSprite" to="." method="_on_AnimatedSprite_animation_finished"] diff --git a/project.godot b/project.godot index 061f565..0c6b688 100644 --- a/project.godot +++ b/project.godot @@ -8,9 +8,26 @@ config_version=4 +_global_script_classes=[ { +"base": "KinematicBody2D", +"class": "Enemy", +"language": "GDScript", +"path": "res://enemies/Enemy.gd" +}, { +"base": "KinematicBody2D", +"class": "Giovanna", +"language": "GDScript", +"path": "res://Giovanna.gd" +} ] +_global_script_class_icons={ +"Enemy": "", +"Giovanna": "" +} + [application] config/name="Platformer" +run/main_scene="res://Level1.tscn" config/icon="res://icon.png" [display] @@ -70,6 +87,11 @@ jump={ "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":32,"unicode":0,"echo":false,"script":null) ] } +quit={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777217,"physical_scancode":0,"unicode":0,"echo":false,"script":null) + ] +} [physics]