Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 12-23-2007, 03:22 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
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.
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 12:56 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.