Periodic boundary now applies to prey too
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
extends CharacterBody2D
|
||||
|
||||
@export var speed = 200
|
||||
var screen_size
|
||||
var damage = 1
|
||||
|
||||
func _ready():
|
||||
screen_size = get_viewport_rect().size
|
||||
var screen_size = get_viewport_rect().size
|
||||
GameManager.init_screen_size(screen_size.x, screen_size.y)
|
||||
|
||||
func _process(delta):
|
||||
velocity = Vector2.ZERO
|
||||
@@ -20,15 +20,5 @@ func _process(delta):
|
||||
|
||||
move_and_collide(speed * velocity * delta)
|
||||
#position += speed * velocity * delta
|
||||
position = get_boundaried_position(position)
|
||||
position = GameManager.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