summaryrefslogtreecommitdiff
path: root/demos/2d/space_shooter/asteroid.gd
diff options
context:
space:
mode:
Diffstat (limited to 'demos/2d/space_shooter/asteroid.gd')
-rw-r--r--demos/2d/space_shooter/asteroid.gd42
1 files changed, 18 insertions, 24 deletions
diff --git a/demos/2d/space_shooter/asteroid.gd b/demos/2d/space_shooter/asteroid.gd
index f21b9777bb..9f6734e122 100644
--- a/demos/2d/space_shooter/asteroid.gd
+++ b/demos/2d/space_shooter/asteroid.gd
@@ -1,49 +1,43 @@
extends Area2D
-# member variables here, example:
-# var a=2
-# var b="textvar"
+# Member variables
+const SPEED = -200
+const Y_RANDOM = 10
-const SPEED=-200
-const Y_RANDOM=10
+var points = 1
+var speed_y = 0.0
+var destroyed = false
-var points=1
-
-
-var speed_y=0.0
func _process(delta):
+ translate(Vector2(SPEED, speed_y)*delta)
- translate( Vector2(SPEED,speed_y) * delta )
func _ready():
- # Initialization here
- speed_y=rand_range(-Y_RANDOM,Y_RANDOM)
- pass
+ speed_y = rand_range(-Y_RANDOM, Y_RANDOM)
-var destroyed=false
func destroy():
if (destroyed):
- return
- destroyed=true
+ 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+=1
-
+ # Accumulate points
+ get_node("/root/game_state").points += 1
+
+
func is_enemy():
- return not destroyed
-
+ return not destroyed
+
func _on_visibility_enter_screen():
set_process(true)
- #make it spin!
+ # Make it spin!
get_node("anim").play("spin")
-
+
func _on_visibility_exit_screen():
queue_free()
- pass # replace with function body