From 2dd2c13b193f1edbd1a7c825289d1fc9ec55f386 Mon Sep 17 00:00:00 2001 From: OddlyTimbot Date: Mon, 6 Jul 2026 14:32:07 -0400 Subject: [PATCH] adding a charge attack to states --- Week3Readme.md | 6 +++ .../player/charge/Player Punch 64x64.png | Bin 0 -> 3228 bytes .../charge/Player Punch 64x64.png.import | 40 +++++++++++++++ scenes/player.tscn | 48 +++++++++++++++++- scripts/player.gd | 18 ++++++- scripts/scene_manager.gd | 2 +- 6 files changed, 110 insertions(+), 4 deletions(-) create mode 100644 Week3Readme.md create mode 100644 assets/graphics/player/charge/Player Punch 64x64.png create mode 100644 assets/graphics/player/charge/Player Punch 64x64.png.import diff --git a/Week3Readme.md b/Week3Readme.md new file mode 100644 index 0000000..d5c4315 --- /dev/null +++ b/Week3Readme.md @@ -0,0 +1,6 @@ +Here in week3 we have several missions to achieve. + +1. Update the Bullet with some graphics +2. Update the player with graphics and a state-machine +3. Update the destroy function in SceneManager to stash bullets +4. Update level loading in GameController and SceneManager diff --git a/assets/graphics/player/charge/Player Punch 64x64.png b/assets/graphics/player/charge/Player Punch 64x64.png new file mode 100644 index 0000000000000000000000000000000000000000..c9a466098265a13f5f26383823f223194031eb4e GIT binary patch literal 3228 zcmb_f`8U)J7yk~`*ai)yEDYC8jg>KkOPC7)0EnrHfgJ#_9hCrr zU#G?~H`~X5zjbgcHPOE-AF%Y@ET*}$Os>(t!mk+Vu*o;E=P$De?0Y){8?UPw#{Q+Ps&vWMRAZu4??Ct|ExPentv#*@4>L3Mm;$LoJ7$wP2Z8 zu+}J>JC0u={*uM_2Z&rap{T$y{oa*z0bAa6kGjb@F5u+JQ;il*ryNN(NsLA|iHu(- zz>>vidg_GIA9hjlibphy=)9vj4O8HXx)$z~{*sKc3=hoU+`WDSk_na!O9gK6v2 zonKCO&Yrm>><7xo{XFnOQ}$T-u%yj_v=KaibpM-=Vqu9d*Ma``W7;ZlSZnf!Noom% zC$r0fhwAaLh&*IOlO+Me!ahdpYWF(vq(IL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=4cPeVqL`O8S$9(1{voy4!!#aeS1WfVtLs&T z)75H1by13WAULasSbH#~G(q8mO<0lQA!IQQOh7g+dv@>?MUBH`P`XcAoNk8jZ}ty_y;~s5webh1_4o3NQ!RG*N{ARWDSDHqU+v2F*R7 zEdF)VX(Q6>&&>k(%aes!%;ldYW$!wAmuscXE}OCZLnOb$t~;LsIR)UwjK|U&2Ue zjpN2de}2s#5Rm)4^L~&G(b_Io;c08J@@sh<&fp~8kNp*#DHO-L#j1@FwggaQs^c*F2W-V_+BM6Xu z#qKnK%GT0Y*@0nxA&?@HQYd!6zYS9EegvQc9{Y}~N3>hFmoM)PW2<6D)GyS0p_3!+ 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/assets/graphics/player/charge/Player Punch 64x64.png.import b/assets/graphics/player/charge/Player Punch 64x64.png.import new file mode 100644 index 0000000..e809353 --- /dev/null +++ b/assets/graphics/player/charge/Player Punch 64x64.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://t2wrpg2jjey2" +path="res://.godot/imported/Player Punch 64x64.png-3a937f356fef19bd687f033e25d25550.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/graphics/player/charge/Player Punch 64x64.png" +dest_files=["res://.godot/imported/Player Punch 64x64.png-3a937f356fef19bd687f033e25d25550.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +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/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +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/scenes/player.tscn b/scenes/player.tscn index a4eb2cc..ced5798 100644 --- a/scenes/player.tscn +++ b/scenes/player.tscn @@ -2,11 +2,16 @@ [ext_resource type="Script" uid="uid://b1obldvd2etx7" path="res://scripts/player.gd" id="1_3vyb7"] [ext_resource type="Texture2D" uid="uid://c84o6tpt2h0s8" path="res://assets/graphics/player/jump_fall/player jump 48x48.png" id="2_dqkch"] +[ext_resource type="Texture2D" uid="uid://t2wrpg2jjey2" path="res://assets/graphics/player/charge/Player Punch 64x64.png" id="2_qlg0r"] [ext_resource type="Texture2D" uid="uid://bhjnspvqa20rc" path="res://assets/graphics/player/idle/Player Idle 48x48.png" id="3_qlg0r"] [ext_resource type="Texture2D" uid="uid://jdvo0dp5qvnd" path="res://assets/graphics/player/running/player run 48x48.png" id="4_tuyoq"] [sub_resource type="CircleShape2D" id="CircleShape2D_uwrxv"] +[sub_resource type="AtlasTexture" id="AtlasTexture_tuyoq"] +atlas = ExtResource("2_qlg0r") +region = Rect2(192, 0, 64, 64) + [sub_resource type="AtlasTexture" id="AtlasTexture_fjrip"] atlas = ExtResource("2_dqkch") region = Rect2(96, 0, 48, 48) @@ -91,10 +96,34 @@ region = Rect2(288, 0, 48, 48) atlas = ExtResource("4_tuyoq") region = Rect2(336, 0, 48, 48) +[sub_resource type="AtlasTexture" id="AtlasTexture_qlg0r"] +atlas = ExtResource("2_qlg0r") +region = Rect2(192, 0, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_pf23h"] +atlas = ExtResource("2_qlg0r") +region = Rect2(256, 0, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_dt7fs"] +atlas = ExtResource("2_qlg0r") +region = Rect2(320, 0, 64, 64) + +[sub_resource type="AtlasTexture" id="AtlasTexture_wqfne"] +atlas = ExtResource("2_qlg0r") +region = Rect2(384, 0, 64, 64) + [sub_resource type="SpriteFrames" id="SpriteFrames_pf23h"] animations = [{ "frames": [{ "duration": 1.0, +"texture": SubResource("AtlasTexture_tuyoq") +}], +"loop": false, +"name": &"charging", +"speed": 12.0 +}, { +"frames": [{ +"duration": 1.0, "texture": SubResource("AtlasTexture_fjrip") }], "loop": false, @@ -175,6 +204,23 @@ animations = [{ "loop": true, "name": &"running", "speed": 12.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_qlg0r") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_pf23h") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_dt7fs") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_wqfne") +}], +"loop": false, +"name": &"shoving", +"speed": 12.0 }] [node name="Player" type="CharacterBody2D" unique_id=2145223914] @@ -202,7 +248,7 @@ position = Vector2(-12.837839, -8.108109) texture_filter = 1 position = Vector2(0, -6.081082) sprite_frames = SubResource("SpriteFrames_pf23h") -animation = &"falling" +animation = &"shoving" autoplay = "idle" [connection signal="animation_finished" from="PlayerGraphic" to="." method="_on_animation_finished"] diff --git a/scripts/player.gd b/scripts/player.gd index 5686fc0..55aecc1 100644 --- a/scripts/player.gd +++ b/scripts/player.gd @@ -19,7 +19,7 @@ const JUMP_VELOCITY = -400.0 enum FaceDirection {RIGHT,LEFT} var facing:FaceDirection = FaceDirection.RIGHT #State Handling -enum PlayerState {IDLE, RUNNING, JUMPING, FALLING} +enum PlayerState {IDLE, RUNNING, JUMPING, FALLING, CHARGING, SHOVING} var current_player_state:PlayerState = PlayerState.IDLE var upJump:bool = false @@ -43,15 +43,23 @@ func handle_input()->void: # Handle shove. if Input.is_action_just_pressed("shove"): print("I want to shove") - pushTimer = Time.get_ticks_msec() + if pushRightEnabled and facing==FaceDirection.RIGHT: + pushTimer = Time.get_ticks_msec() + current_player_state = PlayerState.CHARGING + if pushLeftEnabled and facing==FaceDirection.LEFT: + pushTimer = Time.get_ticks_msec() + current_player_state = PlayerState.CHARGING + if Input.is_action_just_released("shove"): var pushForce = Time.get_ticks_msec() - pushTimer if pushForce>4000: pushForce=4000 if pushRightEnabled and facing==FaceDirection.RIGHT: #deliver the boom + current_player_state=PlayerState.SHOVING pushSignal.emit(pushTarget, Vector2(1,0)*100*(pushForce/100)) if pushLeftEnabled and facing==FaceDirection.LEFT: + current_player_state=PlayerState.SHOVING pushSignal.emit(pushTarget, Vector2(-1,0)*100*(pushForce/100)) #Handle Shoot Bullet if Input.is_action_just_pressed("shoot"): @@ -140,9 +148,15 @@ func handle_update_animation()->void: player_graphic.play("jumping") PlayerState.FALLING: player_graphic.play("falling") + PlayerState.CHARGING: + player_graphic.play("charging") + PlayerState.SHOVING: + player_graphic.play("shoving") func _on_animation_finished() -> void: match current_player_state: PlayerState.JUMPING: upJump = false + PlayerState.SHOVING: + current_player_state = PlayerState.IDLE diff --git a/scripts/scene_manager.gd b/scripts/scene_manager.gd index 881ed5c..98d1fad 100644 --- a/scripts/scene_manager.gd +++ b/scripts/scene_manager.gd @@ -58,7 +58,7 @@ func stash(bullet:Bullet)->void: func destroy(body)->void: match body: var bod when bod is Rocket: - print("removing rocket") + body.queue_free() var bod when bod is Crate: body.queue_free() var bod when bod is Bullet: