Game #3: Space Shooter
This commit is contained in:
parent
a00e9b59c9
commit
f785a24c14
45 changed files with 927 additions and 0 deletions
30
space-shooter/Scenes/Objects/Enemy.gd
Normal file
30
space-shooter/Scenes/Objects/Enemy.gd
Normal file
|
@ -0,0 +1,30 @@
|
|||
extends Area2D
|
||||
|
||||
const Explosion = preload("res://Scenes/ExplosionEffect.tscn")
|
||||
|
||||
export (int) var speed = 50
|
||||
export (int) var armor = 3
|
||||
|
||||
func _process(delta):
|
||||
position.x -= speed * delta
|
||||
|
||||
func _on_Enemy_body_entered(body):
|
||||
body.create_hit_effect()
|
||||
body.queue_free()
|
||||
armor -= 1
|
||||
|
||||
if armor <= 0:
|
||||
var root = get_tree().current_scene
|
||||
if root.is_in_group("World"):
|
||||
root.score += 10
|
||||
explode()
|
||||
queue_free()
|
||||
|
||||
func _on_VisibilityNotifier2D_screen_exited():
|
||||
queue_free()
|
||||
|
||||
|
||||
func explode():
|
||||
var explosion = Explosion.instance()
|
||||
explosion.global_position = global_position
|
||||
get_tree().current_scene.add_child(explosion)
|
Loading…
Add table
Add a link
Reference in a new issue