This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is the GameMaker HTML5 runtime - a JavaScript-based game engine runtime that executes GameMaker Studio games in web browsers. The runtime translates GameMaker Language (GML) into JavaScript execution and provides a WebGL-based rendering pipeline.
To use this runtime in GameMaker:
- Clone this repository to a local directory (e.g.,
C:\source\GameMaker-HTML5) - In GameMaker, navigate to Preferences > Platform Settings > HTML5
- Change Path to HTML5 runner to your repository path
- To revert: change the path back to
${html5_runner_path}
After making changes:
- Run your game in GameMaker using the HTML5 target
- Use the browser's Developer Tools (F12) to debug
- Use GameMaker's built-in Debugger for GML-level debugging
npx eslint scripts/**/*.jsThe project uses ESLint with browser environment targeting ES6. Key rules:
- Semicolons are required
- Many legacy warnings are downgraded to warnings (e.g.,
no-unused-vars,no-redeclare) - Mixed spaces/tabs and function reassignment allowed (legacy codebase)
Note: There is no automated test suite in this repository. Testing is done by running actual GameMaker projects.
scripts/runner.js: Main entry point that loads all runtime scripts viadocument.write()in dependency orderscripts/_GameMaker.js: Primary runtime initialization and game loop
The runtime uses a class-based system mirroring GameMaker's object model:
yyObject(scripts/yyObject.js): Object definitions containing events, properties, and parent relationshipsyyInstance(scripts/yyInstance.js): Runtime instances of objects with position, sprite, physics, and behavior propertiesyyRoom(scripts/yyRoom.js): Room management including layers, instances, views, backgrounds, and physics worlds
Instance lifecycle:
- Created via
yyInstance()constructor - Initialized with object properties and events
- Updated each frame through event system (Create → Step → Draw → etc.)
- Managed in room's active/deactive instance lists
Events are defined in scripts/Events.js and scripts/Globals.js:
- Events use a bitmask system (e.g.,
EVENT_CREATE = 0x000,EVENT_STEP = 0x300) - Event types: Create, Destroy, Alarm, Step, Collision, Keyboard, Mouse, Draw, etc.
- Instances execute events through their parent object's event functions
- Inheritance: child objects can call parent events
The rendering system is built on WebGL:
scripts/yyWebGL.js: Main WebGL interface and state managementscripts/libWebGL/: Low-level WebGL abstraction layerlibWebGL.js: Core WebGL wrapper and batch renderingyyCommandBuilder.js: Batched rendering command builderyyRenderStateManager.js: WebGL state cachingyyVBuffer.js/yyVBufferManager.js: Vertex buffer managementyyVertexFormat.js: Vertex format definitionsshaders/: GLSL shader definitions
scripts/yyGraphics.js: High-level 2D drawing primitivesscripts/CameraManager.js: Camera and view managementscripts/yyEffects.js: Shader effects system
Drawing flow:
- Game renders to application surface (or direct to backbuffer)
- Commands batched via command builder
- State changes minimized via render state manager
- Vertex data submitted to VBuffers
- Draw calls executed with appropriate shaders
Each GameMaker asset type has a corresponding yy*.js file:
yySprite.js: Sprite frames, collision masks, animations, nine-sliceyyBackground.js: Background/tile assetsyyFont.js: Font rendering (bitmap and SDF fonts)yySound.js: Audio playback (Web Audio API)yyBuffer.js: Binary buffer operationsyyParticle.js: Particle system managementyySequence.js: Animation sequences (largest file at ~8700 lines)yyAnimCurve.js: Animation curve datayyPath.js: Path definitionsyyTimeline.js: Timeline managementyy3DModel.js: 3D model storage
All built-in GML functions are in scripts/functions/:
- Organized by category:
Function_Graphics.js,Function_Collision.js,Function_String.js, etc. - Data structures:
collections/ds_grid.js,collections/ds_list.js,collections/ds_map.js, etc. - Drawing:
Function_Graphics.js,Function_Sprite.js,Function_Surface.js,Function_D3D.js - Game control:
Function_Instance.js,Function_Room.js,Function_Game.js,Function_Object.js - Physics:
Function_Physics.js(Box2D wrapper inscripts/jsBox2D/) - I/O:
Function_File.js,Function_HTTP.js,Function_Networking.js - Audio:
Function_Sound.js,Function_Sound_Legacy.js
scripts/yyVariable.js implements GML's dynamic type system:
- Type coercion between numbers, strings, booleans, arrays, structs
- Built-in variables (e.g.,
x,y,sprite_index,image_index) - Array and struct access patterns
- Reference tracking for objects and instances
Physics powered by Box2D (Liquid Fun):
scripts/physics/: Physics world, fixtures, joints, debug renderingscripts/jsBox2D/jsliquidfun.js: Box2D JavaScript port- Physics objects managed per-room via
yyPhysicsWorld
- Spine (scripts/spine/): Skeletal animation runtime
- SWF (scripts/SWF/): Flash animation support
- Yoga (scripts/yoga/): Flexbox layout engine for UI layers
- zlib (scripts/zlib/): Compression/decompression
- Font.js (scripts/fontjs/): Font parsing
- Fingerprint.js (scripts/fingerprintjs/): Device fingerprinting
- Long.js (scripts/long/): 64-bit integer support
- Classes/constructors: PascalCase with
yyprefix (e.g.,yyInstance,yySprite) - Global variables: lowercase with
g_prefix (e.g.,g_pBuiltIn,g_CurrentTime) - Member variables: camelCase with
m_prefix (e.g.,this.m_pStorage) - Constants: UPPER_SNAKE_CASE (e.g.,
EVENT_CREATE,BROWSER_CHROME) - Private properties: double underscore prefix (e.g.,
this.__x,this.__y)
/**@constructor*/
function yyClassName() {
this.__type = "[ClassName]";
// Initialization
}
yyClassName.prototype.MethodName = function() {
// Method implementation
};Use yyError() and related functions from scripts/yyErrorMessages.js for user-facing errors. The system provides descriptive error messages that reference GML function names and expected parameters.
- Coordinate Systems: HTML5 uses web coordinates (origin top-left), but GameMaker uses bottom-left for some operations (e.g., y-axis inverted for 3D)
- Reference vs Value: Instances are reference types; primitive values are copied
- Collision Masks: Collision can use sprite bounding boxes, precise masks, or custom shapes
- Layer System: Newer layer-based approach coexists with legacy depth-based rendering
- Application Surface: Most rendering goes through an application surface that can be disabled or resized
- Main development branch:
develop - Feature branches: Named with pattern
gmb-<issue-number>-<description>-dev - Commit messages: Start with
[H5]or[HTML5]prefix, reference issue numbers - Pull requests: Include exported GameMaker project (
.yyz) demonstrating changes when possible - The team performs code review before merging
scripts/
├── runner.js # Entry point / script loader
├── _GameMaker.js # Main runtime loop
├── Globals.js # Global constants
├── GameGlobals.js # Game-specific globals
├── Events.js # Event system
├── yy*.js # Core asset/system classes
├── functions/ # GML function implementations
│ ├── collections/ # Data structure functions
│ └── Function_*.js # Categorized GML functions
├── libWebGL/ # WebGL rendering layer
├── physics/ # Physics system
├── animation/ # Skeletal animation
├── sound/ # Audio system
├── Builders/ # Geometry builders
├── device/ # Platform detection
├── utils/ # Utility functions
└── [third-party]/ # External libraries
- Identify the appropriate
Function_*.jsfile inscripts/functions/ - Add function implementation following GML API specification
- Use
yyGetInt32(),yyGetReal(),yyGetString()for parameter extraction - Return appropriate types (numbers, strings, or objects)
- Test with a GameMaker project that calls the function
- Check
scripts/yyWebGL.jsfor low-level WebGL calls - Check
scripts/libWebGL/libWebGL.jsfor batch rendering logic - Verify shader compilation in
scripts/libWebGL/shaders/ - Use browser WebGL inspector tools (e.g., Spector.js)
- Check application surface handling in
_GameMaker.js
- Check
scripts/yyInstance.jsfor instance property handling - Check
scripts/Events.jsfor event dispatching - Verify object inheritance in
scripts/yyObject.js - Use GameMaker's debugger to inspect instance state
- Check room instance lists in
scripts/yyRoom.js
- Main repository: https://github.com/YoYoGames/GameMaker-HTML5
- Issue tracker: https://github.com/YoYoGames/GameMaker-HTML5/issues
- GameMaker bugs: https://github.com/YoYoGames/GameMaker-Bugs
- Feature requests: https://contact.gamemaker.io/