Files
nerpa d1ae049b00
CI / Test (pull_request) Successful in 22s
feat: add weapons
- add fire pattern (base interface for all weapons)
- add shotgun and cannon pattern
- add basic projectile
- add input map for shoot
2026-05-15 20:51:52 +03:00

29 lines
633 B
GDScript

extends CharacterBody2D
@export var thrust := 500.0
@export var friction := 0.98
@export var max_speed := 1000.0
@onready var weapons = get_children().filter(func(c): return c is Weapon)
func _physics_process(delta: float) -> void:
handle_move(delta)
handle_shoot()
func handle_move(delta: float) -> void:
var direction = Input.get_vector("move_left", "move_right", "move_up", "move_down")
velocity += direction * thrust * delta
velocity *= friction
velocity = velocity.limit_length(max_speed)
move_and_slide()
func handle_shoot() -> void:
if Input.is_action_just_pressed("shoot"):
for w in weapons:
w.shoot()