From e50ead9360e1fd0309c98232e13ba05c520f9ed3 Mon Sep 17 00:00:00 2001 From: OddlyTimbot Date: Mon, 7 Oct 2024 20:36:58 -0400 Subject: [PATCH] final week 6 working death, damage, punch, enemy death --- .../graphics/environment/foreground.png | Bin 0 -> 2207 bytes .../environment/foreground.png.import | 34 ++++++++ .../player/hurt/Player Hurt 48x48.png | Bin 0 -> 1448 bytes .../player/hurt/Player Hurt 48x48.png.import | 34 ++++++++ .../player/punch/Player Punch 64x64.png | Bin 0 -> 3228 bytes .../punch/Player Punch 64x64.png.import | 34 ++++++++ augustgamecourse/scenes/game.tscn | 42 ++++++++- augustgamecourse/scenes/player.tscn | 80 +++++++++++++++++- augustgamecourse/scenes/ui.tscn | 38 +++++++++ augustgamecourse/scripts/game_controller.gd | 4 + augustgamecourse/scripts/player.gd | 68 ++++++++++++--- augustgamecourse/scripts/scene_manager.gd | 13 ++- augustgamecourse/scripts/ui.gd | 10 +++ 13 files changed, 334 insertions(+), 23 deletions(-) create mode 100644 augustgamecourse/assets/graphics/environment/foreground.png create mode 100644 augustgamecourse/assets/graphics/environment/foreground.png.import create mode 100644 augustgamecourse/assets/graphics/player/hurt/Player Hurt 48x48.png create mode 100644 augustgamecourse/assets/graphics/player/hurt/Player Hurt 48x48.png.import create mode 100644 augustgamecourse/assets/graphics/player/punch/Player Punch 64x64.png create mode 100644 augustgamecourse/assets/graphics/player/punch/Player Punch 64x64.png.import create mode 100644 augustgamecourse/scenes/ui.tscn create mode 100644 augustgamecourse/scripts/ui.gd diff --git a/augustgamecourse/assets/graphics/environment/foreground.png b/augustgamecourse/assets/graphics/environment/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..25ade8cc993a2a0cd13de6dc01cbdf4639f4aaa2 GIT binary patch literal 2207 zcmc&#`9Bkm8{b&2BFCi3v1&O-@j>K>m}?EGG$f2M_kGSW(uc^cA)?gCHP%5(Bwx$% zZIkqFu>gQlZhWqx<$vtJ_iV4z>{UcgfJ3_N9>dep zb$un%?M@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;r=siI#U*)Y~r2>?p{q5^o{3eOZuZU%h^~c?M`o@Yw zWjJ>REPB}Vd@6uYD^ZaWd|vW zJa08LLMToAm-H!zE-DVoA}Us(n>5U|q4&-wIbTKBqsH=n3gqs+jbeU==&$l>xzq9j zPl*aP&I+DdCt2mm>vd&aS|WL?3R`w7nlSVqY+6Szjx#C7kNG~#Wwbx*+|UvU!^9lm4L`jc z?!+eqmY2DDMeI<^PFSxerks3Bs$rH|B>NW6Va6HQAaW5sUOl?^TlpZNK<1*0V*82n zVOO%`_(-E$%H0`=>_Kt5n*6)g0!OIeYg>9g09cY4EimQF=U6 zK~_44A?}u)KScgaNw>|yfVbbjo*?);p=8uh8v-qw$fDP}d{^QG#bXqw2mBn=R(k#S z8?xta3^I&R@kit2!X<3rcxw#jV7Dye`SkWU{DUDn zsu$Vgu$5$T+8L>O-WiC^v3>oD?} zDRwoEj}5>FvqJ+`YgK9XA3Y!?BwNqk-S56~?OjV@)03^K&aNl#&zDmkOh6o6YpZY~ zYFEjR^of3KM~q_-=hn=C#(cET8(g4$!rC3x>BW%jBL^ep8T0X!+rAylQ|yA~wyW{C z)i*r6#WK7GWS`>oA)~8zy8brcw^UX=kMdNLfDv*uec@u E59Ai?NdN!< literal 0 HcmV?d00001 diff --git a/augustgamecourse/assets/graphics/environment/foreground.png.import b/augustgamecourse/assets/graphics/environment/foreground.png.import new file mode 100644 index 0000000..6065d50 --- /dev/null +++ b/augustgamecourse/assets/graphics/environment/foreground.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dqa6ro66e3j1d" +path="res://.godot/imported/foreground.png-dbbd7dc92b4c96ae99e46b292c2d728f.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/graphics/environment/foreground.png" +dest_files=["res://.godot/imported/foreground.png-dbbd7dc92b4c96ae99e46b292c2d728f.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/augustgamecourse/assets/graphics/player/hurt/Player Hurt 48x48.png b/augustgamecourse/assets/graphics/player/hurt/Player Hurt 48x48.png new file mode 100644 index 0000000000000000000000000000000000000000..57d878395e3581c75dc07562589c4c209606485d GIT binary patch literal 1448 zcmV;Z1y}lsP)Px)Vo5|nRCt{2n@>y}RUF4ZkJerOE#kjMStQgHNr?OjDhY`uTxqn~MsGFI8%cX2 z#+wHZ-nkf)9-7#Lo=hNMy_gUWrUz6Ku)&lxmefL8tXe6HK*8r>dAl>i%(BbQ?!JNF zC)s3n-t6r6_vZI~zxQT#K@bE%5ClOG1VIo4K@bE%5ClOG1VIo4;mDxEKB3kcfQ3g} z+PS|g5mx|8h5nVH@&3Aq|r=_kK&wGEuT zmfemKQw=rs)TufE&aa%SkiuY`+5tYA+TfG-rd`JjoV~_c_tUEBm%q4lf25-N3dI?R zUkp~>2EDsErvcVCHeLJM9_;Qr_Ro850JOfDbbVj7&EV|#;VTb$bTgKVnw}Fa`j(3H%HIITHZHRh;MEc($q) z;h^LizHn7g?I6s=!@9VRFw`3-wCCUn zV_s{X2{^C8L2>M%6RMH%mPy82CPUG1@~|IF#(UKA)_k@zm$&A1JmA>6jzQJhk=b@8 z{@!-g=0Uxk?TjQR)aSs|g?8;7MNf|{Dp&-rnq5{cU`CP?%1^fg)m*>By^L;W;#alb zA!lTB4TdkY2O85gm8(gZr5l*ZT~pTRL4wxs)cg|^>Sl% zyOL6hCP;fe-GkqKW;U%dZ!vUqUso|=WvOI`t^i6YwATA70YG|N(-6z_cU{Mz@_we; zCNPX7C-&*E-2?`&cCYTYzg+TLs9VwRP9vKt2ALTAs_^YmNH4qtWvFB&RRA-pC*wUT z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!+ zRFPq!$@dF+D6yBMxdG{#A1;X4P+M$PTI*Lwv3no@9upJVfo%HL4*^D(GF)u86Br$? zVd7_Z-7JPIG%p9{9r@V^z&{ob!ip#)y*$qT=i{k5S=$l|EG+H_^`aRMb&+R=6mg*fxK#ua zIgxHU^@Ft1xMQEzCE}TGOnRNr%RT#jFiCtPD@V(hU=N&)W0odGx7|kxwV3*Cqrz@B zQs*|tLH&i6Jb|e?LR!uoeitJeXsguC+wjQwos<-DVcy+#^1^K*7F=oKTomL?6?4|T>$N#aX`XtAg<8?Ccg{=xPmpsv1e5xfy99;RSbv@m NQ$s6*D!rTc{{!G)IeY*B literal 0 HcmV?d00001 diff --git a/augustgamecourse/assets/graphics/player/punch/Player Punch 64x64.png.import b/augustgamecourse/assets/graphics/player/punch/Player Punch 64x64.png.import new file mode 100644 index 0000000..fd4d484 --- /dev/null +++ b/augustgamecourse/assets/graphics/player/punch/Player Punch 64x64.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c0oo6kno61i0b" +path="res://.godot/imported/Player Punch 64x64.png-d36156dc820906936bd540ab6e3cc9ce.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/graphics/player/punch/Player Punch 64x64.png" +dest_files=["res://.godot/imported/Player Punch 64x64.png-d36156dc820906936bd540ab6e3cc9ce.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/augustgamecourse/scenes/game.tscn b/augustgamecourse/scenes/game.tscn index 8e93b48..e656428 100644 --- a/augustgamecourse/scenes/game.tscn +++ b/augustgamecourse/scenes/game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=15 format=4 uid="uid://diss5ty7548p3"] +[gd_scene load_steps=17 format=4 uid="uid://diss5ty7548p3"] [ext_resource type="Texture2D" uid="uid://cjdayl6k7xt2s" path="res://assets/graphics/environment/background/forestbackground.png" id="1_7cw2b"] [ext_resource type="PackedScene" uid="uid://0j0320rcnxo7" path="res://scenes/crate.tscn" id="1_8ekmb"] @@ -10,6 +10,8 @@ [ext_resource type="PackedScene" uid="uid://csewven6s5npw" path="res://scenes/trigger.tscn" id="3_t3xge"] [ext_resource type="PackedScene" uid="uid://dkqrujmfd1dt4" path="res://scenes/coin.tscn" id="3_xdwxn"] [ext_resource type="PackedScene" uid="uid://chg3b7bwi8e5v" path="res://scenes/badguy.tscn" id="10_wtwdm"] +[ext_resource type="PackedScene" uid="uid://dw0mifscsrgaw" path="res://scenes/ui.tscn" id="11_41b0s"] +[ext_resource type="Texture2D" uid="uid://dqa6ro66e3j1d" path="res://assets/graphics/environment/foreground.png" id="12_1m160"] [sub_resource type="TileMapPattern" id="TileMapPattern_pcobp"] tile_data = PackedInt32Array(0, 0, 4, 1, 65536, 4, 2, 65536, 4, 3, 131072, 4) @@ -419,11 +421,11 @@ script = ExtResource("1_mpwqj") [node name="Timer" type="Timer" parent="SceneManager"] [node name="TileMapLayer" type="TileMapLayer" parent="."] -tile_map_data = PackedByteArray("AAACAAUAAAAPAAQAAAADAAUAAAABAAQAAAAEAAUAAAABAAQAAAAFAAUAAAABAAQAAAAHAAQAAAAAAAIAAAAIAAQAAAABAAIAAAAJAAQAAAACAAIAAAAJAAMAAAACAAAAAAAIAAMAAAABAAAAAAAHAAMAAAAAAAAAAAAIAAAAAAAEAAQAAAALAAIAAAAAAAQAAAAMAAIAAAAQAAQAAAAMAAEAAAAPAAMAAAANAAEAAAACAAQAAAAMAAUAAAAAAAQAAAANAAUAAAABAAQAAAAOAAUAAAABAAQAAAAPAAUAAAACAAQAAAAGAAUAAAACAAQAAAAQAAMAAAAAAAQAAAARAAM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AdAAYAAAABAAQAAAAeAAYAAAABAAQAAAAfAAYAAAAQAAQAAAAfAAUAAAAEAAEAAAAfAAQAAAAPAAMAAAAgAAQAAAABAAQAAAAhAAQAAAABAAQAAAAiAAQAAAACAAQAAAA=") tile_set = SubResource("TileSet_cs2mx") [node name="Floor" type="StaticBody2D" parent="."] -position = Vector2(94, 183) +position = Vector2(94, 160) metadata/_edit_group_ = true [node name="CollisionShape2D" type="CollisionShape2D" parent="Floor"] @@ -456,6 +458,15 @@ metadata/_edit_group_ = true [node name="Coin" parent="coins" instance=ExtResource("3_xdwxn")] position = Vector2(206, 151) +[node name="Coin4" parent="coins" instance=ExtResource("3_xdwxn")] +position = Vector2(396, 155) + +[node name="Coin5" parent="coins" instance=ExtResource("3_xdwxn")] +position = Vector2(588, 91) + +[node name="Coin6" parent="coins" instance=ExtResource("3_xdwxn")] +position = Vector2(556, -5) + [node name="Coin2" parent="coins" instance=ExtResource("3_xdwxn")] position = Vector2(263, 89) @@ -467,7 +478,32 @@ position = Vector2(368, 57) [node name="slime" parent="enemies" instance=ExtResource("10_wtwdm")] position = Vector2(282, 84) +[node name="slime3" parent="enemies" instance=ExtResource("10_wtwdm")] +position = Vector2(414, 20) + +[node name="slime4" parent="enemies" instance=ExtResource("10_wtwdm")] +position = Vector2(455, 148) + +[node name="slime5" parent="enemies" instance=ExtResource("10_wtwdm")] +position = Vector2(357, 212) + [node name="slime2" parent="enemies" instance=ExtResource("10_wtwdm")] position = Vector2(106, 149) +[node name="CanvasLayer" type="CanvasLayer" parent="."] + +[node name="Control" parent="CanvasLayer" instance=ExtResource("11_41b0s")] +offset_left = 10.0 +offset_top = 8.0 +offset_right = -6.0 +metadata/_edit_lock_ = true + +[node name="Parallax2D" type="Parallax2D" parent="."] +scroll_scale = Vector2(2, 2) +repeat_size = Vector2(320, 0) + +[node name="Sprite2D" type="Sprite2D" parent="Parallax2D"] +position = Vector2(160, 130) +texture = ExtResource("12_1m160") + [connection signal="timeout" from="SceneManager/Timer" to="SceneManager" method="resetWorld"] diff --git a/augustgamecourse/scenes/player.tscn b/augustgamecourse/scenes/player.tscn index 8b8266d..7115328 100644 --- a/augustgamecourse/scenes/player.tscn +++ b/augustgamecourse/scenes/player.tscn @@ -1,10 +1,12 @@ -[gd_scene load_steps=39 format=3 uid="uid://dbgc24hrbtvxm"] +[gd_scene load_steps=49 format=3 uid="uid://dbgc24hrbtvxm"] [ext_resource type="Script" path="res://scripts/player.gd" id="1_5qpif"] [ext_resource type="Texture2D" uid="uid://d6d3re6epsh4" path="res://assets/graphics/player/death/Player Death 64x64.png" id="2_t1yra"] [ext_resource type="Texture2D" uid="uid://pdvgf3y1lquv" path="res://assets/graphics/player/idle/Player Idle 48x48.png" id="2_vcmr0"] [ext_resource type="Texture2D" uid="uid://cvh48exhs1ir1" path="res://assets/graphics/player/run/player run 48x48.png" id="3_a03rx"] [ext_resource type="Texture2D" uid="uid://d0kfe5ms2vjbr" path="res://assets/graphics/player/jump/player jump 48x48.png" id="3_mvdmt"] +[ext_resource type="Texture2D" uid="uid://chroktky8p0g1" path="res://assets/graphics/player/hurt/Player Hurt 48x48.png" id="3_td76e"] +[ext_resource type="Texture2D" uid="uid://c0oo6kno61i0b" path="res://assets/graphics/player/punch/Player Punch 64x64.png" id="6_cp1mx"] [sub_resource type="AtlasTexture" id="AtlasTexture_uru55"] atlas = ExtResource("2_t1yra") @@ -46,6 +48,22 @@ region = Rect2(384, 0, 48, 48) atlas = ExtResource("2_t1yra") region = Rect2(432, 0, 48, 48) +[sub_resource type="AtlasTexture" id="AtlasTexture_tm0rm"] +atlas = ExtResource("3_td76e") +region = Rect2(0, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_yv45b"] +atlas = ExtResource("3_td76e") +region = Rect2(48, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_qcxh5"] +atlas = ExtResource("3_td76e") +region = Rect2(96, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_32phs"] +atlas = ExtResource("3_td76e") +region = Rect2(144, 0, 48, 48) + [sub_resource type="AtlasTexture" id="AtlasTexture_etdvv"] atlas = ExtResource("2_vcmr0") region = Rect2(0, 0, 48, 48) @@ -98,6 +116,22 @@ region = Rect2(48, 0, 48, 48) atlas = ExtResource("3_mvdmt") region = Rect2(96, 0, 48, 48) +[sub_resource type="AtlasTexture" id="AtlasTexture_m3mm6"] +atlas = ExtResource("6_cp1mx") +region = Rect2(128, 0, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_651rh"] +atlas = ExtResource("6_cp1mx") +region = Rect2(192, 0, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_pwqvs"] +atlas = ExtResource("6_cp1mx") +region = Rect2(256, 0, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_1vc4x"] +atlas = ExtResource("6_cp1mx") +region = Rect2(320, 0, 64, 64) + [sub_resource type="AtlasTexture" id="AtlasTexture_qxesk"] atlas = ExtResource("3_a03rx") region = Rect2(0, 0, 48, 48) @@ -169,6 +203,23 @@ animations = [{ }, { "frames": [{ "duration": 1.0, +"texture": SubResource("AtlasTexture_tm0rm") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_yv45b") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_qcxh5") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_32phs") +}], +"loop": false, +"name": &"hurt", +"speed": 12.0 +}, { +"frames": [{ +"duration": 1.0, "texture": SubResource("AtlasTexture_etdvv") }, { "duration": 1.0, @@ -218,6 +269,23 @@ animations = [{ }, { "frames": [{ "duration": 1.0, +"texture": SubResource("AtlasTexture_m3mm6") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_651rh") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_pwqvs") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_1vc4x") +}], +"loop": false, +"name": &"punch", +"speed": 12.0 +}, { +"frames": [{ +"duration": 1.0, "texture": SubResource("AtlasTexture_qxesk") }, { "duration": 1.0, @@ -256,7 +324,7 @@ metadata/_edit_group_ = true texture_filter = 1 position = Vector2(0, -7) sprite_frames = SubResource("SpriteFrames_wlxdo") -animation = &"death" +animation = &"idle" autoplay = "idle" [node name="CollisionShape2D" type="CollisionShape2D" parent="."] @@ -264,13 +332,17 @@ shape = SubResource("CircleShape2D_mcosy") debug_color = Color(0.826895, 0.282133, 0.703752, 0.42) [node name="RightRay" type="RayCast2D" parent="."] -target_position = Vector2(16, 0) +target_position = Vector2(19, 0) +collide_with_areas = true [node name="LeftRay" type="RayCast2D" parent="."] -target_position = Vector2(-17, 0) +target_position = Vector2(-19, 0) +collide_with_areas = true [node name="MarkerRight" type="Node2D" parent="."] position = Vector2(12, -5) [node name="MarkerLeft" type="Node2D" parent="."] position = Vector2(-15, -5) + +[connection signal="animation_finished" from="AnimatedSprite2D" to="." method="_on_animation_finished"] diff --git a/augustgamecourse/scenes/ui.tscn b/augustgamecourse/scenes/ui.tscn new file mode 100644 index 0000000..9d66288 --- /dev/null +++ b/augustgamecourse/scenes/ui.tscn @@ -0,0 +1,38 @@ +[gd_scene load_steps=2 format=3 uid="uid://dw0mifscsrgaw"] + +[ext_resource type="Script" path="res://scripts/ui.gd" id="1_ndnyg"] + +[node name="Control" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_ndnyg") + +[node name="VBoxContainer" type="VBoxContainer" parent="."] +layout_mode = 1 +anchors_preset = 10 +anchor_right = 1.0 +grow_horizontal = 2 + +[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"] +layout_mode = 2 + +[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="Health" type="Label" parent="VBoxContainer/HBoxContainer/MarginContainer"] +layout_mode = 2 +text = "Health : 100" + +[node name="MarginContainer2" type="MarginContainer" parent="VBoxContainer/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="Coins" type="Label" parent="VBoxContainer/HBoxContainer/MarginContainer2"] +layout_mode = 2 +text = "Coins : 0" +horizontal_alignment = 2 diff --git a/augustgamecourse/scripts/game_controller.gd b/augustgamecourse/scripts/game_controller.gd index 290de5b..0ce24f7 100644 --- a/augustgamecourse/scripts/game_controller.gd +++ b/augustgamecourse/scripts/game_controller.gd @@ -4,6 +4,8 @@ var coinsCollected:int = 0 var player:Resource signal playerDeath +signal coinsUpdate(amt) +signal playerHealth(currentHealth) func _ready() -> void: print("Game controller is ready") @@ -13,6 +15,7 @@ func _ready() -> void: func coinCollected(): coinsCollected +=1 print("Game Controller Coin Collected : "+str(coinsCollected)) + coinsUpdate.emit(coinsCollected) func resetPlayer(): player.health = player.max_health @@ -21,6 +24,7 @@ func playerDamage(): #one can not kill what is dead.... if player.health >0: player.health -= 20 + playerHealth.emit(player.health) #is the player dead? if player.health <= 0: #kill him diff --git a/augustgamecourse/scripts/player.gd b/augustgamecourse/scripts/player.gd index 2b11021..940dccf 100644 --- a/augustgamecourse/scripts/player.gd +++ b/augustgamecourse/scripts/player.gd @@ -7,10 +7,15 @@ const PUSH_FORCE = 700 var faceLeft = false var living = true +var animPlaying="jump" +signal playerDead # can i push right or left var pushLeftEnabled = false var pushRightEnabled = false +var punchLeftEnabled = false +var punchRightEnabled = false + @onready var right_ray: RayCast2D = $RightRay @onready var left_ray: RayCast2D = $LeftRay @onready var marker_right: Node2D = $MarkerRight @@ -18,6 +23,7 @@ var pushRightEnabled = false @onready var playerSprite: AnimatedSprite2D = $AnimatedSprite2D var pushTarget +var punchTarget:Enemy var bullet = preload("res://scenes/bullet.tscn") @@ -26,10 +32,15 @@ func killPlayer(): if living: living = false #play death animation - playerSprite.play("death") + animPlaying="death" + playerSprite.play(animPlaying) +func hurtPlayer(currentHealth): + print("current health is : "+str(currentHealth)) + animPlaying="hurt" + playerSprite.play(animPlaying) func _physics_process(delta: float) -> void: - if living: + if living and not animPlaying=="hurt": # Add the gravity. if not is_on_floor(): velocity += get_gravity() * delta @@ -37,14 +48,23 @@ func _physics_process(delta: float) -> void: # Handle jump. if Input.is_action_just_pressed("ui_accept") and is_on_floor(): velocity.y = JUMP_VELOCITY - - if Input.is_action_just_pressed("Shove") && pushLeftEnabled && faceLeft: - pushTarget.apply_central_impulse(Vector2(-1,0) * PUSH_FORCE * 1.5) - pushLeftEnabled = false + if Input.is_action_just_pressed("Shove"): + animPlaying="punch" + playerSprite.play(animPlaying) + if punchLeftEnabled && faceLeft: + punchTarget.queue_free() + punchLeftEnabled = false + if punchRightEnabled && not faceLeft: + punchTarget.queue_free() + punchRightEnabled = false - if Input.is_action_just_pressed("Shove") && pushRightEnabled && not faceLeft: - pushTarget.apply_central_impulse(Vector2(1,0) * PUSH_FORCE * 1.5) - pushRightEnabled=false + if pushLeftEnabled && faceLeft: + pushTarget.apply_central_impulse(Vector2(-1,0) * PUSH_FORCE * 1.5) + pushLeftEnabled = false + + if pushRightEnabled && not faceLeft: + pushTarget.apply_central_impulse(Vector2(1,0) * PUSH_FORCE * 1.5) + pushRightEnabled=false if Input.is_action_just_pressed("shoot"): if faceLeft: @@ -71,10 +91,11 @@ func _physics_process(delta: float) -> void: velocity.x = move_toward(velocity.x, 0, SPEED) if is_on_floor(): - if direction == 0: - playerSprite.play("idle") - else: - playerSprite.play("run") + if not animPlaying == "punch": + if direction == 0: + playerSprite.play("idle") + else: + playerSprite.play("run") else: playerSprite.play("jump") @@ -90,9 +111,14 @@ func _physics_process(delta: float) -> void: if collider.is_in_group("pushables"): pushLeftEnabled = true pushTarget = collider + if collider is Enemy: + print("I can punch on left") + punchTarget = collider + punchLeftEnabled = true else: #do something else pushLeftEnabled = false + punchLeftEnabled = false if right_ray.is_colliding(): var collider = right_ray.get_collider() @@ -100,5 +126,21 @@ func _physics_process(delta: float) -> void: if collider.is_in_group("pushables"): pushRightEnabled = true pushTarget = collider + if collider is Enemy: + print("I can punch on the right") + punchTarget = collider + punchRightEnabled = true else: pushRightEnabled = false + punchRightEnabled = false + + +func _on_animation_finished() -> void: + print("animation finished "+animPlaying) + if animPlaying=="hurt": + animPlaying="idle" + if animPlaying=="death": + #send a signal + playerDead.emit() + if animPlaying=="punch": + animPlaying="idle" diff --git a/augustgamecourse/scripts/scene_manager.gd b/augustgamecourse/scripts/scene_manager.gd index a4fda1d..479e846 100644 --- a/augustgamecourse/scripts/scene_manager.gd +++ b/augustgamecourse/scripts/scene_manager.gd @@ -9,6 +9,7 @@ var cratePool:Array = [] @onready var enemies: Node = $"../enemies" @onready var player: CharacterBody2D = $"../CharacterBody2D" @onready var timer: Timer = $Timer +@onready var ui: Control = $"../CanvasLayer/Control" # Called when the node enters the scene tree for the first time. func _ready() -> void: @@ -28,6 +29,11 @@ func _ready() -> void: n.playerDamage.connect(GameController.playerDamage) #GameController signals GameController.playerDeath.connect(killPlayer) + GameController.coinsUpdate.connect(ui.coinsUpdate) + GameController.playerHealth.connect(ui.healthUpdate) + GameController.playerHealth.connect(player.hurtPlayer) + #Player signals + player.playerDead.connect(playerDead) func boxTrap(): print("Trigger a box trap!") @@ -66,11 +72,12 @@ func crateFactory(): func killPlayer(): # tell player to die - starts death animation player.killPlayer() - if timer.is_stopped(): - timer.start(4) - func resetWorld(): print("screne manager resetting world") GameController.resetPlayer() get_tree().reload_current_scene() + +func playerDead(): + if timer.is_stopped(): + timer.start(1) diff --git a/augustgamecourse/scripts/ui.gd b/augustgamecourse/scripts/ui.gd new file mode 100644 index 0000000..4d90f84 --- /dev/null +++ b/augustgamecourse/scripts/ui.gd @@ -0,0 +1,10 @@ +extends Control +@onready var health: Label = $VBoxContainer/HBoxContainer/MarginContainer/Health +@onready var coins: Label = $VBoxContainer/HBoxContainer/MarginContainer2/Coins + + +func healthUpdate(amt): + health.text = "Health : "+str(amt) + +func coinsUpdate(amt): + coins.text = "Coins : "+str(amt)