PHP Code:
if (dir==2) {
if (onwall(down,coordinates)) {
//for loop here that goes left and right on X if dir in {0,2} and Y if its else
if (!onwall(i,y_coordinates_used_with_onwall)) {
move(x-i,y_coordinates_used_with_onwall_or_whatever_looks_better,time,20);
}
}
}
???