From 04f421901ca07ae20224e4c1db875874246371dd Mon Sep 17 00:00:00 2001 From: OddlyTimbot Date: Tue, 27 Oct 2026 21:03:58 -0400 Subject: [PATCH] parallax background, pickups, slime enemies --- assets/graphics/enemies/slime_green.png | Bin 0 -> 908 bytes .../graphics/enemies/slime_green.png.import | 40 +++++ assets/graphics/environment/farbackground.png | Bin 0 -> 1018 bytes .../environment/farbackground.png.import | 40 +++++ assets/graphics/environment/foreground.png | Bin 0 -> 2175 bytes .../environment/foreground.png.import | 40 +++++ assets/graphics/environment/midground.png | Bin 0 -> 2268 bytes .../graphics/environment/midground.png.import | 40 +++++ assets/graphics/environment/sky.png | Bin 0 -> 852 bytes assets/graphics/environment/sky.png.import | 40 +++++ assets/graphics/pickups/coin.png | Bin 0 -> 500 bytes assets/graphics/pickups/coin.png.import | 40 +++++ scenes/coin.tscn | 113 ++++++++++++++ scenes/game.tscn | 75 +++++++++- scenes/slime.tscn | 140 ++++++++++++++++++ scripts/coin.gd | 16 ++ scripts/coin.gd.uid | 1 + scripts/gamecontroller.gd | 20 +++ scripts/scene_manager.gd | 31 +++- scripts/slime.gd | 80 ++++++++++ scripts/slime.gd.uid | 1 + 21 files changed, 710 insertions(+), 7 deletions(-) create mode 100644 assets/graphics/enemies/slime_green.png create mode 100644 assets/graphics/enemies/slime_green.png.import create mode 100644 assets/graphics/environment/farbackground.png create mode 100644 assets/graphics/environment/farbackground.png.import create mode 100644 assets/graphics/environment/foreground.png create mode 100644 assets/graphics/environment/foreground.png.import create mode 100644 assets/graphics/environment/midground.png create mode 100644 assets/graphics/environment/midground.png.import create mode 100644 assets/graphics/environment/sky.png create mode 100644 assets/graphics/environment/sky.png.import create mode 100644 assets/graphics/pickups/coin.png create mode 100644 assets/graphics/pickups/coin.png.import create mode 100644 scenes/coin.tscn create mode 100644 scenes/slime.tscn create mode 100644 scripts/coin.gd create mode 100644 scripts/coin.gd.uid create mode 100644 scripts/slime.gd create mode 100644 scripts/slime.gd.uid diff --git a/assets/graphics/enemies/slime_green.png b/assets/graphics/enemies/slime_green.png new file mode 100644 index 0000000000000000000000000000000000000000..a21cb6fa253a2142be9bdad248238299dce6e695 GIT binary patch literal 908 zcmeAS@N?(olHy`uVBq!ia0vp^2|(<@!3HEb(?2AGr~;43Vg?3oVGw3ym^DX&fq~i1 z)5S5QV$Rz+)_J!b1lrmiqe6M+oJ(NX&NN4Phv|b`z4{NYP5+>JWrs--17qeTsRD5g z!(g=zZP^CRNrf+-+NH@KR$Td0s&mngVw3+xu0?EXcCBM}?K8i`C}Wk?V1NhZ=gNnL znwH6IezGFZ!~9a6?RHUyhPV4>Uu{?_FnfW>zS{qPKK*<4uVTZ$ce_63>1Q2~5psEW zx_|#J@#X97|9=sRdr@7gG^K>%S{q!=tk;zc{umA757CW^gF~?Y* zzL@Q4_FeSScBuyG05^_0b=8H-_E|RV`0{(oCG+JLF?=tr`x)+BFt>laYl`#E_4#US z^)8yV;ydQc)Lt=IzWv`O|NWa{=kBflzObA3)w^Aa^ZVqko^^cn|Ic5O3*}M*OaJxH zkT2-?mBRcbPJn+~%B^6jY(87p9(Mo#>Q7(h~rm&XFcnS2%Pu(#j4I<=R1EbeZ((y;O5o?wIy5Q|G$2J-k$H; z`tsE}e}z7FZ&xe&&T>;Ie$t&EuHB#RoL~6BudegQ(e6(xj^8Zaa&Il$W#4ySE~~5m zTfmt7%O>)U?6I5hEH)mc^Zy7i2AYE5_cS8+Pd zEL*XBwVBru|99M6hFkZ|y>aAN9DmO}@fM%8>yNRi-8VbG`yY1_&*gmzOfw=rUyaF+ zc6a>UWOJqT@=>+Yz0nhwE57CCn(*tmRI)?YzOxPXujg|0Ui|Qj8JN8oJYD@<);T3K F0RY5^vzq__ literal 0 HcmV?d00001 diff --git a/assets/graphics/enemies/slime_green.png.import b/assets/graphics/enemies/slime_green.png.import new file mode 100644 index 0000000..74f5067 --- /dev/null +++ b/assets/graphics/enemies/slime_green.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dm5aslppmk2hw" +path="res://.godot/imported/slime_green.png-5261ffd1254c816fe62b35227a9aa11d.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/graphics/enemies/slime_green.png" +dest_files=["res://.godot/imported/slime_green.png-5261ffd1254c816fe62b35227a9aa11d.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/assets/graphics/environment/farbackground.png b/assets/graphics/environment/farbackground.png new file mode 100644 index 0000000000000000000000000000000000000000..76a7b998ce10206d3942c898e84e7c98272cfc49 GIT binary patch literal 1018 zcmeAS@N?(olHy`uVBq!ia0y~yV4MJCKjdHolFzn1mH|?X#X;^)j5kl})B`yz>5jgR z3=A9lx&I`x0{IHb9znhg3{`3j3=J&|48MRv4KElNN(~qoUL`OvSj}Ky5HFasE6@fg z!ItFh?!xdN1Q+aGJ{c&&S>O>_%)p?h48n{ROYO^mg6t)pzOL-AxTM7lWx0djU1DHh zw)1px45_&F_RhhzuM7knE>5U>!O$6|(Hl15MMG1=m2ycS?FuSD?TsA`4IJ!FKz;@XHwQ;kzQpUvAuKu~DkPu;Xb z0iCQ&LjU+Sv90+kyWv|Li;IbZioxaW6I2!4YyU6(uB@QM*gf6rr1T3-CEIrmlYR>d zJZv~CcJ7X}WtB_SeMay1?hY=@v;KQtm&^EE2h{E0@}_ywZ%=uFjSPYtrBA(E`MW`a zNkGtA`PsT%JROWcLHkGVPp`kq=#bM0v^5NfQg{Wnq!$keeGv^UN)aSkj0*%3BcaK%Qp6x29HC1V zl@em$00}~5r5lKmwgHjD2%&^T36PU|@jtjf;AWmF?>qC%hxss*_(LyAu!nz269XxPvyU?XQ1cb`BBaGwC(_;D2LO@` z0U$jS0CvPw`Z54uOaNdt8~|)e0YE*jf_B+XT#&ip1$6-qziUnRvm!Ag7v~*T$6s4KF{ayz%J9m=G(CnLbty`(O`QGX?%U#BG3KyFH=~-`$8daUEl|f_pa= zmxri=>H8vOQ(I!Q)jZKt)FcY)?8Cc>N{_uFMb>VG7N`=+ zxO!g9I{K*0zZpz8=%~FH5)s-6-5y0~zGHRYN1i)*_b3tuyj2`yF<+!m_UX`)mjPF? z-Mu)szhYDkA%_0ZSrP4x!Kx_I8JOGezOjhZfs?bW?gzzk{PS!V5HQW|9Fkg`7k!O<8h_Fg z8|VWHW`LuboA_{P&-K<&wl(F0PcYo~=Z7oaHNP28LT!p0d&(9I>QQ*mws%}kz#Z02 zGOI3YzYJmcWnxMvP-;N6XlvO5Zk%l1OU6lBnGxWVnEHmFjPoaG3;v&seRdj)hVt-W z66cBKM>w}0#zH*k;c3RGzOkPhBno@XkJkz}sMV+JV`pZypa<;}IZ?CJ8K&Ov5MgRT zl;(&5TYAx}JB_KBin{C9S##%ELROLk!p$j9&8Q&Wmi8HM z-jihcks<$zy!f;Vm*VPw`utWz-hTcvVyXlVV(R9y1AbhxZ5_% z47R8dHlTJp1tCy%T$RKdk-Y1QJy0Of%oMi?Gu|eT(SPlBXj$eRn8zmld15_PG~6lb zefi#Eq%TuL!V%4kb{N~E3yZ!Apu zGQ65%FdQ&wE)3c(KUymho(PJ)r74o)ux+LDOU}X9R@<0!S% z%EZ^?zWpYT&$)+L%#ln-GXx)fOpp2ZoY}o=cO?aJUt^B^I>jyjHu0@^eK)Ud6EXVSe1kSh(*?5?n2TbF;VOLSMqT6b!om7p7CFTsjt%j literal 0 HcmV?d00001 diff --git a/assets/graphics/environment/foreground.png.import b/assets/graphics/environment/foreground.png.import new file mode 100644 index 0000000..3dd3dcc --- /dev/null +++ b/assets/graphics/environment/foreground.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dsywyyr0yb4cg" +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/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/assets/graphics/environment/midground.png b/assets/graphics/environment/midground.png new file mode 100644 index 0000000000000000000000000000000000000000..2b697a347a7d27f1d1b268e15220498f4e60f4f8 GIT binary patch literal 2268 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 Bj=cZ? literal 0 HcmV?d00001 diff --git a/assets/graphics/environment/sky.png.import b/assets/graphics/environment/sky.png.import new file mode 100644 index 0000000..bdc8c25 --- /dev/null +++ b/assets/graphics/environment/sky.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cjkp5fjucdfoi" +path="res://.godot/imported/sky.png-87ee3f869f476b86b8c4a0a2c430b158.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/graphics/environment/sky.png" +dest_files=["res://.godot/imported/sky.png-87ee3f869f476b86b8c4a0a2c430b158.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/assets/graphics/pickups/coin.png b/assets/graphics/pickups/coin.png new file mode 100644 index 0000000000000000000000000000000000000000..01ae33d70b398db7f1f7bcafe883a0a469805201 GIT binary patch literal 500 zcmV^r!6hi!Wct>kSmw76A*+mkqIDVjdDL!Rb}5E?Td;C@2y9S zHih2xK(yTWh+gXdrTqK8Uwx^_$MoI4V|67Hn26^Qp-rJ*c_3P5d_*tx|6%^yEznE& zeE6^KHvJ|vI7934d=L#ytZIR)9hxaN1Jm8sZ6_j{Yx1#nTWt!D2<;1?{VNX?M*l~R zzukKP+i+D+FAlB;7qkOXfaGA?&h>EX&+$Oxqgs>{d4C#zhd05hUS`kO@{&+Bb`?-H zKXwYn7Ms9B!`F}PQh%-o65r;4=uy!A4;g>*6iCRL!wF!o{9{X0YM%Mf@U=DvM2}Kx zY#A;!e+4Y{Qh#m^NPMe5dkcj0f5`ZIy8@JYG2kpkh}LrU76{dHI?&Z}2LKX(>v1MX z4k6>OaQ_N1p97frj@jdSpELonJ&y=&3jN9h(K6#Bda3^x^WUBW>`ee7IfzLSUk<|l qVg27u071wNc?u+CjZ6R`YyJS*Ofbr5QwY-l0000 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_body_entered(body: Node2D) -> void: + coinCollisionSignal.emit(body, self) diff --git a/scripts/coin.gd.uid b/scripts/coin.gd.uid new file mode 100644 index 0000000..a5a2004 --- /dev/null +++ b/scripts/coin.gd.uid @@ -0,0 +1 @@ +uid://dhc6762deonm2 diff --git a/scripts/gamecontroller.gd b/scripts/gamecontroller.gd index c375331..4b455dc 100644 --- a/scripts/gamecontroller.gd +++ b/scripts/gamecontroller.gd @@ -3,6 +3,11 @@ class_name GameController extends Node2D signal teleportSignal(body:RigidBody2D) signal destroySignal(body) +var numberOfCrates = 2 +var totalCoins = 0 +var coinsRemaining = 0 +var coinsCollected = 0 + # Called when the node enters the scene tree for the first time. func _ready() -> void: get_window().grab_focus() @@ -30,3 +35,18 @@ func _on_bullet_hit(body, bullet) -> void: destroySignal.emit(body) destroySignal.emit(bullet) + +func crateTotal(amount)->void: + numberOfCrates = amount + if numberOfCrates<=0: + print("YOU WON!!!") +func coinTotal(amount)->void: + if totalCoins == 0: + totalCoins = amount + coinsRemaining = amount + print("Collected "+str(totalCoins-coinsRemaining)+" of "+str(totalCoins) ) +func coinCollected(body, coin)->void: + if body is Player: + #give them a coin + coinsCollected +=1 + destroySignal.emit(coin) diff --git a/scripts/scene_manager.gd b/scripts/scene_manager.gd index 9a3cc53..993ef1b 100644 --- a/scripts/scene_manager.gd +++ b/scripts/scene_manager.gd @@ -3,6 +3,8 @@ class_name SceneManager extends Node2D @onready var triggers: Node2D = $"../Triggers" @onready var game: GameController = $".." @onready var player: Player = $"../Player" +@onready var crates: Node2D = $"../Crates" +@onready var coins: Node2D = $"../Coins" #recipe for bullets var bullet = preload("res://scenes/bullet.tscn") @@ -16,13 +18,38 @@ func _ready() -> void: game.teleportSignal.connect(teleport) game.destroySignal.connect(destroy) player.bulletSignal.connect(makeBullet) - + updateCrates() + updateCoins() # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: pass +func updateCrates()->void: + var totalCrates = 0 + # loop through all crates + for obj in crates.get_children(): + if obj is Crate: + #check if the tree exit signal is wired up + if not obj.tree_exited.is_connected(updateCrates): + obj.tree_exited.connect(updateCrates) + totalCrates +=1 + # tell the gamecontroller how many crates + game.crateTotal(totalCrates) + +func updateCoins()->void: + var totalCoins = 0 + #loop through the coins + for obj in coins.get_children(): + if obj is Coin: + if not obj.tree_exited.is_connected(updateCoins): + obj.tree_exited.connect(updateCoins) + if not obj.coinCollisionSignal.is_connected(game.coinCollected): + obj.coinCollisionSignal.connect(game.coinCollected) + totalCoins +=1 + game.coinTotal(totalCoins) + func buildLevel()->void: if triggers: for obj in triggers.get_children(): @@ -68,6 +95,8 @@ func destroy(target)->void: stash(target) if target is Crate: target.queue_free() + if target is Coin: + target.queue_free() func stash(target:Bullet)->void: print("stash a bullet") diff --git a/scripts/slime.gd b/scripts/slime.gd new file mode 100644 index 0000000..6a20492 --- /dev/null +++ b/scripts/slime.gd @@ -0,0 +1,80 @@ +class_name Slime extends Area2D + +@onready var right_cast: RayCast2D = $RightCast +@onready var left_cast: RayCast2D = $LeftCast +@onready var right_down_cast: RayCast2D = $RightDownCast +@onready var left_down_cast: RayCast2D = $LeftDownCast +@onready var slime_graphic: AnimatedSprite2D = $SlimeGraphic + +var speed = 100 +enum FaceDirection {RIGHT, LEFT} +var facing:FaceDirection = FaceDirection.RIGHT +#direction 1 move to right, 0 no movement, -1 to the left +var direction = 1 + +enum EnemyStates {RUN, ATTACK, SPAWN} +var currentEnemyState:EnemyStates = EnemyStates.SPAWN + + +# Called when the node enters the scene tree for the first time. +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: + handleMovement(delta) + handleStates() + handleAnimation() + handleCollisions() + +func handleMovement(delta)->void: + position.x += direction*speed*delta + match facing: + FaceDirection.LEFT: + slime_graphic.flip_h = true + FaceDirection.RIGHT: + slime_graphic.flip_h = false + +func handleStates()->void: + match currentEnemyState: + EnemyStates.SPAWN when not direction ==0: + currentEnemyState = EnemyStates.RUN + +func handleAnimation()->void: + match currentEnemyState: + EnemyStates.SPAWN: + slime_graphic.play("spawn") + EnemyStates.RUN: + slime_graphic.play("run") + EnemyStates.ATTACK: + slime_graphic.play("attack") + +func handleCollisions()->void: + if not right_down_cast.is_colliding(): + direction = -1 + facing = FaceDirection.LEFT + if not left_down_cast.is_colliding(): + direction = 1 + facing= FaceDirection.RIGHT + if right_cast.is_colliding() and not right_cast.get_collider() is Player: + direction = -1 + facing = FaceDirection.LEFT + if left_cast.is_colliding() and not left_cast.get_collider() is Player: + direction = 1 + facing= FaceDirection.RIGHT + + + pass +func _on_body_entered(body: Node2D) -> void: + print("Slime Attack!") + + +func _on_animation_finished() -> void: + match currentEnemyState: + EnemyStates.SPAWN: + currentEnemyState = EnemyStates.RUN + direction = 1 + EnemyStates.ATTACK: + currentEnemyState = EnemyStates.RUN + direction = (randi() % 2) *2 -1 diff --git a/scripts/slime.gd.uid b/scripts/slime.gd.uid new file mode 100644 index 0000000..ff2d6ff --- /dev/null +++ b/scripts/slime.gd.uid @@ -0,0 +1 @@ +uid://bltdu3mbpch5n