3c6f31b503
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
27 lines
631 B
GDScript
27 lines
631 B
GDScript
class_name EnemyBullet
|
|
extends Area2D
|
|
## 敌方弹丸:直线飞行,出屏即回收。
|
|
|
|
const TEX := preload("res://assets/svg/bullet_enemy.svg")
|
|
|
|
var velocity := Vector2(0.0, 260.0)
|
|
|
|
|
|
func _ready() -> void:
|
|
collision_layer = 8
|
|
collision_mask = 0
|
|
var sprite := Sprite2D.new()
|
|
sprite.texture = TEX
|
|
add_child(sprite)
|
|
var shape := CollisionShape2D.new()
|
|
var circle := CircleShape2D.new()
|
|
circle.radius = 5.0
|
|
shape.shape = circle
|
|
add_child(shape)
|
|
|
|
|
|
func _process(delta: float) -> void:
|
|
position += velocity * delta
|
|
if position.y < -40.0 or position.y > 1000.0 or position.x < -40.0 or position.x > 580.0:
|
|
queue_free()
|