then there were numbered rockets
This commit is contained in:
parent
404f518ddd
commit
17a077d186
@ -1,4 +1,5 @@
|
||||
class_name Rocket extends RigidBody2D
|
||||
signal splodeSignal(rocket)
|
||||
|
||||
func _ready() -> void:
|
||||
#Rockets expolode in time
|
||||
@ -12,6 +13,6 @@ func _ready() -> void:
|
||||
func _on_body_entered(body: Node) -> void:
|
||||
print("Rocket hit a target")
|
||||
|
||||
#should i splode myself?
|
||||
#should i splode myself? No. Scene manager job.
|
||||
func splode()->void:
|
||||
self.queue_free()
|
||||
splodeSignal.emit(self)
|
||||
|
||||
@ -8,6 +8,8 @@ var rocket = preload("res://scenes/rocket.tscn")
|
||||
|
||||
var bulletArray:Array[Bullet] = []
|
||||
var totalAllowedBullets:int = 7
|
||||
var rocketArray:Array[Rocket] = []
|
||||
var totalAllowedRockets:int = 3
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
@ -46,6 +48,8 @@ func pushTarget(body,pushDirection)->void:
|
||||
if body is RigidBody2D:
|
||||
body.apply_central_impulse(pushDirection)
|
||||
func destroy(body)->void:
|
||||
if body is Rocket:
|
||||
print("removing rocket")
|
||||
body.queue_free()
|
||||
func teleportTarget(body)->void:
|
||||
if body is Crate:
|
||||
@ -73,10 +77,16 @@ func makeBullet(spawnPosition, speed)->void:
|
||||
var myBullet:Bullet = bulletFactory()
|
||||
myBullet.transform = spawnPosition
|
||||
myBullet.setSpeed(speed)
|
||||
|
||||
func rocketFactory()->Rocket:
|
||||
var myRocket:Rocket
|
||||
myRocket = rocket.instantiate()
|
||||
add_sibling(myRocket)
|
||||
return myRocket
|
||||
|
||||
func makeRocket(spawnPosition, direction, speed)->void:
|
||||
print("make a rocket")
|
||||
var myRocket = rocket.instantiate()
|
||||
add_sibling(myRocket)
|
||||
var myRocket:Rocket = rocketFactory()
|
||||
myRocket.splodeSignal.connect(destroy)
|
||||
myRocket.transform = spawnPosition
|
||||
pushTarget(myRocket,direction*speed)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user