# AGENTS.md: GameMaker (GML)

## Basics
- Code lives in object events (`Create`, `Step`, `Draw`, `Draw GUI`, `Clean Up`) and script assets. Script assets define functions and constructors; they don't run per-frame logic at the top level.
- Use modern GML: structs, constructors (`function Inventory() constructor { ... }`), methods, `static` functions, and `array_*`/`struct_*` built-ins. Avoid `ds_*` structures unless needed for performance, and destroy any you create in `Clean Up`.
- Declare instance variables in `Create`; use `var` for locals. Never rely on undefined variables. Use `#macro` and `enum` for constants.

## Game loop
- Movement in `Step` uses `delta_time / 1000000` if the game is not locked to a fixed room speed, otherwise consistent per-step values. Pick one approach project-wide.
- State machines with an `enum` + `switch` or struct-based states, not piles of booleans.
- Collisions with `place_meeting`/`instance_place` and tilemap collision (`tilemap_get_at_pixel`) for terrain.
- UI drawing in `Draw GUI`; the world in `Draw`. Reset `draw_set_*` state (color, alpha, font, align) after you change it.

## Assets and data
- Name assets with prefixes: `obj_`, `spr_`, `snd_`, `rm_`, `scr_`, `fnt_`.
- Save data via `json_stringify(struct)` to a file with `buffer_save` or `file_text_*`, with a version field.

## Don't
- Don't edit `.yy`/`.yyp` project files by hand; describe IDE steps.
- Don't use `with(all)` or `instance_find` loops every step for lookups; keep references.
