PluginBench
Rule

gamemaker gml

via PatrickJS/awesome-cursorrules

GameMaker Language best practices for scripts, objects, events, and performance-conscious game code.

What is gamemaker gml?

Rules for writing maintainable, performant GML code in GameMaker projects. Covers object organization, state machines, collision handling, memory management, and debugging patterns. Use this when developing GameMaker games to avoid common pitfalls and keep code modular and efficient.

  • Enforce separation of concerns across Create, Step, and Draw events with clear responsibilities
  • Guide use of finite state machines for player, enemy, and game-flow logic
  • Recommend caching and object pooling strategies to avoid expensive searches and allocations
  • Establish naming conventions and variable scoping practices (locals over instance vars where appropriate)
  • Provide debugging patterns including collision overlays, assertions, and reproducible test rooms
  • Flag common mistakes like game logic in Draw events, leaked data structures, and magic numbers

Applies to

File patterns this rule matches.

["**/*.gml"
**/*.yy
"**/*.yyp"]
Rule definition (reference)

Source of truth, from the repository.

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.

Related rules

Convert test scripts to business-readable Gherkin (Given-When-Then) format for QA documentation.

**/*
41k
via PatrickJS/awesome-cursorrules

Structure commit messages with type, scope, and description for semantic versioning and automated changelog generation.

**/*
41k
via PatrickJS/awesome-cursorrules

Gitflow branching strategy with protected main/develop branches, feature/release/hotfix workflows, and semantic versioning.

["**/*"]
41k
via PatrickJS/awesome-cursorrules

Enforce disciplined AI coding practices: verify facts, make focused changes, avoid unnecessary commentary.

**/*
41k
via PatrickJS/awesome-cursorrules

Clean code principles and best practices for readable, maintainable software development.

**/*
41k
via PatrickJS/awesome-cursorrules
GOgo logo

Idiomatic Go: explicit error handling, interface-based design, context-first concurrency.

**/*.go
41k
via PatrickJS/awesome-cursorrules