eel fixes
This commit is contained in:
parent
1096679637
commit
016a304303
2 changed files with 6 additions and 3 deletions
|
@ -30,15 +30,17 @@ func _ready() -> void:
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
# move
|
# move
|
||||||
global_position.x -= speed * delta * sign(scale.x)
|
global_position.x += speed * delta * sign(scale.x)
|
||||||
# make segments wibble
|
# make segments wibble
|
||||||
_wave_segments()
|
_wave_segments()
|
||||||
# check for wrapping
|
# 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 total_length = BASE_LENGTH + (SEGMENT_LENGTH * float(segments))
|
||||||
var eel_rect = Rect2(global_position + Vector2(-2.0, 4.0), Vector2(total_length, 0.0))
|
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):
|
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:
|
func _wave_segments() -> void:
|
||||||
for segment in hitbox.get_children():
|
for segment in hitbox.get_children():
|
||||||
|
|
|
@ -19,6 +19,7 @@ wave_amplitude = 6.0
|
||||||
|
|
||||||
[node name="Hitbox" type="Area2D" parent="." groups=["enemy_hitbox"]]
|
[node name="Hitbox" type="Area2D" parent="." groups=["enemy_hitbox"]]
|
||||||
position = Vector2( 0, 4 )
|
position = Vector2( 0, 4 )
|
||||||
|
scale = Vector2( -1, 1 )
|
||||||
|
|
||||||
[node name="SegmentStart" type="Position2D" parent="Hitbox"]
|
[node name="SegmentStart" type="Position2D" parent="Hitbox"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue