Introducción al Desarrollo de Videojuegos con GameMaker · Module 1: Introduction to GameMaker, Installation, and First Project
Overview of GML Code and GML Visual
Lesson 5 of 60 · 60 min
Also available in: ES
Two Paths to the Same Goal: Logic in GameMaker
When building a video game, the underlying engine handles rendering graphics to the display, playing audio, and capturing keyboard or gamepad input. However, the engine cannot inherently know the rules governing your specific world: it does not know whether a player should lose health upon touching spikes, whether collecting a coin should grant ten points, or whether a door should open when an interact key is pressed. To bring these mechanics to life, developers must program the game's logic.
Historically, GameMaker has stood out across the industry by democratizing game development through two distinct workflows that differ fundamentally in interface yet remain equivalent in purpose: GML Visual (formerly known as Drag and Drop or DnD) and GML Code (the engine's native text-based programming language). Both coexist inside the same IDE and communicate seamlessly, but each fosters a different way of thinking about, organizing, and executing software design.
This lesson demystifies both paradigms, examines how GameMaker translates visual actions into machine instructions, contrasts their operational performance and day-to-day ergonomics, and establishes why we adopt GML Code as the foundational language for our retro platformer project.
What Is GameMaker Language (GML)?
GameMaker Language (GML) is a proprietary programming language designed specifically for the GameMaker ecosystem. Unlike general-purpose languages such as C++, Python, or C#, GML is built from the ground up to solve common challenges in 2D game development. It provides built-in spatial variables for object coordinates (such as 'x' and 'y'), dedicated sprite and animation properties (such as 'sprite_index' and 'image_speed'), and native functions that detect complex geometric collisions with a single instruction.
It is crucial to understand that GML Visual is neither an alternate engine nor an isolated language. GML Visual is simply a visual abstraction layer resting directly on top of GML Code. Every action block you drag onto the canvas, every field you fill in a visual node, and every execution wire you connect corresponds internally to one or more lines of GML Code. When you compile or run your project (F5), GameMaker converts those visual blocks into standard textual code before packaging the executable. Under the hood, the computer always runs the exact same fundamental instructions, regardless of the interface you used to construct them.
GML Visual: Action-Block-Based Programming
GML Visual is a visual scripting system based on modular action blocks and nodes. Rather than writing syntax statements inside an empty text editor, the developer selects pre-built actions from a side toolbox and drags them directly onto an object's event canvas.
Each action block represents a distinct logical operation identified by an intuitive icon and natural-language label. For instance, dedicated blocks exist for 'Assign Variable', 'If Variable', 'Set Direction and Speed', and 'Destroy Instance'. Linking these blocks sequentially from top to bottom creates a visual flowchart that mirrors the CPU's step-by-step execution path.

Control flow in GML Visual is organized using visual indentation and nesting. When you insert an 'If' conditional block, any dependent actions intended to run only when that condition evaluates to true are indented slightly to the right, nested beneath the parent block's tab. This layout allows developers to track the exact route the processor takes when an entity collides, a countdown timer reaches zero, or a key is pressed.
Key Advantages of GML Visual
1. Elimination of syntax errors: For absolute beginners, one of the steepest hurdles in learning to code is the friction caused by minor punctuation mistakes: missing a semicolon (;), forgetting a closing brace (}), mixing up uppercase and lowercase letters, or misspelling a function name. In GML Visual, these errors are virtually impossible because action blocks enforce validated inputs and rigid forms that reject typographical mistakes.
2. Guided API discovery: The action toolbox categorizes operations into thematic sections (such as Movement, Instances, Audio, Drawing, and Control Logic). Beginners can explore engine capabilities simply by browsing through available tool palettes without needing to memorize function names from the technical manual beforehand.
3. Visual branching representation: Understanding branching logic ('if A occurs, execute B; otherwise, execute C') is intuitive when mapped out with color-coded nodes and chained flowlines, giving artists, designers, and visual thinkers an accessible entry point into computational logic.
Limitations and Trade-offs of GML Visual
Despite its clear educational value, heavy reliance on GML Visual introduces substantial bottlenecks as game projects scale in size and architectural complexity:
First, development speed (ergonomics) decreases significantly. Writing a mathematical formula to calculate a parabolic jump trajectory takes just a few seconds on a keyboard. In GML Visual, that exact same formula requires dragging multiple assignment blocks, wiring auxiliary variables, and toggling drop-down menus. What fits into a single clean line of text can easily consume an entire screen's worth of visual blocks.
Second, screen real estate becomes difficult to manage. An object running a full finite-state machine (idle, walk, run, jump, wall-slide, attack, hurt) produces massive node graphs requiring constant panning and zooming, making it challenging to maintain a coherent overview of the software architecture.
Finally, team collaboration and version control (tools such as Git and GitHub) suffer noticeably. Text-based code can be cleanly reviewed, diffed, and merged line by line. Visual scripts, by contrast, are serialized behind the scenes as dense XML or JSON files; when two developers modify the same visual object simultaneously, resolving merge conflicts manually is error-prone and can easily corrupt project assets.
GML Code: The Power of Textual Code
GML Code is the direct, unadorned way to program GameMaker. It is an imperative, structured, dynamically typed scripting language whose syntax is heavily influenced by C, C++, and JavaScript. In GML Code, developers define instructions using statements built from functions, arithmetic operators, reserved keywords, and custom variables.
Execution flows strictly from top to bottom, line by line, inside each event. Conditional and iterative code blocks are delimited using curly braces ('{' and '}'), while individual statements are conventionally closed with a semicolon (';'). GameMaker includes an advanced code editor featuring intelligent syntax highlighting, real-time error checking, predictive autocompletion (IntelliSense), and instant contextual documentation by middle-clicking any native keyword or function.
Decisive Advantages of GML Code
1. Maximum iteration speed and agility: Once familiar with basic syntax, a programmer writes logic at typing speed. Standard tasks like duplicating a condition, modifying three numerical parameters, or reordering execution lines take milliseconds using universal keyboard shortcuts (such as Ctrl+C, Ctrl+V, or moving lines with Alt+Arrow keys).
2. High information density and clarity: A single standard desktop monitor comfortably displays 50 to 80 lines of structured code. This allows you to inspect an entity's complete state machine or an enemy's core AI loop at a glance without navigating through floating panels or node clusters.
3. Seamless community collaboration and troubleshooting: Roughly 95% of GameMaker tutorials, open-source repositories, technical forums, and community discussions are shared exclusively in GML Code. Asking for help online requires only pasting a formatted snippet of text; troubleshooting GML Visual requires uploading multiple full-screen UI screenshots, which slows down feedback and peer support.
4. Professional version control: GML scripts and object events are stored as plain-text files (.gml). Version control systems track exact changes with surgical precision (for instance: 'line 24 modified, move_speed changed from 4 to 6'), enabling robust branching, code reviews, clean merges, and comprehensive commit histories.
Comparative Overview: GML Visual vs. GML Code
To establish a clear perspective on both paradigms before writing production code, the following matrix contrasts the primary technical and operational factors encountered in daily development:
| Evaluation Criteria | GML Visual (Action Blocks) | GML Code (Pure Text) |
|---|---|---|
| Initial learning curve | Very gentle; ideal for learners with zero prior programming experience. | Moderate; requires learning core syntax, punctuation rules, and function signatures. |
| Writing and editing speed | Low; relies on continuous mouse clicks, pop-up menus, and canvas panning. | Very high; utilizes keyboard shortcuts, code completion, and multi-line editing. |
| Screen real estate efficiency | Low; blocks and connecting wires require wide viewing areas. | High; dozens of complex instructions fit neatly within a single editor view. |
| Syntax error prevention | Prevents typos and invalid syntax via pre-configured fields and dropdown menus. | Requires attention to punctuation (semicolons, matching braces, and variable spelling). |
| Community support & resources | Limited; few intermediate or advanced developers share visual solutions. | Universal; the overwhelming majority of tutorials, packages, and answers use GML Code. |
| Version control (Git) | Difficult to audit and resolve when concurrent merge conflicts occur. | Excellent; structured plain text cleanly highlights additions, deletions, and diffs. |
| Runtime game performance | Identical; the compiler translates visual blocks into equivalent GML Code representations. | Identical; both paths compile to the exact same VM bytecode or optimized C++ (YYC). |
Comparative Case Study: Horizontal Movement and Input Handling
To observe how both paradigms solve the same problem in practice, let us examine an essential platformer mechanic: checking whether the player is holding down the right arrow key and updating the character's horizontal position accordingly.
Now, let us inspect the exact same technical instruction written in GML Code within the text editor for that same Step event:
// obj_player Step Event
// Check if the right arrow key is being held down this frame
if (keyboard_check(vk_right))
{
// Increase horizontal coordinate by 4 pixels
x = x + 4;
}Examining the anatomy of this code reveals clear mechanics. The 'if' keyword establishes a logical branch. The condition inside the parentheses, '(keyboard_check(vk_right))', calls a built-in GameMaker function that returns 'true' as long as the specified key remains held down, and 'false' otherwise. The body inside the curly braces '{' and '}' contains the action: 'x = x + 4;' reads the object's current horizontal position and increments it by 4 pixels. This can also be written concisely using the compound assignment operator: 'x += 4;'.
Contrasting both implementations highlights a meaningful difference in abstraction: while GML Visual relies on checking a 'Relative' checkbox, GML Code exposes the direct mathematical relationship: 'x equals its previous value plus 4'. This explicit mathematical clarity eliminates ambiguity and reinforces a solid mental model of Cartesian coordinates in 2D game worlds.
The Bridge Tool: Live Preview and Conversion
One of GameMaker's most effective learning features for developers transitioning to code is its ability to display visual programming as live textual code. This feature provides an interactive bridge that removes the intimidation factor from learning text-based syntax.
When building an event using GML Visual, right-clicking anywhere on the visual canvas opens a context menu where you can choose 'Live Preview'. GameMaker opens a read-only side panel showing the exact GML Code generated by the active blocks. Whenever you modify an action parameter or reorder a node on the canvas, the code in the preview updates instantly.
💡 Pro tip: You can permanently convert an event built in GML Visual to GML Code by right-clicking the event workspace and selecting 'Convert to GML Visual / Code'. Keep in mind that this operation is generally one-way: GameMaker translates action blocks into clean textual code, but custom hand-written code containing advanced constructs cannot always be parsed back into visual blocks.
Why We Choose GML Code for This Course
In this curriculum, we make the deliberate choice to standardize on GML Code starting in Module 2 and throughout our complete 2D platformer build. While GML Visual works well for rapid one-off prototyping, this course is designed to build durable, professional skills that translate across game development.
This methodology rests on three core rationales:
1. Project scalability: Building a complete retro platformer with sub-pixel movement, variable-height jump physics, solid collision response, enemy state machines, user interfaces, and save data requires clean architectural modularity. Managing these systems entirely with visual blocks leads to cognitive overload and fragmented canvases.
2. Transferable computational skills: Learning GML Code reinforces universal programming concepts: data types, local vs. instance scope, arrays, 'for' loops, 'switch' statements, and modular methods. These foundational patterns apply directly if you later transition to C#, GDScript, JavaScript, or C++.
3. Developer autonomy and problem-solving: Fluency in GML Code enables you to leverage the full breadth of GameMaker community documentation, follow advanced tutorials, integrate third-party libraries, and read compiler error logs directly in the output console to debug issues independently.
Practical Activities and Exercises
To reinforce your understanding of both paradigms and practice translating between them, complete the following three exercises:
Summary
- GML (GameMaker Language) is the engine's core logic layer; both GML Visual and GML Code compile into the same underlying operational instructions.
- GML Visual organizes logic through modular, connected action blocks, providing a structured, syntax-error-free entry point for beginners and visual designers.
- GML Code delivers text-based scripting with C-style syntax, offering maximum typing efficiency, high information density, and seamless Git version control integration.
- GameMaker provides a 'Live Preview' panel that displays the textual GML Code generated by visual blocks in real time, serving as an effective bridge between paradigms.
- Starting in Module 2, this course relies on GML Code as our technical standard to build a scalable, professional, and maintainable 2D platformer.
Practise what you learned
Exercise 1 · 1 point
When you compile or run a project (F5) in GameMaker, the engine directly executes GML Visual blocks through an isolated graphical interpreter without converting them to GML Code.
Exercise 2 · 1 point
Match each GameMaker concept or paradigm with its corresponding characteristic or limitation:
- GML Visual
- GML Code
- Version control (Git)
- F5 key
Exercise 3 · 1 point
In GML Code, blocks of conditional or loop logic are enclosed using , while individual statements conventionally end with a .
Sign in to save your progress — Sign in