wrapsteroids

This commit is contained in:
Robin Hübner 2017-07-30 00:14:42 +02:00
parent 9834ca9ace
commit 569fef0adc
1 changed files with 14 additions and 4 deletions

View File

@ -16,11 +16,21 @@ func _ready():
rot_vel = deg2rad(floor(rand_range(1, max_rot_vel))) rot_vel = deg2rad(floor(rand_range(1, max_rot_vel)))
set_fixed_process(true) set_fixed_process(true)
func wrap(v, v_min, v_max):
if v < v_min:
return v_max - 1
elif v > v_max:
return v_min - 1
else:
return v
func _fixed_process(delta): func _fixed_process(delta):
#var cur_pos = get_pos()
#cur_pos.x = cur_pos.x % get_viewport().get_rect().size.x var cur_pos = get_pos()
#cur_pos.y = cur_pos.y % get_viewport().get_rect().size.y cur_pos.x = wrap(cur_pos.x, 1, get_viewport().get_rect().size.x)
#set_pos(cur_pos) cur_pos.y = wrap(cur_pos.y, 1, get_viewport().get_rect().size.y)
set_pos(cur_pos)
self.move(velocity) self.move(velocity)
self.rotate(rot_vel) self.rotate(rot_vel)