The prioritized movement code I showed above has parts of it that are in it for the later parts. Here is what the create and step events look like; as you'll see, I used an object called objSolid which was the parent object of all things you can run into.
image_speed = 0.50;
direction = 270;
move_s = 3;
move_c = 0;
width = sprite_get_width(mask_index);
height = sprite_get_height(mask_index);
is_moving = false;
has_hat = true;
/***************************************************************
PRIORITIZED MOVEMENT SCRIPT
Code Source: www.zfgc.com
Contributors:
- 4Sword: Switch statement based movement checking/correction,
collision based on bounding boxes
- Goodnight: Original movement system concept
IF USED, DO NOT REMOVE THIS CREDIT INFORMATION AND MAKE SURE TO
CREDIT ZFGC (aka. ZELDA FAN GAME CENTRAL) PUBLICALLY SO THAT
THIS CODE IS NOT MISTAKEN FOR YOUR OWN OR CONSIDERED STOLEN.
***************************************************************/
var hold_u, hold_d, hold_l, hold_r, move_f, collobj, overlap;
hold_u = keyboard_check(vk_up);
hold_d = keyboard_check(vk_down);
hold_l = keyboard_check(vk_left);
hold_r = keyboard_check(vk_right);
if (hold_u && hold_d){
hold_u = 0; hold_d = 0;
}
if (hold_l && hold_r){
hold_l = 0; hold_r = 0;
}
switch (hold_u + hold_d + hold_l + hold_r){
case 0:
is_moving = false; move_f = 0; move_c = 0;
break;
case 1:
is_moving = true; move_f = 1; move_c = 0;
if (hold_u)
direction = 90;
else if (hold_d)
direction = 270;
else if (hold_l)
direction = 180;
else
direction = 0;
break;
case 2:
is_moving = true; move_f = SQRT_TWO;
switch (direction){
case 90:
if (hold_d)
direction = 270;
break;
case 270:
if (hold_u)
direction = 90;
break;
case 180:
if (hold_r)
direction = 0;
break;
case 0:
if (hold_l)
direction = 180;
break;
}
break;
}
if (move_f != 0){
move_c += move_s;
while (move_c >= 1){
x += hold_r - hold_l;
if (place_meeting(x,y,objSolid)){
if (hold_u + hold_d == 0){
collobj = instance_place(x,y,objSolid);
overlap = !(bbox_top > collobj.bbox_bottom || bbox_bottom < collobj.bbox_top || (bbox_left + hold_l) > collobj.bbox_right || (bbox_right - hold_r) < collobj.bbox_left);
if (overlap){
move_f = SQRT_TWO;
if (!place_meeting(x,y - 1,objSolid)){
y -= 1;
}
else if (!place_meeting(x,y + 1,objSolid)){
y += 1;
}
else{
x -= hold_r - hold_l;
if (!place_meeting(x,y - height div 2,objSolid)){
y -= 1;
}
else if (!place_meeting(x,y + height div 2,objSolid)){
y += 1;
}
}
}
else{
x -= hold_r - hold_l;
}
}
else{
x -= hold_r - hold_l;
}
}
y += hold_d - hold_u;
if (place_meeting(x,y,objSolid)){
if (hold_l + hold_r == 0){
collobj = instance_place(x,y,objSolid);
overlap = !((bbox_top + hold_u) > collobj.bbox_bottom || (bbox_bottom - hold_d) < collobj.bbox_top || bbox_left > collobj.bbox_right || bbox_right < collobj.bbox_left);
if (overlap){
move_f = SQRT_TWO;
if (!place_meeting(x - 1,y,objSolid)){
x -= 1;
}
else if (!place_meeting(x + 1,y,objSolid)){
x += 1;
}
else{
y -= hold_d - hold_u;
if (!place_meeting(x - width div 2,y,objSolid)){
x -= 1;
}
else if (!place_meeting(x + width div 2,y,objSolid)){
x += 1;
}
}
}
else{
y -= hold_d - hold_u;
}
}
else{
y -= hold_d - hold_u;
}
}
move_c -= move_f;
}
}
Oh, and additionally, the SQRT_TWO part is a constant set in the game settings to be the closest decimal approximation that Game Maker allows for the square root of 2 - about 1.4142135620.