bullet stashing
This commit is contained in:
parent
2e494502a8
commit
29b125f5af
@ -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!")
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user