From 29b125f5af3acec67f532b5a1a96dfd74a8bc082 Mon Sep 17 00:00:00 2001 From: OddlyTimbot Date: Mon, 6 Jul 2026 13:56:57 -0400 Subject: [PATCH] bullet stashing --- scripts/game.gd | 2 ++ scripts/scene_manager.gd | 23 ++++++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/scripts/game.gd b/scripts/game.gd index 539a0f0..0d2813c 100644 --- a/scripts/game.gd +++ b/scripts/game.gd @@ -49,6 +49,8 @@ func crateTotal(howmany): func bulletDamage(body, _bullet)->void: if body.is_in_group("shootable"): destroySignal.emit(body) + destroySignal.emit(_bullet) + func rocketDamage(body, rocket)->void: if body.is_in_group("shootable"): print("Rocket strikes target!") diff --git a/scripts/scene_manager.gd b/scripts/scene_manager.gd index cd111c1..881ed5c 100644 --- a/scripts/scene_manager.gd +++ b/scripts/scene_manager.gd @@ -47,10 +47,26 @@ func updateCrates()->void: func pushTarget(body,pushDirection)->void: if body is RigidBody2D: body.apply_central_impulse(pushDirection) + +#Stashes bullets off-screen instead of destroying them +func stash(bullet:Bullet)->void: + var stashPosition:Vector2 = Vector2(-100,-100) + bullet.position = stashPosition + bullet.setSpeed(0) + bullet.set_process(false) + func destroy(body)->void: - if body is Rocket: - print("removing rocket") - body.queue_free() + match body: + var bod when bod is Rocket: + print("removing rocket") + var bod when bod is Crate: + body.queue_free() + var bod when bod is Bullet: + print("stash a bullet") + stash(body) + _: + body.queue_free() + func teleportTarget(body)->void: if body is Crate: var viewport_size = get_viewport().get_visible_rect().size @@ -77,6 +93,7 @@ func makeBullet(spawnPosition, speed)->void: var myBullet:Bullet = bulletFactory() myBullet.transform = spawnPosition myBullet.setSpeed(speed) + myBullet.set_process(true) func rocketFactory()->Rocket: var myRocket:Rocket