Well, I look back and my first post was
very sloppy. I wrote it in a rush and it was late, yada yada. Anyways, I think I came up with another good theory. Only theory as I've yet to test it out in a script, but here it is:
PHP Code:
for (i=0;i<speed;i+=1/16) {
runintowall=onwall(player.x+1.5+vecx(playerdir)*i,player.y+2+vecy(playerdir)*i);
if (runintowall==true) {
player.x+=vecx(playerdir)*i;
player.y+=vecy(playerdir)*i;
break;
}
}
This is a simple wallcheck, not really one fit for an actual walking system, but you should get the idea. If a wall is anywhere in the area of the next step, instead of just breaking the walk-cycle, add to the players movement the size of i. Since i is anywhere's between 0 and the players max speed, it will look flush and fluent, yet not go past the wall since i can not be further than it triggered the onwall.
EDIT: Well I have tested this method at 10tiles/0.05sec and it works perfectly... almost. Going down and right flushes you right against the wall, however up and left is a
little offset. Nothing visually, but it shows in the player.x/y values as it has a semi-large floating value. I know why it's doing it, but it's an inconvenience. Either way, this method eliminates the need for pre-movement values and checks.