Skip to content

Commit

Permalink
Switched the space shooter demo from none fixed process to fixed process
Browse files Browse the repository at this point in the history
  • Loading branch information
jmintb authored and akien-mga committed May 31, 2016
1 parent 891d3bf commit 25afca1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 18 deletions.
6 changes: 3 additions & 3 deletions 2d/space_shooter/asteroid.gd
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var speed_y = 0.0
var destroyed = false


func _process(delta):
func _fixed_process(delta):
translate(Vector2(SPEED, speed_y)*delta)


Expand All @@ -23,7 +23,7 @@ func destroy():
return
destroyed = true
get_node("anim").play("explode")
set_process(false)
set_fixed_process(false)
get_node("sfx").play("sound_explode")
# Accumulate points
get_node("/root/game_state").points += 1
Expand All @@ -34,7 +34,7 @@ func is_enemy():


func _on_visibility_enter_screen():
set_process(true)
set_fixed_process(true)
# Make it spin!
get_node("anim").play("spin")

Expand Down
6 changes: 3 additions & 3 deletions 2d/space_shooter/enemy1.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const SPEED = -200
var destroyed=false


func _process(delta):
func _fixed_process(delta):
get_parent().translate(Vector2(SPEED*delta, 0))


Expand All @@ -20,14 +20,14 @@ func destroy():
return
destroyed = true
get_node("anim").play("explode")
set_process(false)
set_fixed_process(false)
get_node("sfx").play("sound_explode")
# Accumulate points
get_node("/root/game_state").points += 5


func _on_visibility_enter_screen():
set_process(true)
set_fixed_process(true)
get_node("anim").play("zigzag")
get_node("anim").seek(randf()*2.0) # Make it start from any pos

Expand Down
10 changes: 3 additions & 7 deletions 2d/space_shooter/enemy2.gd
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var shoot_timeout = 0
var destroyed=false


func _process(delta):
func _fixed_process(delta):
translate(Vector2(SPEED*delta, 0))
shoot_timeout -= delta

Expand All @@ -33,18 +33,14 @@ func destroy():
return
destroyed = true
get_node("anim").play("explode")
set_process(false)
set_fixed_process(false)
get_node("sfx").play("sound_explode")
# Accumulate points
get_node("/root/game_state").points += 10


func _ready():
set_fixed_process(true)


func _on_visibility_enter_screen():
set_process(true)
set_fixed_process(true)


func _on_visibility_exit_screen():
Expand Down
6 changes: 3 additions & 3 deletions 2d/space_shooter/rail.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ var offset = 0


func stop():
set_process(false)
set_fixed_process(false)


func _process(delta):
func _fixed_process(delta):
offset += delta*SPEED
set_pos(Vector2(offset, 0))


func _ready():
set_process(true)
set_fixed_process(true)
4 changes: 2 additions & 2 deletions 2d/space_shooter/ship.gd
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var prev_shooting = false
var killed = false


func _process(delta):
func _fixed_process(delta):
var motion = Vector2()
if Input.is_action_pressed("move_up"):
motion += Vector2(0, -1)
Expand Down Expand Up @@ -53,7 +53,7 @@ func _process(delta):

func _ready():
screen_size = get_viewport().get_rect().size
set_process(true)
set_fixed_process(true)


func _hit_something():
Expand Down

0 comments on commit 25afca1

Please sign in to comment.