GameMaker Studio Resources
Unlocking the ability to work on GameMaker Studio shows that you have learned the needed skills to take your game development to the next level. Below you will find a small collection of code snippits to help get your games going faster.
Copy & Paste Scripts
Platformer Code
obj_player
create
move_speed = 4;
jump_speed = 16;
move_x = 0;
move_y = 0;
step
NOTE: This script assumes your ground object is called: obj_ground and that you have viewport[0] enabled.
var move_x = keyboard_check(vk_right) - keyboard_check(vk_left);
if(!(move_x == 0))
{
image_xscale = sign(move_x);
}
move_x = move_x * move_speed;
var l2D9FA33B_0 = instance_place(x + 0, y + 2, [obj_ground]);
if ((l2D9FA33B_0 > 0))
{
move_y = 0;
var l5AE66F27_0 = instance_place(x + move_x, y + 2, [obj_ground]);
if (!(l5AE66F27_0 > 0))
{
var l1B8DB965_0 = instance_place(x + move_x, y + 10, [obj_ground]);
if ((l1B8DB965_0 > 0))
{
move_y = abs(move_x);
move_x = 0;
}
}
var l3731EA01_0;
l3731EA01_0 = keyboard_check(vk_space);
if (l3731EA01_0)
{
move_y = -jump_speed;
}
}
else
{
if(move_y < 10)
{
move_y += 1;
}
}
move_and_collide(move_x, move_y, obj_ground,4,0,0,-1,-1);