M
mentalredux
Guest
Hello there, I'm working on making my first game and I need a little help. I have the playable character's movement working perfectly and now I am working on adding walls and other objects for the player to interact with. I am using a step function for movement and I'm not sure where to add the code that checks if the place is free before the object tries to move to the location. Any help would be greatly appreciated as well as criticism, thank you!
GML:
move_towards_point(mouse_x,mouse_y,2);
if distance_to_point (mouse_x,mouse_y)>200{speed=10};
else
if distance_to_point (mouse_x,mouse_y)>170{speed=8};
else
if distance_to_point (mouse_x,mouse_y)>150{speed=7};
else
if distance_to_point (mouse_x,mouse_y)>50{speed=4};
else
if distance_to_point (mouse_x,mouse_y)>25{speed=3};
else
if distance_to_point (mouse_x,mouse_y)>5{speed=2};
else
if distance_to_point (mouse_x,mouse_y)>3{speed=1};
else
if distance_to_point (mouse_x,mouse_y)<1{speed=0};
dir=floor(((point_direction(x+8,y+8,mouse_x,mouse_y)+22.5)%360)/45)
if(dir==0){
sprite_index=spr1_r;
}
if(dir==1){
sprite_index=spr1_ur;
}
if(dir==2){
sprite_index=spr1_u;
}
if(dir==3){
sprite_index=spr1_ul;
}
if(dir==4){
sprite_index=spr1_l;
}
if(dir==5){
sprite_index=spr1_dl;
}
if(dir==6){
sprite_index=spr1_d;
}
if(dir==7){
sprite_index=spr1_dr;
}