View Single Post
  #3  
Old 12-23-2007, 04:28 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by DustyPorViva View Post
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.
Zero (zokemon) said in an earlier thread (I'll add the link here if I find it) that he had a wall detection system that was perfect for this.

Edit:

Quote:
Originally Posted by zokemon View Post
I have one if people would like to have it. It is more hardcoded into my "doMovePlayer()" function though. It has 100% perfect onwall checks and emulates the default Graal movement exactly with an added variable of speed (I tested it at a rate of 5000 tiles per second and did not cross a single wall).
Quote:
Originally Posted by zokemon View Post
Yeah, mine will butt you up right against the wall even at such speeds.
Quote:
Originally Posted by zokemon View Post
Oh, I didn't see your post.
I'll post it in the code gallery and link it from here a little later after I spice it up (gotta remove some server specific things from the function first)
However, he never actually posted it.
__________________
Reply With Quote