
12-23-2007, 03:22 AM
|
|
Will work for food. Maybe
|
 |
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
|
|
Flush wall detection
|
I'm messed around with walking systems before... but I figure I could learn something that still boggles me.
I've tried walking systems, and of course the hardest part is the wall detection... so my question is, how can you make a flush wall detection?
By flush I mean, as you run into a wall, you walk flush into it, not 3 pixels away, not 2 pixels in, right up against it. Add to this, walking any speed...(of course, not something ridiculous like a 5 tile walking speed... but 2 doesn't seem too bad).
I've been pondering this, and I've seen some pretty good walking systems out there, but not really function well over 1 tile/0.05sec... so maybe I thought we could all put our heads together on this.
EDIT:
Okay, so right after I posted this I figured something out... many times I see people using for loops to detect placements between the player and the next move... I've cultivated something similar. What I did was run a for loop as:
for (i=0;i<this.speed;i+=1/16) {}
This will create a loop between every pixel and the speed the player is going.
Then, do a wall check, incrementing the check by i:
this.testx=playerx+2.5+i;
This will check every pixel between the player and the next move. Now, instead of just writing a check that you're touching a wall, I did this:
player.x=this.testx-2.5;
This will set the player flush up against the wall, and I've done this going 5 tiles/0.05sec so far and it has worked flawlessly. I'd still love to hear more stuff about this as I'm sure everyone could benefit from it, and there must be better ways. |
|
|
|