diff options
author | James McLean <james@mcleanlabs.ca> | 2015-06-11 10:46:59 -0400 |
---|---|---|
committer | James McLean <james@mcleanlabs.ca> | 2015-06-11 10:46:59 -0400 |
commit | 237d6afa1602c414390e8f008580d288c3c7e694 (patch) | |
tree | 678b0ab27b66425ad2a292cea094661353c96f97 /demos/2d/space_shooter/enemy1.gd | |
parent | b19ed63eb6b3aa0fd9cdf54847deff96fd4830df (diff) | |
parent | c845c2a8276c61323416139790962a096a8d956e (diff) |
Merge branch 'master' of github.com:okamstudio/godot
Diffstat (limited to 'demos/2d/space_shooter/enemy1.gd')
-rw-r--r-- | demos/2d/space_shooter/enemy1.gd | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/demos/2d/space_shooter/enemy1.gd b/demos/2d/space_shooter/enemy1.gd new file mode 100644 index 0000000000..051798742a --- /dev/null +++ b/demos/2d/space_shooter/enemy1.gd @@ -0,0 +1,37 @@ + +extends Area2D + +# member variables here, example: +# var a=2 +# var b="textvar" + +const SPEED=-200 + +func _process(delta): + get_parent().translate(Vector2(SPEED*delta,0)) + + +var destroyed=false + +func is_enemy(): + return not destroyed + + +func destroy(): + if (destroyed): + return + destroyed=true + get_node("anim").play("explode") + set_process(false) + get_node("sfx").play("sound_explode") + #accum points + get_node("/root/game_state").points+=5 + +func _on_visibility_enter_screen(): + set_process(true) + get_node("anim").play("zigzag") + get_node("anim").seek(randf()*2.0) #make it start from any pos + +func _on_visibility_exit_screen(): + queue_free() + |