0% found this document useful (0 votes)
3 views5 pages

Gamemaker Studio Functions

The document provides an overview of key functions in GameMaker Studio for game development, detailing their purposes, syntax, and practical examples. Functions include point_direction for angle calculation, keyboard_check for key detection, and instance_create_depth for object creation, among others. Each function is illustrated with code examples and outputs to demonstrate their application in a game context.

Uploaded by

usamahabib733
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views5 pages

Gamemaker Studio Functions

The document provides an overview of key functions in GameMaker Studio for game development, detailing their purposes, syntax, and practical examples. Functions include point_direction for angle calculation, keyboard_check for key detection, and instance_create_depth for object creation, among others. Each function is illustrated with code examples and outputs to demonstrate their application in a game context.

Uploaded by

usamahabib733
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Gamemaker Studio Functions

Introduction
Subtitle: Core Functions for Game Development
Content:
Overview of key functions in a sample GameMaker Studio game.
Each section explains one function with a practical example.
Visual: GameMaker Studio logo or a screenshot of a simple game.

point_direction(x1, y1, x2, y2)


Purpose: Computes the angle (in degrees) from one point to another.
Syntax: point_direction(x1, y1, x2, y2)
Example:
// Aim player sprite at mouse cursor
image_angle = point_direction(x, y, mouse_x, mouse_y);
Output: Rotates the player sprite to face the mouse.

keyboard_check(key)
Purpose: Detects if a specified key is held down.
Syntax: keyboard_check(key)
Example:
// Move player up with 'W' key
if (keyboard_check(ord("W"))) {
y -= 5;
}
Output: Moves player 5 pixels up when 'W' is pressed.

place_meeting(x, y, obj)
Purpose: Checks for collision with an object at a given position.
Syntax: place_meeting(x, y, obj)
Example:
// Move right if no wall collision
if (!place_meeting(x + 5, y, obj_wall)) {
x += 5;
}
Output: Moves instance right if no wall is detected.

instance_create_depth(x, y, depth, obj)


Purpose: Creates an instance of an object at a specific position with depth.
Syntax: instance_create_depth(x, y, depth, obj)
Example:
// Spawn a bullet at player's position
instance_create_depth(x, y, depth + 1, obj_bullet);
Output: Creates a bullet instance in front of the player.

draw_self()
Purpose: Draws the instance’s sprite at its current position.
Syntax: draw_self()
Example:
// Render player sprite
draw_self();
Output: Displays the player sprite with current rotation with position.

draw_text(x, y, string)
Purpose: Displays text at specified coordinates.
Syntax: draw_text(x, y, string)
Example:
// Show player health
draw_text(20, 50, "HP: " + string(hitpoints));
Output: Displays "HP: 100" at position (20, 50).

draw_set_font(font)
Purpose: Sets the font for text drawing.
Syntax: draw_set_font(font)
Example:
// Set font with display ammo
draw_set_font(fnt_game);
draw_text(20, 100, "Ammo: " + string(ammo));
Output: Draws "Ammo: 20" in the specified font.

show_message(string)
Purpose: Shows a pop-up message box with text.
Syntax: show_message(string)
Example:
// Prompt to reload when ammo is zero
if (ammo == 0) {
show_message("Press SPACE to reload!");
}
Output: Displays a message box for reloading ammo.

instance_destroy()
Purpose: Removes the calling instance from the game.
Syntax: instance_destroy()
Example:
// Destroy player when health is zero
if (hitpoints <= 0) {
instance_destroy();
}
Output: Removes the player instance from the game.

game_end()
Purpose: Closes the game application.
Syntax: game_end()
Example:
// End game on player death
if (hitpoints <= 0) {
game_end();
}
Output: Closes the game window.
distance_to_object(obj)
Purpose: Measures distance to the nearest instance of an object.
Syntax: distance_to_object(obj)
Example:
// Enemy fires if player is close
if (distance_to_object(obj_player) < 250) {
instance_create_depth(x, y, depth, obj_enemy_bullet);
}
Output: Spawns enemy bullet if player is within 250 pixels.

You might also like