eel fixes

This commit is contained in:
Haze Weathers 2023-05-29 01:28:25 -04:00
parent 1096679637
commit 016a304303
2 changed files with 6 additions and 3 deletions

View file

@ -30,15 +30,17 @@ func _ready() -> void:
func _physics_process(delta: float) -> void:
# move
global_position.x -= speed * delta * sign(scale.x)
global_position.x += speed * delta * sign(scale.x)
# make segments wibble
_wave_segments()
# check for wrapping
var sector_rect = Rect2(sector * Game.resolution, Game.resolution)
var sector_rect = Rect2(sector * Game.resolution - Vector2(8.0, 0.0), Game.resolution + Vector2(16.0, 0.0))
var total_length = BASE_LENGTH + (SEGMENT_LENGTH * float(segments))
var eel_rect = Rect2(global_position + Vector2(-2.0, 4.0), Vector2(total_length, 0.0))
if sign(scale.x) == 1.0:
eel_rect.position.x -= total_length
if not sector_rect.intersects(eel_rect):
global_position.x += (Game.resolution.x + total_length) * sign(scale.x)
global_position.x -= (sector_rect.size.x + total_length) * sign(scale.x)
func _wave_segments() -> void:
for segment in hitbox.get_children():