Skip to main content
rule

gamemaker-gml — Cursor rule: what it does, how to install

Guides Cursor with GameMaker Language conventions for objects, scripts, and rooms. Keeps GML projects performant and prevents common memory leaks.

Install into Cursor · Manually: put the files in place All methods and platforms ↓
.cursor/rules/gamemaker-gml.mdc
Open on GitHub

What gamemaker-gml does

The rule targets **/*.gml, **/*.yy, and **/*.yyp files across the workspace. It enforces lifecycle separation: initialization stays in Create, simulation goes into Step, and visual rendering belongs strictly in Draw.

Core architectural recommendations include finite state machines for gameplay entities, input handling isolated from action execution, and object pooling for frequent effects. Broad searches like instance_find or repetitive collision scans in Step events are avoided to preserve performance.

Dynamic data structures must be destroyed when no longer needed. Relying on room editor instance creation order for deterministic logic is an explicit anti-pattern.

What it helps with

  • separate game simulation from rendering across Step and Draw events
  • clean up dynamic data structures to avoid GameMaker memory leaks
  • implement finite state machines for entity actions and UI states
  • replace heavy frame-by-frame instance searches with cached identifiers

Example prompts for the agent

  • Build an FSM for enemy patrol and chase states using GML functions.
  • Refactor the projectile spawner to use an object pool instead of constant instances.
  • Check this player object and move calculation logic out of the Draw event.

How to install gamemaker-gml

Manually: put the files in place

.cursor/rules/gamemaker-gml.mdc

Frontmatter: description, globs, alwaysApply

Step by step, with commands for each platform: Cursor rules: .mdc files, four modes and what replaced .cursorrules

Questions about gamemaker-gml

How to install gamemaker-gml in Cursor?

Add the rule file at .cursor/rules/gamemaker-gml.mdc in the root directory of your project.

What does gamemaker-gml do?

It directs Cursor to follow idiomatic GameMaker architecture, enforce event boundaries, and optimize Step event execution.

Why does the rule prohibit logic inside Draw events?

Draw events are strictly for rendering graphics. Running gameplay calculations there degrades frame rates and triggers timing bugs.

Source text

gamemaker-gml.mdc · CC0-1.0
---
description: GameMaker Language (GML) rules for scripts, objects, events, rooms, data structures, and performance-minded game code
globs: ["**/*.gml", "**/*.yy", "**/*.yyp"]
alwaysApply: false
---

# GameMaker GML Rules

## Code Organization

- Keep object event code short and move reusable behavior into scripts or functions.
- Use clear prefixes or naming conventions for scripts, objects, sprites, rooms, and globals.
- Prefer functions over copy-pasted event blocks.
- Keep create-step-draw responsibilities separate.
- Put initialization in Create, simulation in Step, and rendering-only work in Draw.

## GML Style

- Use descriptive variable names and avoid one-letter names outside small loops.
- Prefer local variables with `var` or function-scoped declarations over unnecessary instance variables.
- Use constants, enums, and macros for repeated identifiers, layer names, states, and collision groups.
- Guard optional instance references with `instance_exists`.
- Keep global state minimal and document it.

## Gameplay Architecture

- Use finite state machines for player, enemy, UI, and game-flow states.
- Keep collision logic explicit and deterministic.
- Separate input collection from action execution.
- Use alarms, timelines, or explicit timers consistently; do not mix patterns without reason.
- Store save data through structured maps/structs and version the save format.

## Performance

- Avoid expensive searches such as broad `instance_find` or repeated collision scans in every Step event.
- Cache frequently used asset IDs, layer IDs, and object references when safe.
- Destroy data structures when no longer needed.
- Use object pooling for frequent projectiles, particles, or short-lived effects when allocation becomes costly.
- Profile before optimizing and keep hot-path code simple.

## Debugging and Testing

- Add debug overlays for collision boxes, state, velocity, and AI decisions when useful.
- Use assertions or explicit guard clauses for impossible states.
- Test room transitions, pause/resume, save/load, and controller/keyboard input separately.
- Keep reproducible test rooms for complex mechanics.

## Common Mistakes

- Do not put game logic in Draw events.
- Do not create data structures without destroying them.
- Do not rely on room editor instance order for critical behavior.
- Do not hardcode magic numeric state IDs.

© PatrickJS · CC0-1.0 · PatrickJS/awesome-cursorrules

Similar IDE rules

Everything for Game dev and 3D: Unity, Unreal, Godot, Blender →

From the same set210

github-code-quality-cursorrules-prompt-file A set of guardrails for the Cursor agent: check facts before asserting them, skip apologies and recaps, change one file at a time. ★ 41,024repo stars gitflow Configures Gitflow branching standards, Conventional Commits format, and release steps for the Cursor assistant. ★ 41,024repo stars git-conventional-commit-messages This Cursor rule shapes Git commit messages around Conventional Commits. Use it when an agent needs consistent types, scopes, bodies, and footers. ★ 41,024repo stars gherkin-style-testing-cursorrules-prompt-file A Cursor rule that turns technical test scripts and manual cases into Gherkin scenarios written in plain business language. ★ 41,024repo stars fortran A Cursor rule for modern Fortran practices covering modules, types, arrays, builds, and tests. Use it when working on scientific Fortran code. ★ 41,024repo stars flutter-development-guidelines-cursorrules-prompt-file Locks down folder layout, naming and Dart style for Flutter apps built on MVVM with Riverpod. Useful when the agent scatters files across the project. ★ 41,024repo stars flutter-app-expert-cursorrules-prompt-file Configures Cursor for Flutter 3.x development with Clean Architecture, BLoC, and Material 3 design. Guides code structure and testing practices. ★ 41,024repo stars fastapi A Cursor rule for FastAPI work in Python. It guides project structure, API design, models, security, database code, testing, and deployment. ★ 41,024repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor