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:
@@ -0,0 +1,53 @@
|
||||
class_name EnemyMedium
|
||||
extends EnemyBase
|
||||
## 中型轰炸机:从屏幕一侧横掠,正弦起伏,朝玩家方向瞄准射击。
|
||||
|
||||
const TEX := preload("res://assets/svg/enemy_medium.svg")
|
||||
|
||||
var side := 1 ## 1 = 从左向右,-1 = 从右向左
|
||||
var base_y := 220.0
|
||||
var vx := 110.0
|
||||
var fire_interval := 1.6
|
||||
var bullet_speed := 235.0
|
||||
|
||||
var _t := 0.0
|
||||
var _fire_timer := 1.0
|
||||
|
||||
|
||||
func setup(p_side: int, p_y: float, p_vx := 110.0, p_bullet_speed := 235.0, p_fire_interval := 1.6) -> void:
|
||||
side = p_side
|
||||
base_y = p_y
|
||||
vx = p_vx
|
||||
bullet_speed = p_bullet_speed
|
||||
fire_interval = p_fire_interval
|
||||
drops_powerup = true
|
||||
position = Vector2(-70.0 if side == 1 else 610.0, base_y)
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
hp = 6
|
||||
score_value = 400
|
||||
hit_radius = 30.0
|
||||
var sprite := Sprite2D.new()
|
||||
sprite.texture = TEX
|
||||
add_child(sprite)
|
||||
var shape := CollisionShape2D.new()
|
||||
var rect := RectangleShape2D.new()
|
||||
rect.size = Vector2(54.0, 30.0)
|
||||
shape.shape = rect
|
||||
add_child(shape)
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
_t += delta
|
||||
position.x += vx * float(side) * delta
|
||||
position.y = base_y + sin(_t * 1.1) * 46.0
|
||||
if (side == 1 and position.x > 610.0) or (side == -1 and position.x < -70.0):
|
||||
queue_free()
|
||||
return
|
||||
_fire_timer -= delta
|
||||
if _fire_timer <= 0.0:
|
||||
_fire_timer = fire_interval
|
||||
_fire_bullet(_aim_direction() * bullet_speed)
|
||||
Reference in New Issue
Block a user