summaryrefslogtreecommitdiff
path: root/demos/2d/space_shooter/enemy2.gd
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2015-11-21 16:13:43 +0100
committerRémi Verschelde <rverschelde@gmail.com>2015-12-09 08:39:12 +0100
commit7589b2bf605b58fbb0e34dec8ae833708e9b54ea (patch)
tree6c6b6515be9d121127f738a586fd95299ca7018a /demos/2d/space_shooter/enemy2.gd
parent323dde7f3164477b3d51fda8352d8b37a19f7f9d (diff)
Improve code formatting
The scripts were streamlined using more or less the following conventions: - space after a comma in lists of arguments - spaces around weak operators (+, -), no spaces around strong operators (*, /) - spaces around comparison operators and compound assignment operators - space after a comment start (#) - removed trailing spaces or tabs, apart from those that delimit the function indentation level (those could be removed too but since they are added automatically by the editor when typing code, keeping them for now) - function blocks separate by two newlines - comment sentences start with an upper-case letter
Diffstat (limited to 'demos/2d/space_shooter/enemy2.gd')
-rw-r--r--demos/2d/space_shooter/enemy2.gd52
1 files changed, 24 insertions, 28 deletions
diff --git a/demos/2d/space_shooter/enemy2.gd b/demos/2d/space_shooter/enemy2.gd
index 4f632a053d..ca35f45faa 100644
--- a/demos/2d/space_shooter/enemy2.gd
+++ b/demos/2d/space_shooter/enemy2.gd
@@ -1,56 +1,52 @@
extends Area2D
-# member variables here, example:
-# var a=2
-# var b="textvar"
-const SPEED=-220
-const SHOOT_INTERVAL=1
-var shoot_timeout=0
+# Member variables
+const SPEED = -220
+const SHOOT_INTERVAL = 1
+
+var shoot_timeout = 0
+var destroyed=false
+
func _process(delta):
- translate( Vector2(SPEED*delta,0) )
- shoot_timeout-=delta
-
- if (shoot_timeout<0):
+ translate(Vector2(SPEED*delta, 0))
+ shoot_timeout -= delta
- shoot_timeout=SHOOT_INTERVAL
+ if (shoot_timeout < 0):
+ shoot_timeout = SHOOT_INTERVAL
- #instance a shot
+ # Instance a shot
var shot = preload("res://enemy_shot.scn").instance()
- #set pos as "shoot_from" Position2D node
- shot.set_pos( get_node("shoot_from").get_global_pos() )
- #add it to parent, so it has world coordinates
+ # Set pos as "shoot_from" Position2D node
+ shot.set_pos(get_node("shoot_from").get_global_pos())
+ # Add it to parent, so it has world coordinates
get_parent().add_child(shot)
-
-var destroyed=false
+
func is_enemy():
return not destroyed
+
func destroy():
if (destroyed):
- return
- destroyed=true
+ return
+ destroyed = true
get_node("anim").play("explode")
- set_process(false)
+ set_process(false)
get_node("sfx").play("sound_explode")
- #accum points
- get_node("/root/game_state").points+=10
+ # Accumulate points
+ get_node("/root/game_state").points += 10
+
func _ready():
- set_fixed_process(true)
# Initialization here
- pass
-
-
+ set_fixed_process(true)
func _on_visibility_enter_screen():
set_process(true)
- pass # replace with function body
func _on_visibility_exit_screen():
queue_free()
- pass # replace with function body