[FAQ] Drag and Drop to GML (easy way to learn GML)

Tab one

Move Fixed, Move Free
motion_set(direction, speed);

Move Towards...
move_towards_point(x, y, speed);

Change horizontal speed
hspeed= x ;

Change vertical speed
vspeed = x;

Set gravity
gravity_direction = x;
gravity_amount = y;

Reverse horizontal direction
hspeed = -hspeed;

Reverse vertical direction
vspeed = -vspeed;

Set friction
friction = x;

Jump to position
x = val;
y = val;

Jump to start position
x = xstart;
y = ystart;

Jump to random position
move_random(1, 1);

Align to grid
move_snap(h, v);

Wrap screen
move_wrap(h, v, margin);

Move to contact
move_contact_solid(dir, maxdist);
move_contact_all(dir, maxdist);

Bounce
move_bounce_solid(advanced);
move_bounce_all(advanced;)

Set path
path_start(path, speed, end_action, absolute);

End path
path_end();

Step towards
mp_linear_step(x, y, size, checkall);

Step avoiding
mp_potential_step(x, y, size, checkall);

Tab 2

Create instance
instance_create(x, y, objectname);

Create moving
ID = instance_create(x, y, object1);
with (ID) motion_set(direction, speed);

Create random
instance_create(x, y, choose(object0, object1, object2));
(up to 16 unlike drag and drop's 4)

Change instance
instance_change(obj, perform?);

Destroy instance
instance_destroy();

Destroy at position
position_destroy(x, y);

Change sprite
sprite_index = sprite0;

Transform sprite
image_xscale = x;
image_yscale = y;
image_angle = z;
image_xscale = -1; (horizontal flip)
image_yscale = -1; (vertical flip)

Color sprite
image_blend = x;
image_alpha = y;

Play sound
sound_play(snd);
sound_loop(snd);
sound_stop(snd);

Check sound
if sound_isplaying(sound)=true { //actions }

Room changing
room_goto_previous()
room_goto_next()
room_restart()
room_goto(x);

Check previous
if room_previous(x)<>-1 then { //actions }

Check next
if room_next(x)<>-1 then { //actions }


Main tab 2

Set alarm
alarm[0] = steps;

Sleep
sleep(x);

Set timeline
timeline_index = x;

Set timeline position
timeline_position = x;

Display message
show_message('Message');

Show game info
show_info();

Show video
show_video(filename, full?, loop?);

Restart game
game_restart();

End game
game_end();

Save game
game_save('filename');

Load game
game_load('filename');

Replace sprite
sprite_replace(index, filename, number, precise?, transparent?, smooth?, preload?, ox, oy);

Replace sound
sound_replace(index, filename, type, loadonuse?);

Replace background
background_replace(index, filename, transparent?, smooth?, preload?);


Control tab

Check empty
if place_free(x, y) { //actions }

Check collision
if !place_empty(x, y);
if place_meeting(x, y, all);
if !place_free(x, y);

Check object
if place_meeting(x, y, object0) { //actions }

Test instance count
if instance_number(object) = x { //actions }

Test chance
if floor(random(value)) = 0 { //actions }

Ask question
if show_question('The Question?') { //actions }

Test expression
if (expression) { //actions }

Check mouse
if mouse_check_button(mode) { //actions }

where mode is: mb_none, mb_left, mb_middle, mb_right

Check grid
if place_snapped(x, y) { //actions }

Exit event
exit;

Repeat x
repeat(amount) statement;

Call parent event
event_inherited();

Execute script
script_execute(index, args);

Set variable
normal assignment, i.e. varname = value; or global.varname = value;.

Test variable
if varname = x { //actions }

Draw variable
draw_text(x, y, variablename);




Under construction. Sorry for any inconvenience.


Credits: it's all there if you know where to look. Also thanks to The Game Maker's Apprentice, and to Game Maker Community's tutorial board for some clarifications.

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=68828