clegg
This commit is contained in:
commit
6a269eb236
97 changed files with 2137 additions and 0 deletions
28
bat/bat.gd
Normal file
28
bat/bat.gd
Normal file
|
@ -0,0 +1,28 @@
|
|||
extends Node2D
|
||||
|
||||
@onready var startpos = position
|
||||
@export var speed = 1.0
|
||||
@export var sine_distance = 64.0
|
||||
@export var shoot_cooldown = 1.0
|
||||
const BULLET = preload("res://bat/bat_bullet/bat_bullet.tscn")
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
%ShootTimer.start(shoot_cooldown)
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _physics_process(delta):
|
||||
var sine = sin(Time.get_ticks_msec() / 300.0) * sine_distance
|
||||
position.y = startpos.y + sine
|
||||
|
||||
|
||||
func _on_shoot_timer_timeout() -> void:
|
||||
var player = get_owner().get_node("Player")
|
||||
var bullet = BULLET.instantiate()
|
||||
bullet.global_position = global_position
|
||||
get_parent().add_child(bullet)
|
||||
if player.position.x < position.x:
|
||||
bullet.direction = -1
|
||||
else:
|
||||
bullet.direction = 1
|
Loading…
Add table
Add a link
Reference in a new issue