From ffd98d163ee4760344d35e9d835949ee22051408 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 16 Oct 2025 23:27:09 -0400 Subject: [PATCH] added shooting animation; timer is a little broken --- .../player_jump/player new jump 48x48.png | Bin 0 -> 2912 bytes .../player new jump 48x48.png.import | 40 +++++ .../Player Running Shooting 48x48.png | Bin 0 -> 3605 bytes .../Player Running Shooting 48x48.png.import | 40 +++++ .../player_shoot/player shoot 2H 48x48.png | Bin 0 -> 1705 bytes .../player shoot 2H 48x48.png.import | 40 +++++ project.godot | 1 + scenes/player.tscn | 146 +++++++++++++++++- scripts/player.gd | 50 ++++-- 9 files changed, 302 insertions(+), 15 deletions(-) create mode 100644 graphics/player_jump/player new jump 48x48.png create mode 100644 graphics/player_jump/player new jump 48x48.png.import create mode 100644 graphics/player_shoot/Player Running Shooting 48x48.png create mode 100644 graphics/player_shoot/Player Running Shooting 48x48.png.import create mode 100644 graphics/player_shoot/player shoot 2H 48x48.png create mode 100644 graphics/player_shoot/player shoot 2H 48x48.png.import diff --git a/graphics/player_jump/player new jump 48x48.png b/graphics/player_jump/player new jump 48x48.png new file mode 100644 index 0000000000000000000000000000000000000000..2551816a6257fae2f0224050f65631cb3017956c GIT binary patch literal 2912 zcmV-m3!n6fP)Px=8c9S!RCt{2om*@a=M~5QXV-i2+Fjc*wy})^E(Ovgl(nJs@<0)^k{d*0DOD7y zs%)u9$h@U$ky2h;2~nw)@_;m6l;<=YM9t^Z(AAnOy?{fj}S-2m}IwKp+qZ1OkCTAP@)y z0)apv5C{YUfj}S-2m}IwKu~Fr6Ccv|=NmxS4=k=QwAPqD|IE$}PVB}tgnsX-^caNx z;wagGatPP$gVz%v^m|XG#~}0i%#nS#iO}yol^%o8Ulh(5kU$_16oD`x zfk5CHRbC4a2n6mkaJEZ+6JUTJplaaczIfi-hsHm}(S0X$%TA0OEm@Z{1{C%aK2PLq zU~!GmUp91!5CkX)q@_PX^1o&qLttWxB7eK3CV&$Izfi1nD-^09C~ph{XS-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L@>34lu=OvMz z>z?CGvgmyHOmjY{lseW?i(c|6Ap4PjJ#*0}z?qr%hr}kX49Uq-n+~^FJ$B^h)(tRA z*(A5D>n{HevtlA>E)1%bYX%`R^Y>4Pb)MMf`pZZ+0lkzXw?!&-+H;=|XrxC*|+o{#X#R*z49Lv_s=S!-cd3 zAj_5iZbvV(%X96$WMA!izQNvj#{26W5JL11C_{>_h4-65H5xeaU_VcC#4;Yvp6AV~ zxfl+rgH{yHO2WH6xRY51^G&+~Mw~NX*&4S2e4lF^O99r`)b9rjLh1yPvb2RspQ|=~ qD;|b3T=!e#-+!e^^&g(3@Duffj#|PgiIO|d06-67tX-w)_~!qHSi`#j literal 0 HcmV?d00001 diff --git a/graphics/player_shoot/Player Running Shooting 48x48.png.import b/graphics/player_shoot/Player Running Shooting 48x48.png.import new file mode 100644 index 0000000..9caa919 --- /dev/null +++ b/graphics/player_shoot/Player Running Shooting 48x48.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dadvc8tsvmkb6" +path="res://.godot/imported/Player Running Shooting 48x48.png-47c63e435c65b23aebd6a86cf7f30ecb.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://graphics/player_shoot/Player Running Shooting 48x48.png" +dest_files=["res://.godot/imported/Player Running Shooting 48x48.png-47c63e435c65b23aebd6a86cf7f30ecb.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/graphics/player_shoot/player shoot 2H 48x48.png b/graphics/player_shoot/player shoot 2H 48x48.png new file mode 100644 index 0000000000000000000000000000000000000000..62041bf73b76c44210d09465e19c81f2b2b92911 GIT binary patch literal 1705 zcmZ`(Yfw`M77n6-FoG_XXLzVoONGYD)*z1rdB{tMPPe^mheb=ceXqiAs9fA7%oDE1h|Qk3n4coY@FSnyXVI_XXbo!=FB*dwrkJ*P8Tmy@bWlbq3#HF?ZuB11ECi zLw&L_r0jxIFooCAdAHB?faXl}x^{UKQS&`+JXicki(~Mu1M3vWU6IrYYU8-})6(3| zt#^KNYqijMZVJw_`GHqyk9^4}eg0Vi!4yrN7E(qIwMCnjyj?LT2_LV5e@!8|1h)c6 z<7W5iK1wVBonD`;j8x0=74VJ;nbj4Cb-;rdOHS>Uw&RPo5z<%70dzOGO9)9 z35_Zh<@nM}M#|LiR!P?EHa-hGbi?c3uQ`j+VL!YY|DGh7l9u&osSLCxHu9sAU6)`~ z)1Ok`vkiM>_cipN8ESz?831nS-N^dv$MBB?Y~NFr-DIJ-kjIvb^LsTOi0D%xm3cT# zQREz6S#A=%povh_U8rX&y=UGIC?^F@!M6CO;+2Os@4Ld*a@-fCHAj+;wavDP9-9|O zAG~)}G=r91Vbr|bd9NKg?fMRW$h;n)ZuHm_&bg7KjztsyF@RS#h+)^}B5j-og0DrZnvB<=qXL` zenU@l0*`l53bn%Nmy}f>oP%|$jui-OD9X}eJ%2U}WQ`480KY%fAI= zTb7XOA|4lhzVd4Bw8A~|`H=bQ4oyPI)=Ln z>`F@t%}M^kx&Pt{=m$1mRwwa|))orXk9+2<>2e8&bvdRet5}QL@orIAbG=k@#g)yB zm~ptMxm6~6DU&XWq8_IH!e)`lcQp1fcND}TW_%P9lWN?XF7xWKeBnxtOk>CrA6e%- zh0b?)id~$=>_+bRzU__s_g}-Tzi8;R$x(L()~`+hRYBzeKn+KirAS z^#__a(m>U;!xz)YXZ$xm)5Vn^q3*uyT~ke$3!1chc46suAfGVSW`q9iRsmsG%8kkZ z4igP|tHqx5draG^jNfrpf@3HPP^NJx62JdfQT-nU!7UXc^S&8rOOY9_ zEwbN72Rs>*4Sd&#l88Lq7lx;9XY?*D2|k09#E@j_QXDPb22IYNgY)O*`5&b70^)>_ z?{4&%Ur*jm84MlMBNNl={-a4>IKx*?^K~%PbV&rQ5B7EUC?^IF96cnbD+8WD4pkYR zN45$HfP@7CP70xAd?xkcDhCa!#~b6+e4> z!jUpTrP31#;hWr+Kc~S;3yW$`H@D^t${Diry0&+j6h#aIM=E2Yq z)9Se>7`2Xv=*UU-VCG;>N{zt>FPiW3zywQKe5W7oqfj)+QA0Zmjk!~t9}&;$YDrvS$kh^ z{c|dwbNPyN|8O88TBTo8xKJq|*)N1*&_F~~egG`N)lFG0&bDo;PZO`gx|M^jy4z7l ztHI$t6-jd93hb);lpH1}e5qwXo5JP#01hEM$9qHI-Wof-PUZEa3AHz&z#{AOCE)c>D9{SyIjso@bfUY20-p&lF%?%(43)!+XO{{V#Y literal 0 HcmV?d00001 diff --git a/graphics/player_shoot/player shoot 2H 48x48.png.import b/graphics/player_shoot/player shoot 2H 48x48.png.import new file mode 100644 index 0000000..5705b80 --- /dev/null +++ b/graphics/player_shoot/player shoot 2H 48x48.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://crll0t2wjtsly" +path="res://.godot/imported/player shoot 2H 48x48.png-9803739eaed87b62419b05b35dcbe01e.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://graphics/player_shoot/player shoot 2H 48x48.png" +dest_files=["res://.godot/imported/player shoot 2H 48x48.png-9803739eaed87b62419b05b35dcbe01e.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/project.godot b/project.godot index aa14200..84edab7 100644 --- a/project.godot +++ b/project.godot @@ -11,6 +11,7 @@ config_version=5 [application] config/name="September Game AB" +config/tags=PackedStringArray("2d", "lesson", "platformer") run/main_scene="uid://cueixogtk70go" config/features=PackedStringArray("4.5", "Forward Plus") config/icon="res://icon.svg" diff --git a/scenes/player.tscn b/scenes/player.tscn index e4132c4..d4480b6 100644 --- a/scenes/player.tscn +++ b/scenes/player.tscn @@ -1,9 +1,11 @@ -[gd_scene load_steps=27 format=3 uid="uid://d3y1iqmpknpyo"] +[gd_scene load_steps=47 format=3 uid="uid://d3y1iqmpknpyo"] [ext_resource type="Script" uid="uid://d3hp5rjoph7hg" path="res://scripts/player.gd" id="1_3vyb7"] [ext_resource type="Texture2D" uid="uid://dr3rp5hv7rexv" path="res://graphics/player_idle/Player Idle 48x48.png" id="2_g2els"] [ext_resource type="Texture2D" uid="uid://uxdt2cgxicmt" path="res://graphics/player_jump/player jump 48x48.png" id="3_dqkch"] [ext_resource type="Texture2D" uid="uid://bgp8oow6hgh5o" path="res://graphics/player_run/player run 48x48.png" id="4_qlg0r"] +[ext_resource type="Texture2D" uid="uid://dadvc8tsvmkb6" path="res://graphics/player_shoot/Player Running Shooting 48x48.png" id="5_tuyoq"] +[ext_resource type="Texture2D" uid="uid://crll0t2wjtsly" path="res://graphics/player_shoot/player shoot 2H 48x48.png" id="6_fjrip"] [sub_resource type="CapsuleShape2D" id="CapsuleShape2D_3vyb7"] radius = 6.0 @@ -89,6 +91,78 @@ region = Rect2(288, 0, 48, 48) atlas = ExtResource("4_qlg0r") region = Rect2(336, 0, 48, 48) +[sub_resource type="AtlasTexture" id="AtlasTexture_f1ej7"] +atlas = ExtResource("5_tuyoq") +region = Rect2(0, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_l71n6"] +atlas = ExtResource("5_tuyoq") +region = Rect2(48, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ke2ow"] +atlas = ExtResource("5_tuyoq") +region = Rect2(96, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ujl30"] +atlas = ExtResource("5_tuyoq") +region = Rect2(144, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_31cv2"] +atlas = ExtResource("5_tuyoq") +region = Rect2(192, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_pf23h"] +atlas = ExtResource("5_tuyoq") +region = Rect2(240, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_dt7fs"] +atlas = ExtResource("5_tuyoq") +region = Rect2(288, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_wqfne"] +atlas = ExtResource("5_tuyoq") +region = Rect2(336, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_wnwbv"] +atlas = ExtResource("6_fjrip") +region = Rect2(0, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_gl8cc"] +atlas = ExtResource("6_fjrip") +region = Rect2(48, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_487ah"] +atlas = ExtResource("6_fjrip") +region = Rect2(96, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_md1ol"] +atlas = ExtResource("6_fjrip") +region = Rect2(144, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_bj30b"] +atlas = ExtResource("6_fjrip") +region = Rect2(192, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_jc3p3"] +atlas = ExtResource("6_fjrip") +region = Rect2(240, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_hax0n"] +atlas = ExtResource("6_fjrip") +region = Rect2(288, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_t4otl"] +atlas = ExtResource("6_fjrip") +region = Rect2(336, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_j2b1d"] +atlas = ExtResource("6_fjrip") +region = Rect2(384, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_cs1tg"] +atlas = ExtResource("6_fjrip") +region = Rect2(432, 0, 48, 48) + [sub_resource type="SpriteFrames" id="SpriteFrames_3vyb7"] animations = [{ "frames": [{ @@ -170,6 +244,70 @@ animations = [{ "loop": true, "name": &"run", "speed": 15.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_f1ej7") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_l71n6") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ke2ow") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ujl30") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_31cv2") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_pf23h") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_dt7fs") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_wqfne") +}], +"loop": false, +"name": &"shoot_run", +"speed": 15.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_wnwbv") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_gl8cc") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_487ah") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_md1ol") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_bj30b") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_jc3p3") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_hax0n") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_t4otl") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_j2b1d") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_cs1tg") +}], +"loop": false, +"name": &"shoot_still", +"speed": 15.0 }] [node name="Player" type="CharacterBody2D"] @@ -188,14 +326,14 @@ target_position = Vector2(50, 0) target_position = Vector2(-50, 0) [node name="RightSpawn" type="Marker2D" parent="."] -position = Vector2(10, -4) +position = Vector2(16, -7) [node name="LeftSpawn" type="Marker2D" parent="."] -position = Vector2(-10, -4) +position = Vector2(-16, -7) [node name="PlayerSprite" type="AnimatedSprite2D" parent="."] sprite_frames = SubResource("SpriteFrames_3vyb7") -animation = &"jump" +animation = &"shoot_run" autoplay = "idle" [node name="Camera2D" type="Camera2D" parent="."] diff --git a/scripts/player.gd b/scripts/player.gd index effd5d7..fc29eec 100644 --- a/scripts/player.gd +++ b/scripts/player.gd @@ -1,10 +1,12 @@ -extends CharacterBody2D +class_name Player extends CharacterBody2D +## Character controller. +## TODO: fix bullet cooldown timer const SPEED = 300.0 const JUMP_VELOCITY = -600.0 enum FaceDirection{LEFT, RIGHT} -enum State{IDLE, WALK, JUMP, FALLING} +enum State{IDLE, WALK, JUMP, FALLING, SHOOT_STILL, SHOOT_RUN} @export var BUMP_POWER := 50 @export var SHOVE_POWER := 200 @@ -14,9 +16,10 @@ enum State{IDLE, WALK, JUMP, FALLING} var current_state: State = State.IDLE var facing : FaceDirection = FaceDirection.RIGHT var direction : float = 0.0 -var jump_buffer_timer : Timer var push_target : RigidBody2D var push_enabled : bool = false +var jump_buffer_timer : Timer +var shoot_cooldown_timer : Timer @onready var right_cast: RayCast2D = $RightCast @onready var left_cast: RayCast2D = $LeftCast @@ -27,6 +30,9 @@ var push_enabled : bool = false func _ready() -> void: jump_buffer_timer = Timer.new() add_child(jump_buffer_timer) + shoot_cooldown_timer = Timer.new() + shoot_cooldown_timer.one_shot = true + add_child(shoot_cooldown_timer) func _physics_process(delta: float) -> void: handle_input() @@ -65,14 +71,22 @@ func handle_input() -> void: # Handle shooting if Input.is_action_just_pressed("shoot"): - print("pew-pew") - match facing: - FaceDirection.RIGHT: - %SceneManager.make_bullet(right_spawn.global_transform, 700) - print("shoot right") - FaceDirection.LEFT: - %SceneManager.make_bullet(left_spawn.global_transform, -700) - print("shoot left") + if shoot_cooldown_timer.time_left == 0: + if velocity.x: + current_state = State.SHOOT_RUN + else: + current_state = State.SHOOT_STILL + print("pew-pew") + match facing: + FaceDirection.RIGHT: + %SceneManager.make_bullet(right_spawn.global_transform, 700) + print("shoot right") + FaceDirection.LEFT: + %SceneManager.make_bullet(left_spawn.global_transform, -700) + print("shoot left") + shoot_cooldown_timer.start(0.2) + else: + print("can't shoot right now because there are %s seconds left in the cooldown timer" % shoot_cooldown_timer.time_left) # Handle throwing grenades if Input.is_action_just_pressed("throw"): @@ -152,6 +166,16 @@ func update_state() -> void: current_state = State.IDLE else: current_state = State.WALK + + # Player shooting + State.SHOOT_STILL: + await player_sprite.animation_finished + current_state = State.IDLE + + # Player shooting while moving + State.SHOOT_RUN: + await player_sprite.animation_finished + current_state = State.WALK func update_animation() -> void: match facing: @@ -168,3 +192,7 @@ func update_animation() -> void: player_sprite.play("jump") State.FALLING: player_sprite.play("fall") + State.SHOOT_STILL: + player_sprite.play("shoot_still") + State.SHOOT_RUN: + player_sprite.play("shoot_run")