feat: 场景与核心玩法脚本(双机型/波次/Boss/道具/炸弹/地面单位/浮游炮激光)

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
2026-08-31 00:31:29 +08:00
parent 024447fbda
commit 3c6f31b503
36 changed files with 1692 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
class_name PlayerBullet
extends Area2D
## 玩家子弹:沿自身方向直线飞行(斜射弹共享此类),命中敌机造成伤害。
const SPEED := 760.0
const TEX := preload("res://assets/svg/bullet_player.svg")
var direction := Vector2.UP
func _ready() -> void:
collision_layer = 2
# 4 空中敌机 + 32 地面/海面单位(只被打,不与玩家机体碰撞)
collision_mask = 4 | 32
var sprite := Sprite2D.new()
sprite.texture = TEX
add_child(sprite)
var shape := CollisionShape2D.new()
var rect := RectangleShape2D.new()
rect.size = Vector2(6.0, 16.0)
shape.shape = rect
add_child(shape)
# 旋转节点本身:贴图与碰撞矩形一起对齐弹道方向
rotation = Vector2.UP.angle_to(direction)
area_entered.connect(_on_area_entered)
func _process(delta: float) -> void:
position += direction * SPEED * delta
if global_position.y < -30.0 or global_position.x < -30.0 or global_position.x > 570.0:
queue_free()
func _on_area_entered(area: Area2D) -> void:
if area is EnemyBase:
(area as EnemyBase).apply_damage(1)
queue_free()