nc543 5079a77296 Main Menu and AI
- Mostly finished the settings menu
- Got basic AI working on easy difficulty
- Changed when animations are loaded
- Music now changes when you hit play
- Changed how AI will work. All enemies should only need the combatant script now
2024-05-12 00:22:34 -04:00

51 lines
1.5 KiB
GDScript

extends "res://Scripts/animationBase.gd"
@export var startPrimaryLoc: Vector2
@export var startSecondaryLoc: Vector2
@export var fullSize: float = 1
@export var explodeDur: float = 0.2
@onready var ballofayr: AnimatedSprite2D = $Path2D/PathFollow2D/AnimatedSprite2D
@onready var path: PathFollow2D = $Path2D/PathFollow2D
@onready var particles: GPUParticles2D = $Path2D/PathFollow2D/GPUParticles2D
var dir: int = 1
var exploding: bool = false
var timer: float = 0
var size: Vector2 = Vector2(0, 0)
# Called when the node enters the scene tree for the first time.
func _ready():
if inverted:
dir = -1
ballofayr.position = startSecondaryLoc
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if !exploding:
if (targetProg / finalProg < 0.3):
timer = clampf(timer + delta, 0, clampf(targetProg / finalProg, 0, 0.25))
path.progress_ratio = timer
if (targetProg / finalProg < 0.9):
ballofayr.scale = lerp(ballofayr.scale, Vector2((targetProg / finalProg) * fullSize, (targetProg / finalProg) * fullSize), delta * 2)
if (targetProg / finalProg >= 0.9):
timer = clampf(timer + delta, 0, targetProg / finalProg)
path.progress_ratio = timer
if path.progress_ratio == 1:
explode()
else:
timer += delta
if timer > explodeDur:
self.free()
func setProgress(target: float, final: float = finalProg) -> void:
targetProg = target
finalProg = final
func explode() -> void:
ballofayr.hide()
particles.emitting = true
exploding = true
timer = 0
func castFailed() -> void:
explode()