Added simple periodic boundary
This commit is contained in:
parent
6662dc0c80
commit
3262a8899c
|
|
@ -20,4 +20,15 @@ func _process(delta):
|
||||||
|
|
||||||
move_and_collide(speed * velocity * delta)
|
move_and_collide(speed * velocity * delta)
|
||||||
#position += speed * velocity * delta
|
#position += speed * velocity * delta
|
||||||
position = position.clamp(Vector2.ZERO, screen_size)
|
position = get_boundaried_position(position)
|
||||||
|
|
||||||
|
# periodic boundary
|
||||||
|
|
||||||
|
func get_boundaried_position(position):
|
||||||
|
## clamp
|
||||||
|
#return position.clamp(Vector2.ZERO, screen_size)
|
||||||
|
|
||||||
|
## periodic
|
||||||
|
position.x = wrapf(position.x, 0, screen_size.x)
|
||||||
|
position.y = wrapf(position.y, 0, screen_size.y)
|
||||||
|
return position
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue