Home › GameMaker › GameMaker GML AGENTS.md
GameMaker GML AGENTS.md
AGENTS.md for GameMaker (2024+ runtime) projects in GML: objects and events, structs and methods, and clean state.
AGENTS.mdGameMaker
How to use
Save this as AGENTS.md in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.
Note: Review and test before use. Provided as is, without warranty. See Terms.
AGENTS.mdDownload # 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.