• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM Need help with 8 directional collision

B

begjan

Guest
I am using this code for movement and what I want is perfect collision with obj_invisible_wall. When obj_player place_meeting with obj_invisible_wall then he stops but able to move again and when obj_player place_meeting with obj_invisible_wall diagonal direction then he stops but able to move again or he will slope moving up or down.

So, guys I'm seeking your help with example codes, because to be honest I'm new in game maker language :)
thanks...


image_speed=0.175;
//image_speed = speed/5
speed=0;

/////////////////////////////////////////////////////////////
if (keyboard_check(vk_right) && keyboard_check(vk_up))
{
direction=45;
speed=3;
sprite_index=spr_walk_right_up;
}
else if (keyboard_check(vk_right) && keyboard_check(vk_down))
{
direction=315;
speed=3;
sprite_index=spr_walk_right_down;
}
else if (keyboard_check(vk_left) && keyboard_check(vk_up))
{
direction=135;
speed=3;
sprite_index=spr_walk_left_up;
}
else if (keyboard_check(vk_left) && keyboard_check(vk_down))
{
direction=225;
speed=3;
sprite_index=spr_walk_left_down;
}
/////////////////////////////////////////////////////////////
else if keyboard_check(vk_right)
{
direction=0;
speed=3;
sprite_index=spr_walk_right;
}

else if keyboard_check(vk_up)
{
direction=90;
speed=3;
sprite_index=spr_walk_up;
}
else if keyboard_check(vk_left)
{
direction=180;
speed=3;
sprite_index=spr_walk_left;
}
else if keyboard_check(vk_down)
{
direction=270;
speed=3;
sprite_index=spr_walk_down;
}
 
Top