// Run This Function in END STEP event
This function requires passing in arguments playerSpeed (not hspeed or speed)
You should also make an optional argument maxFall with a value of 15
In addition, you need to have two variables in the create event
optional: Jumping variable (needed in create if you are going to have
a jumping animation (controlled in step).
var move = -keyboard_check(vk_left) + keyboard_check(vk_right);
var collision = instance_place(x+playerSpeed, y+vspeed, all);
if (collision < 0 or !object_get_solid(collision.object_index)){
// Move to wall, if there is a SOLID wall to your right
move_contact_solid(0, playerSpeed);
collision = instance_place(x-playerSpeed, y+vspeed, all)
if ( collision < 0 or !object_get_solid(collision.object_index)){
// Move to wall, if there is a solid wall to your left
move_contact_solid(180, playerSpeed);
collision = instance_place(x, y - jumpSpeed, all);
// Check to see if you are in the air or are about to jump.
if (place_empty(x, y + 1) or jumpSpeed > 0 or (collision > 0 and !object_get_solid(collision.object_index))){
// Move up or down if there is no collision this frame.
if (collision < 0 or !object_get_solid(collision.object_index)){
// Check for a SOLID object below you
else if (jumpSpeed < 0 and object_get_solid(collision.object_index)){
move_contact_solid(270, jumpSpeed)
// Check for a SOLID object above you
else if (jumpSpeed > 0 and object_get_solid(collision.object_index)){
move_contact_solid(90, jumpSpeed)
if (jumpSpeed < -maxFall){
// If you are on SOLID ground, allow the player to jump again.
if (!place_empty(x, y+1) and instance_place(x, y + 1, all) > 0 and object_get_solid( instance_place(x, y + 1, all).object_index)){