"eh bo derek"

This commit is contained in:
MarcEricMartel 2023-10-10 19:27:17 -04:00
parent 4de4f43753
commit 98e9404435
3 changed files with 46 additions and 28 deletions

View File

@ -14,7 +14,7 @@
position = Vector2(441, 312)
[node name="BatSpawnable" parent="." instance=ExtResource("3_a1ucf")]
position = Vector2(248, 225)
position = Vector2(62, 122)
[node name="BatSpawnable2" parent="." instance=ExtResource("3_a1ucf")]
position = Vector2(644, 251)

View File

@ -90,6 +90,7 @@ func die():
animatedSprite.play("death")
animatedSprite.disconnect("animation_finished", endAttack)
animatedSprite.connect("animation_finished", fadeOut)
enemy.remove_foe(self)
func fadeOut():
var tween = get_tree().create_tween()

View File

@ -44,11 +44,13 @@ func _ready():
atk1r.set_disabled(true)
atk2l.set_disabled(true)
atk2r.set_disabled(true)
list.append($"../BatSpawnable")
list.append($"../BatSpawnable2")
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if abs(velocity.x) < 0.1 && abs(velocity.y) < 0.1 && !is_attacking:
if abs(velocity.x) < 0.2 && abs(velocity.y) < 0.2 && !is_attacking:
setAnimState("Idle")
elif !is_attacking:
setAnimState("Run")
@ -57,32 +59,33 @@ func _process(delta):
is_facing_left = velocity.x > 0 && !(velocity.x < 0)
# AI STUFF
#velocity += processAI(list,delta)
var x = 0
var y = 0
velocity += processAI(list) * delta
#var x = 0
#var y = 0
if Input.is_action_pressed("ui_left"):
#if Input.is_action_pressed("ui_left"):
# # Move as long as the key/button is pressed.
# x -= delta * 50
#elif Input.is_action_pressed("ui_right"):
# # Move as long as the key/button is pressed.
# x += delta * 50
#else:
# velocity.x *= 0.8
#if Input.is_action_pressed("ui_up"):
# Move as long as the key/button is pressed.
x -= delta * 50
elif Input.is_action_pressed("ui_right"):
# y -= delta * 50
#elif Input.is_action_pressed("ui_down"):
# Move as long as the key/button is pressed.
x += delta * 50
else:
velocity.x *= 0.8
if Input.is_action_pressed("ui_up"):
# Move as long as the key/button is pressed.
y -= delta * 50
elif Input.is_action_pressed("ui_down"):
# Move as long as the key/button is pressed.
y += delta * 50
else:
velocity.y *= 0.8
velocity.x += x
velocity.y += y
# y += delta * 50
#else:
# velocity.y *= 0.8
while velocity.length() > 100:
velocity.x *= 0.99
velocity.y *= 0.99
velocity.x *= 0.99
velocity.y *= 0.99
#velocity.x += x
#velocity.y += y
if !hitanim.is_emitting():
anim.modulate.a = 1
@ -90,11 +93,25 @@ func _process(delta):
move_and_slide()
func processAI(objs, delta):
func processAI(objs):
var vec: Vector2 = Vector2(0,0)
var weight: int = 0
for obj in objs:
vec += obj.vecpos * obj.weight * (1 / (position - obj.vecpos)) * delta
return vec.normalized()
if position.distance_to(obj.position) > 10:
weight = abs(obj.priority) * position.distance_to(obj.position)
vec += weight * position.direction_to(obj.position)
else:
weight = obj.priority * position.distance_to(obj.position) * (maxhp / hp) * 100
vec += weight * -position.direction_to(obj.position)
if vec.length() < 5 && objs.size() > 1:
vec.y *= 3
if velocity.length() < 95 && objs.size() > 1:
vec.y += 10
vec.x -= vec.x * .2
return vec.normalized() * 100
func attack():