Files
urm03/scripts/mech.gd
T
vh 380088c694 feat: tracer bullet — greybox arena, positioning piloting, auto-fire KINETIC weapon
One-screen 640x360 arena (walls, grid floor, fixed view), mech with
positioning-only movement (WASD/arrows, accel/decel, no aim), auto-fire
KINETIC hardpoint (nearest-target, visible range ring) firing slugs
that damage + knock back, untagged grunt trickle spawner with contact
damage, hull bar HUD, scene-reload on hull zero.

Headless smoke gate: tests/smoke.tscn asserts boot, piloting movement,
spawning, input-free auto-fire, grunt lethality, knockback displacement.
3/3 passes on nh3-dev headless 4.7.1.
2026-08-06 22:21:10 -07:00

38 lines
991 B
GDScript

class_name Mech
extends CharacterBody2D
## M03, greybox slab. Piloting is positioning ONLY (canon: no aim, no
## combos) — movement input is the entire control surface.
signal hull_changed(hull: float, hull_max: float)
@export var move_speed := 160.0
@export var accel := 900.0
@export var decel := 1200.0
@export var hull_max := 100.0
var hull: float
func _ready() -> void:
add_to_group("mech")
hull = hull_max
func _physics_process(delta: float) -> void:
var dir := Input.get_vector("move_left", "move_right", "move_up", "move_down")
var rate := accel if dir != Vector2.ZERO else decel
velocity = velocity.move_toward(dir * move_speed, rate * delta)
move_and_slide()
func take_damage(amount: float) -> void:
hull = maxf(hull - amount, 0.0)
hull_changed.emit(hull, hull_max)
if hull <= 0.0:
get_tree().reload_current_scene()
func _draw() -> void:
draw_rect(Rect2(-10, -12, 20, 24), Color(0.82, 0.84, 0.88))
draw_rect(Rect2(-6, -6, 12, 12), Color(0.55, 0.6, 0.68))