EEEEELLLLLLSSSSS uuuuuuuuuuuuuuuuuuuuuu
This commit is contained in:
parent
4c31420e52
commit
7df261b58e
11 changed files with 277 additions and 1 deletions
55
objects/enemy/eel.gd
Normal file
55
objects/enemy/eel.gd
Normal file
|
@ -0,0 +1,55 @@
|
|||
extends "res://objects/enemy/enemy.gd"
|
||||
|
||||
|
||||
const SEGMENT_LENGTH: float = 4.0
|
||||
const BASE_LENGTH: float = 20.0 # combined length of head and tail
|
||||
|
||||
|
||||
export var segments: int = 8
|
||||
export var speed: float = 32.0
|
||||
export var wave_length: float = 8.0
|
||||
export var wave_amplitude: float = 4.0
|
||||
|
||||
|
||||
onready var sector: Vector2 = Game.get_sector(global_position)
|
||||
|
||||
|
||||
onready var hitbox: Area2D = $Hitbox
|
||||
onready var first_segment: CollisionShape2D = $"%Segment"
|
||||
onready var segment_start: Position2D = $"%SegmentStart"
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
hitbox.remove_child(first_segment)
|
||||
for i in segments:
|
||||
var new_segment = first_segment.duplicate()
|
||||
new_segment.position.x = segment_start.position.x + SEGMENT_LENGTH * float(i)
|
||||
hitbox.add_child(new_segment)
|
||||
$Hitbox/TailShape.position.x = segment_start.position.x + SEGMENT_LENGTH * segments
|
||||
_wave_segments()
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
# move
|
||||
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 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 not sector_rect.intersects(eel_rect):
|
||||
global_position.x += (Game.resolution.x + total_length) * sign(scale.x)
|
||||
|
||||
func _wave_segments() -> void:
|
||||
for segment in hitbox.get_children():
|
||||
if segment is Node2D:
|
||||
segment.position.y = sin(segment.global_position.x / wave_length) * wave_amplitude
|
||||
|
||||
func die() -> void:
|
||||
for segment in hitbox.get_children():
|
||||
if segment is Node2D:
|
||||
var death_particles = DeathParticles.instance()
|
||||
death_particles.global_position = segment.global_position
|
||||
death_particles.emitting = true
|
||||
get_parent().add_child(death_particles)
|
||||
.die()
|
77
objects/enemy/eel.tscn
Normal file
77
objects/enemy/eel.tscn
Normal file
|
@ -0,0 +1,77 @@
|
|||
[gd_scene load_steps=8 format=2]
|
||||
|
||||
[ext_resource path="res://objects/enemy/eel.gd" type="Script" id=1]
|
||||
[ext_resource path="res://graphics/enemy/eel_head.png" type="Texture" id=2]
|
||||
[ext_resource path="res://graphics/enemy/eel_body.png" type="Texture" id=3]
|
||||
[ext_resource path="res://graphics/enemy/eel_tail.png" type="Texture" id=4]
|
||||
[ext_resource path="res://graphics/enemy/eel_inner_border.png" type="Texture" id=5]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=3]
|
||||
extents = Vector2( 2, 2 )
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=2]
|
||||
extents = Vector2( 2, 2 )
|
||||
|
||||
[node name="Eel" type="Node2D" groups=["enemy"]]
|
||||
script = ExtResource( 1 )
|
||||
blood = false
|
||||
wave_amplitude = 6.0
|
||||
|
||||
[node name="Hitbox" type="Area2D" parent="." groups=["enemy_hitbox"]]
|
||||
position = Vector2( 0, 4 )
|
||||
|
||||
[node name="SegmentStart" type="Position2D" parent="Hitbox"]
|
||||
unique_name_in_owner = true
|
||||
position = Vector2( 12, 0 )
|
||||
__meta__ = {
|
||||
"_gizmo_extents_": 5.0
|
||||
}
|
||||
|
||||
[node name="HeadShape" type="CollisionPolygon2D" parent="Hitbox"]
|
||||
position = Vector2( 8, 0 )
|
||||
polygon = PoolVector2Array( -7, -2, 2, -2, 2, 2, -7, 2 )
|
||||
|
||||
[node name="HeadSprite" type="Sprite" parent="Hitbox/HeadShape"]
|
||||
show_behind_parent = true
|
||||
position = Vector2( -4, 0 )
|
||||
texture = ExtResource( 2 )
|
||||
|
||||
[node name="InnerBorder" type="Sprite" parent="Hitbox/HeadShape"]
|
||||
position = Vector2( 3, 0 )
|
||||
z_index = -1
|
||||
texture = ExtResource( 5 )
|
||||
|
||||
[node name="TailShape" type="CollisionShape2D" parent="Hitbox"]
|
||||
position = Vector2( 16, 0 )
|
||||
shape = SubResource( 3 )
|
||||
|
||||
[node name="TailSprite" type="Sprite" parent="Hitbox/TailShape"]
|
||||
show_behind_parent = true
|
||||
position = Vector2( 2, 0 )
|
||||
texture = ExtResource( 4 )
|
||||
|
||||
[node name="InnerBorder" type="Sprite" parent="Hitbox/TailShape"]
|
||||
position = Vector2( -2, 0 )
|
||||
z_index = -1
|
||||
texture = ExtResource( 5 )
|
||||
|
||||
[node name="Segment" type="CollisionShape2D" parent="Hitbox"]
|
||||
unique_name_in_owner = true
|
||||
position = Vector2( 12, 0 )
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[node name="SegmentSprite" type="Sprite" parent="Hitbox/Segment"]
|
||||
show_behind_parent = true
|
||||
texture = ExtResource( 3 )
|
||||
|
||||
[node name="InnerBorder" type="Sprite" parent="Hitbox/Segment"]
|
||||
position = Vector2( -2, 0 )
|
||||
z_index = -1
|
||||
texture = ExtResource( 5 )
|
||||
|
||||
[node name="InnerBorder2" type="Sprite" parent="Hitbox/Segment"]
|
||||
position = Vector2( 3, 0 )
|
||||
z_index = -1
|
||||
texture = ExtResource( 5 )
|
||||
|
||||
[connection signal="area_entered" from="Hitbox" to="." method="_on_Hitbox_area_entered"]
|
Loading…
Add table
Add a link
Reference in a new issue