From b52ead255754c6bd3c339d76e68bd8d6c628fbb3 Mon Sep 17 00:00:00 2001 From: AhmedBelman Date: Mon, 10 Mar 2025 21:05:25 -0400 Subject: [PATCH] player animations, variable triggers, working bullets --- febfabgame/Assets/graphics/objects/crate.png | Bin 0 -> 1761 bytes .../Assets/graphics/objects/crate.png.import | 34 ++++ .../player/idle/Player Idle 48x48.png | Bin 0 -> 1853 bytes .../player/idle/Player Idle 48x48.png.import | 34 ++++ .../player/jump/player jump 48x48.png | Bin 0 -> 1021 bytes .../player/jump/player jump 48x48.png.import | 34 ++++ .../graphics/player/run/player run 48x48.png | Bin 0 -> 3199 bytes .../player/run/player run 48x48.png.import | 34 ++++ .../graphics/projectiles/pixel_bullet.png | Bin 0 -> 3870 bytes .../projectiles/pixel_bullet.png.import | 34 ++++ febfabgame/Scenes/bullet.tscn | 8 +- febfabgame/Scenes/crate.tscn | 20 ++ febfabgame/Scenes/feb_fab_game.tscn | 90 ++++----- febfabgame/Scenes/player.tscn | 180 +++++++++++++++++- febfabgame/Scenes/trigger.tscn | 10 + febfabgame/Scripts/Player.gd | 18 +- febfabgame/Scripts/bullet.gd | 8 +- febfabgame/Scripts/crate.gd | 1 + febfabgame/Scripts/gamecontroller.gd | 38 +++- febfabgame/Scripts/scene_manager.gd | 25 ++- febfabgame/Scripts/trigger.gd | 8 +- febfabgame/project.godot | 8 + 22 files changed, 514 insertions(+), 70 deletions(-) create mode 100644 febfabgame/Assets/graphics/objects/crate.png create mode 100644 febfabgame/Assets/graphics/objects/crate.png.import create mode 100644 febfabgame/Assets/graphics/player/idle/Player Idle 48x48.png create mode 100644 febfabgame/Assets/graphics/player/idle/Player Idle 48x48.png.import create mode 100644 febfabgame/Assets/graphics/player/jump/player jump 48x48.png create mode 100644 febfabgame/Assets/graphics/player/jump/player jump 48x48.png.import create mode 100644 febfabgame/Assets/graphics/player/run/player run 48x48.png create mode 100644 febfabgame/Assets/graphics/player/run/player run 48x48.png.import create mode 100644 febfabgame/Assets/graphics/projectiles/pixel_bullet.png create mode 100644 febfabgame/Assets/graphics/projectiles/pixel_bullet.png.import create mode 100644 febfabgame/Scenes/crate.tscn create mode 100644 febfabgame/Scenes/trigger.tscn create mode 100644 febfabgame/Scripts/crate.gd diff --git a/febfabgame/Assets/graphics/objects/crate.png b/febfabgame/Assets/graphics/objects/crate.png new file mode 100644 index 0000000000000000000000000000000000000000..2b8bdcd0c0b752f7079f09620a2121e2f556f925 GIT binary patch literal 1761 zcmeAS@N?(olHy`uVBq!ia0y~yV66aQ7G|Kx3)K}YKuS8mC&ZPJk@4EviZj!bwidfg zOR#ARv&?lj3p3XP%3l(wOM?7@862M7NMm4NEAe!345_&F=3paGhM{4>-<9Gk znLx}@fG-5n-t%Qiw=HDgiN4G+!%1VxA&nj<%_&X>BHo%UP8u@~@xA||ayrX=Yw@c0 zyIl&!e2eOzewl*LKoaCON2))%{^Iur)(-I_+>c!MD8vcqcZh#%s&L!`7OCC(ZT*}5 z6@oy)Bi%qjko+T7n7sAUX?G5p-eFs}u-+`;_)!!EU@agc55!z6;G16XZ)x!P7yfz& z#SLsLu^Sin_Ocky)sk&TAFjUh_MP-Ji#s_xAvVKYhGg^pX?%B&O0};w*WR}LXz;H5 zjk~e9p7otM@`~+RfsV?wOo=^<5XlcM5Sp|AOUVUd#V+YLkwB-qK{vgR@Vg zdKT^%g?o!L7ia&RJ^f|C<*jFLpF~v#4KrXU-YXA!eBn|gXSHY5^;ZcRx!ZBO?oXCg zN&D$(C1Jn1E2VTlG8u#14099Il}(^vC@*{LxWP<9@Al=SF!t`VaoxB)!v5>o(;rup z>*WKZ-)zMdfYm#~r}Zv7{AuR`#AxyOjLF2a+COAqGwX zVAt99L|H|7etHtIYrUj`Fwo(!#DNIjk4*WAyweN#Ok?IfuzvD?1Ka*Kbx0~g1S~9F zJ)g8crE>Rg*Oa#xv%B|-Atg3gA^_XK|2W%3>{|4lOE)!juhpEz6|0SlYZ*5ef0NnQ z@bV+=&x(nlmPi0iTCqz3tK4;;V}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IDyC@CGc0CwR_45$7iKhQJ7O(5uq>(i!6j1>#r9a}O%{&F z8(QZpI9=pgG-Nb# zI^Kz!r2K`Lz2Kp?zmEQ7U} zLs5iSL^ysQndjn_Z_)cK!3y?8`13c+Y_To1lzKf`rD(zM^$i(L=C%6^9Hexzmp9TP7J z3x2D_5a!4t4@Lw;++IjPL?TE)*M!XouFOAKKtr?u-6Zv(YkUXdi)sf zak0Mh>nO11+UfNJza4o$n<0Rk1Z07%>MV|KH|Cnd*}PH={w!JoU_k}q;T@2{2S2OR zD+a#QyBe@rHR$i1USRL^qA`5(r#B^2wb1c{XQEaxHcV>?NY(}bx#42)8SNHPEAhx+ zwgbTUmm?2ozQJTIB3(a3CTazbJxT1)Zea|u@~8|2{NOX;WZ4432(zCtQ7d>^3MYza z`pO61;cUJh#UB&2?YppT6D78R|4^6h|6#?IDsW4&75XzcI( zI|u+6TJ`se!ZF#4lOpqh+0S5p*beUt&(-{yaUWs}2=GNDGqzgZXbL{yCx91`EdrAH za5aCX+;6jxRN?`E{`@|6r*cN^Po;%Do_#4@uM~^*CnFzWVt7lNu6Os9ze}qfq(y&z zAN~3LRNk#6AiixSnJ2yu4LOwnk>Ay7)+Q(!7+wzKMJ61R2SEE47DYJB3DHoS125zG z=NfjWa)C7$d|>gvJRb?fU-ZQUv9Iw_V7=DGio;H>%!gN%iq-8`MjGM)49-BT&x$2f zCLY@o5T)$9hFE?0!P#ULO;mw=BX5G;-Lu&+QdMkLz^zYNPI6;W(H&45@yQ*hzGvh%)2y re59^(3$vL{@`WG>f*=TjXb=AZ>!Ac3Jx|zZ00000NkvXXu0mjfKxWs7 literal 0 HcmV?d00001 diff --git a/febfabgame/Assets/graphics/player/jump/player jump 48x48.png.import b/febfabgame/Assets/graphics/player/jump/player jump 48x48.png.import new file mode 100644 index 0000000..c590102 --- /dev/null +++ b/febfabgame/Assets/graphics/player/jump/player jump 48x48.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bv1oc2iwohejk" +path="res://.godot/imported/player jump 48x48.png-cb96bf53d7104a8fe475749788ee547c.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/graphics/player/jump/player jump 48x48.png" +dest_files=["res://.godot/imported/player jump 48x48.png-cb96bf53d7104a8fe475749788ee547c.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/febfabgame/Assets/graphics/player/run/player run 48x48.png b/febfabgame/Assets/graphics/player/run/player run 48x48.png new file mode 100644 index 0000000000000000000000000000000000000000..aca5b5560dba7381b8b06e68e76b1cadf80992cb GIT binary patch literal 3199 zcma)9^;^@A6Mt`Xi~$1$1SS$rKnI9~AWT9A7By5FhZ0gs*VyPV2z5#h>5vvhLVEb2 z6#|ptye9JS+HM=N^|Z-|@euWVtE3n8^*?bSqWe%{ z{V-W{aT4hZ2<_8CQ3D)(XS!5(_Hx+b5)1WD<~>ZdI)J-m~pd!=O9z#Dri_@&m0->;X0VOz8_M}@&=jH)9< zAoz>Fo1E=(9R&E|=bX@VK^*3Pxe2L*kRzQlt^{A9zE3xzP=68{-nyZ;y|ZUO%pUMO zUq#k?8kDW@PAtJg-zJIO*oU&sZh1Oea3ACC|9#T60)Xq}{$wfq_?%Q&k=+tgP#R%4 z^xF+PCsE+659=(^cAeReHaZ-FJ#>KrlmD{pD&fV?;h8Pu3b-o^yz+8YREOxKm~&76 zw#s?o#PUS*W*n7E^v*t#=@k6!RzF80d~Fh{i@aF*f;So1@yqN)i#$GL?h&$lc2uec zvUaYECHH6A+h(bD^ozxcoJ87u0WjF14%}@?{<2mnkvkIPAt!k_gJwHcRg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Vg>fg~T I)3Fc#A5dKsJ^%m! literal 0 HcmV?d00001 diff --git a/febfabgame/Assets/graphics/player/run/player run 48x48.png.import b/febfabgame/Assets/graphics/player/run/player run 48x48.png.import new file mode 100644 index 0000000..bc71160 --- /dev/null +++ b/febfabgame/Assets/graphics/player/run/player run 48x48.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://ciaht230dnmu3" +path="res://.godot/imported/player run 48x48.png-9864f67f072e7f64b36c65e3e85745f1.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/graphics/player/run/player run 48x48.png" +dest_files=["res://.godot/imported/player run 48x48.png-9864f67f072e7f64b36c65e3e85745f1.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/febfabgame/Assets/graphics/projectiles/pixel_bullet.png b/febfabgame/Assets/graphics/projectiles/pixel_bullet.png new file mode 100644 index 0000000000000000000000000000000000000000..900d030a8645ee217d7bdefb51fb303033b44488 GIT binary patch literal 3870 zcmeAS@N?(olHy`uVBq!ia0y~yU|a{p4jgPikte%nWH2!BJ@s^P45^5Fd*|Rz>(~*w_5v zXJlgG5a8haBXCMf3(Wpu5F^J3Vl83e316j`$SI)UaG;=)8K_KQf{;PX%3Uq04h;;9 zhoABSWf~m34iqeXB{YozsD)>`IY@>{lkxD>Ro)RGlMQ0-fn-Jv8x6D3q%mZ((;cB7 z*X`^7RJ}fsU;E?y|G#VfYgYaLr(gej$Cv#(_3dk8ivGR6zrObVa;K7+m5tv2m1l)B zeW+(VT>4Fd=laa~ms#q>fCa%pU7$$!>)HI$>x}J}b4uvtKiJmraF_45ZsxYvXU=Cb zwVjsUp_{NHZ?fb%W25DqHOdd%Tjh>|b)D|#I=^F%+K1IZMTd8&0u>bk73o1ti8)X( zSMrxE*rq>yFhhRIUYDGCnFS9gl1jP;MDDwzHG&+h;K+2GdvZU3J3 zw12hxb6V2B``5mvhX2KG3zs(cw7q7~FSt^`>Lv8Ckn!+WidJRfU>Qme)IV_W1S8ZsAl~#Tk^0= z?0Z4Z;jacO)_ZeEtaI^g(~i1a-k-Z;pY=xj2dzwPuUnVKbUw+C37=y3Kb`0L^Y=G+ z_k&CePu#KSsIAQH0$ZL}uZ5V}v;!y0i@Ih1dbg4Hdb#>H_B{ay3ifW8qCN3X@9VBh z&;R#4{Pjn6_d@E4JM4U?x{DjexYzKxv;OJTj+%qvj{WveUbCOuKj-7`(|>;e zD^V>PX7iQjS%3-a{%e2fb=Sj7L@prwy6%`+O!(4S^NnN9-dkb^ zj`#KUxjW+GF9tdsEC&>94-xA_0#h3)i=JcjDe~5+4o##d7kGB`Ri9ff) z$|Sz-*N>{Fg|UD4Y2SZp%%a8Aw))Z)?;@#no0Zn_^**#JF8fu?EwS$W-S>~T8^@$C zfn)`HZVA2j52gXL$I-86+j+rB8(6&-L?0-)tM>aS$SJ_246K9i0CU#%lRV(0zEAMO zVyFH`U|mn$Thn9wgnxtr6(!yQ*4x{602NKY4639H^b&TQ void: # Add the gravity. if not is_on_floor(): velocity += get_gravity() * delta + else: + isJumping = false + + # Handle jump. if Input.is_action_just_pressed("ui_accept") and is_on_floor(): velocity.y = JUMP_VELOCITY + isJumping = true + playerGraphic.play("jump") # Get the input direction and handle the movement/deceleration. # As good practice, you should replace UI actions with custom gameplay actions. @@ -47,11 +55,19 @@ func _physics_process(delta: float) -> void: velocity.x = direction * SPEED else: velocity.x = move_toward(velocity.x, 0, SPEED) + if direction: + if not isJumping: + playerGraphic.play("run") + if direction ==0: + if not isJumping: + playerGraphic.play("idle") if direction <0: faceLeft = true + playerGraphic.flip_h = true if direction >0: faceLeft = false + playerGraphic.flip_h = false move_and_slide() diff --git a/febfabgame/Scripts/bullet.gd b/febfabgame/Scripts/bullet.gd index f1962ee..909ae2c 100644 --- a/febfabgame/Scripts/bullet.gd +++ b/febfabgame/Scripts/bullet.gd @@ -1,4 +1,5 @@ class_name Bullet extends Area2D +@onready var bulletGraphic: Sprite2D = $Sprite2D var speed = 750 @@ -6,6 +7,10 @@ signal hit(bullet, body) func setSpeed(value): speed = value + if speed <0: + bulletGraphic.flip_h = true + if speed >0: + bulletGraphic.flip_h = false #animation func _physics_process(delta: float) -> void: @@ -14,4 +19,5 @@ func _physics_process(delta: float) -> void: func _on_body_shape_entered(body_rid: RID, body: Node2D, body_shape_index: int, local_shape_index: int) -> void: print("bullet collision") - hit.emit(self, body) + if not body is Player: + hit.emit(self, body) diff --git a/febfabgame/Scripts/crate.gd b/febfabgame/Scripts/crate.gd new file mode 100644 index 0000000..7f42195 --- /dev/null +++ b/febfabgame/Scripts/crate.gd @@ -0,0 +1 @@ +class_name Crate extends RigidBody2D diff --git a/febfabgame/Scripts/gamecontroller.gd b/febfabgame/Scripts/gamecontroller.gd index 3676b48..cd28dd8 100644 --- a/febfabgame/Scripts/gamecontroller.gd +++ b/febfabgame/Scripts/gamecontroller.gd @@ -1,4 +1,4 @@ -extends Node2D +class_name GameController extends Node2D # Game Data var totalCrates = 4 @@ -9,17 +9,35 @@ var cratesDestroyed = 0 func _ready() -> void: pass # Replace with function body. - # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: pass -func _on_trigger_area_trigger(body) -> void: - print("game controller knows about crate destruction") - cratesDestroyed +=1 - totalCrates -=1 - #kill em - body.queue_free() - if totalCrates <=0: - print("win") +func _on_trigger_area_trigger(effect, body) -> void: + print("Do effect "+effect) + match effect: + "destroy": + #write code to destroy + if body is Crate: + %SceneManager.destroy(body) + cratesDestroyed +=1 + "powerup": + #write code to powerup + if body is Player: + print("POWERRRRRR UP") + #Player.SPEED = 700 + + + +func bulletHit(body): + print("game controller knows bullet hit") + if body is Crate: + print("you've hit a crate") + cratesDestroyed +=1 + %SceneManager.destroy(body) + print("crates Remaining :: "+str(totalCrates - cratesDestroyed)) + +func numberOfCrates(value): + totalCrates = value + print("Game Controller know scrates "+str(totalCrates)) diff --git a/febfabgame/Scripts/scene_manager.gd b/febfabgame/Scripts/scene_manager.gd index 60931ca..c0dda85 100644 --- a/febfabgame/Scripts/scene_manager.gd +++ b/febfabgame/Scripts/scene_manager.gd @@ -1,4 +1,7 @@ extends Node +@onready var gameController: GameController = $".." +@onready var crates: Node2D = $"../Crates" +@onready var triggers: Node2D = $"../triggers" var bulletsFiredTotal = 0 var bulletsMadeTotal = 0 @@ -19,6 +22,7 @@ func bulletFactory(): bulletArray.push_front(mybullet) return mybullet + # order desk for bullets func makeBullet(position, speed): print("make a bullet") @@ -26,11 +30,30 @@ func makeBullet(position, speed): owner.add_child(newBullet) newBullet.setSpeed(speed) newBullet.transform = position + func bulletHit(bullet, body): print("tell the game controller a bullet hit smthn") + gameController.bulletHit(body) + bullet.setSpeed(0) + bullet.position = Vector2(-100,-100) +func destroy(body): + body.queue_free() +func buildLevel(): + #how many crates? + var totalCrates = 0 + for obj in crates.get_children(): + if obj is Crate: + totalCrates +=1 + gameController.numberOfCrates(totalCrates) + #wire up the triggers + for obj in triggers.get_children(): + if obj is Trigger: + #wire up to GC + obj.areaTrigger.connect(gameController._on_trigger_area_trigger) - +func _ready() -> void: + buildLevel() diff --git a/febfabgame/Scripts/trigger.gd b/febfabgame/Scripts/trigger.gd index e357803..097692b 100644 --- a/febfabgame/Scripts/trigger.gd +++ b/febfabgame/Scripts/trigger.gd @@ -1,11 +1,13 @@ -extends Area2D +class_name Trigger extends Area2D +@export var effect="alert" -signal areaTrigger(Object) +signal areaTrigger(effect, Object) # Called when the node enters the scene tree for the first time. func _ready() -> void: print("Trigger is Active") + # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: pass @@ -13,4 +15,4 @@ func _process(delta: float) -> void: func _on_body_entered(body: Node2D) -> void: print("body collision in trigger") - areaTrigger.emit(body) + areaTrigger.emit(effect, body) diff --git a/febfabgame/project.godot b/febfabgame/project.godot index 832079a..6c6d3f2 100644 --- a/febfabgame/project.godot +++ b/febfabgame/project.godot @@ -15,6 +15,14 @@ run/main_scene="res://Scenes/feb_fab_game.tscn" config/features=PackedStringArray("4.3", "Forward Plus") config/icon="res://icon.svg" +[display] + +window/size/viewport_width=428 +window/size/viewport_height=240 +window/size/window_width_override=960 +window/size/window_height_override=540 +window/stretch/mode="viewport" + [file_customization] folder_colors={