oliveslogogif

GAMEMAKER STUDIO 2 PLATFORMER TUTORIAL

SET GAME SPEED

Go to Main Options and set the game frames per second to 60

MAKE A COUPLE SPRITES

Right Click where it says Sprites and Left Click Add Sprite. Twice.

Make one named: spr_flr

Make one more named: spr_plr

MAKE THE SPRITES INTO OBJECTS

Make one named: obj_flr

Make another named: obj_plr

CREATE THE PLAYER CODE

After you have created the object "obj_plr" double click on it and add a Create Event.

Copy and Paste this code into the Create Event:

{

air=0

alarm_get(0)

alarm_set(0,0)

}

NOW ADD THE "STEP" EVENT AND COPY AND PASTE THE FOLLOWING INTO THE STEP EVENT SEPERATE FROM THE CREATE EVENT:

if alarm[0]=1

{air+=1}

///move

if keyboard_check(vk_right) //move right

hspeed=4

if keyboard_check(vk_left) //move left

hspeed=-4

if keyboard_check_released(vk_right) //stop move right

hspeed=0

if keyboard_check_released(vk_left) //stop move left

hspeed=0

///jump

if keyboard_check_pressed(vk_up)

{if (place_meeting(x,y+1,obj_flr)) //press up to jump

alarm[0]=1}

if air>0

vspeed=-4 //upspeed

if air>26

{alarm[0]=0 //height of jump

air=0}

if air=0

{if alarm[0]=0

{if vspeed<0 //rate of fall

vspeed=4}}

if air=0

{if (place_meeting(x,y+vspeed,obj_flr)) //landing

{vspeed=0

move_contact_all(270,-1)}}

if vspeed=0

{if (place_meeting(x,y+1,obj_flr))=false //moving off the edge without jumping

vspeed=4}

if (place_meeting(x+1,y,obj_flr)) //side collisions

{if hspeed=hspeed

{hspeed=-hspeed}}

if (place_meeting(x+1,y,obj_flr))

{if hspeed=-hspeed

{hspeed=hspeed}}

ADD OBJECTS TO GAME ROOM

RUN THE GAME

If all goes well should have something like the following

this html5 preview was made in GMS1 so there are some minor differences, I only have the standard license for GMS2