44 lines
1.0 KiB
GDScript
44 lines
1.0 KiB
GDScript
extends RigidBody2D
|
|
@onready var player = %player
|
|
@onready var animated_sprite_2d = $AnimatedSprite2D
|
|
@onready var shoot_spawner = $ShootSpawner
|
|
const BOWSER_JR_FIRE = preload("res://scenes/enemies/bowser_jr_fire.tscn")
|
|
var shoot_direction = -1
|
|
const jump_force = 250
|
|
@onready var timer = $Timer
|
|
var pause = false
|
|
|
|
func _process(delta):
|
|
if pause:
|
|
return
|
|
if player.position.x > position.x:
|
|
animated_sprite_2d.flip_h = true
|
|
shoot_direction = 1
|
|
shoot_spawner.position.x = 32
|
|
else:
|
|
animated_sprite_2d.flip_h = false
|
|
shoot_direction = -1
|
|
shoot_spawner.position.x = 0
|
|
|
|
func shoot():
|
|
if pause:
|
|
return
|
|
animated_sprite_2d.play("open_mouth")
|
|
timer.start()
|
|
var instance = BOWSER_JR_FIRE.instantiate()
|
|
instance.speed *= shoot_direction
|
|
get_parent().add_child(instance)
|
|
instance.position.x = shoot_spawner.global_position.x
|
|
instance.position.y = shoot_spawner.global_position.y
|
|
|
|
func jump():
|
|
if pause:
|
|
return
|
|
linear_velocity.y = -jump_force
|
|
|
|
func f_die():
|
|
pass
|
|
|
|
func _on_timer_timeout():
|
|
animated_sprite_2d.play("default")
|