I have modified it slightly to work with tiles, but I have encountered a problem.
First, here is my code:
var i,move_check;
for (i = abs(xspeed); i > 0; i -= 1){
if (i < 0) {
i = 0;
}
move_check = sign(xspeed)*i;
if !(check_tile_collision(x+move_check,y,direction)){
x += move_check;
break;
}
if !(check_tile_collision(x+move_check,y-i,direction)){
y -= i/2;
}
if !(check_tile_collision(x+move_check,y+i,direction)){
y += i/2;
}
}
for (i = abs(yspeed); i > 0; i -= 1){
if (i < 0) {
i = 0;
}
move_check = sign(yspeed)*i;
if !(check_tile_collision(x,y+move_check,direction)){
y += move_check;
break;
}
if !(check_tile_collision(x-i,y+move_check,direction)){
x -= i/2;
}
if !(check_tile_collision(x+i,y+move_check,direction)){
x += i/2;
}
}xspeed is the speed your player travels in the x direction. yspeed is the speed your player travels in the y direction.check_tile_collision:
tile_x = x + lengthdir_x(argument0,argument2); tile_y = y + lengthdir_y(argument1,argument2); return(tile_layer_find(1000000,tile_x,tile_y));
The problem is that the tile_x and tile_y values go to above 100 when I check for collisions. I am not sure why that is though.
Thanks,
Legobear154
Edited by legobear154, 06 June 2012 - 05:09 PM.











