Added simple periodic boundary

This commit is contained in:
Martin committed 2025-12-21 15:14:51 +01:00
1 parent 6662dc0c80
commit 3262a8899c
1 file changed
+12 -1
@@ -20,4 +20,15 @@ func _process(delta):
move_and_collide(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
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.