Post

 Resources 

Console

Home | Profile | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 VBGamer
 VBGamer
 Time Based Modelling
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sdw
Warrior

USA
160 Posts

Posted - Apr 02 2004 :  8:24:02 PM  Show Profile  Visit sdw's Homepage  Click to see sdw's MSN Messenger address  Reply with Quote
While the forums seem active tonight I'd like to see if I can get one of my little problems solved. The problem is that sometimes when I give an object too much speed it will run past a solid obstacle. eg:

There's a 2 dimensional map array, holding tile values and walkable values. When moving an object it checks to make sure that the tile it's moving onto is walkable first, then it will reset its position to that tile. But sometimes the speed is so great that the object's next position may actually pass over an unwalkable tile to another tile adjacent to it. How can I get around this problem?

Brykovian
Bryk the Cheese Slayer!

USA
58 Posts

Posted - Apr 02 2004 :  9:55:18 PM  Show Profile  Visit Brykovian's Homepage  Click to see Brykovian's MSN Messenger address  Reply with Quote
The process you're looking for is called "nearing" ... basically, if you have a situation like you describe, you need to walk through a loop of tiny changes from the position the object started in to where it would end moving at its current speed, and do a collision check at each point in the loop. Obviously, you don't draw it after each tiny position change in the nearing loop -- only use them for the checks.

-Bryk


www.mwgames.com
Go to Top of Page

Spodi
Warrior

USA
142 Posts

Posted - Apr 03 2004 :  12:00:19 AM  Show Profile  Visit Spodi's Homepage  Send Spodi an AOL message  Click to see Spodi's MSN Messenger address  Send Spodi a Yahoo! Message  Reply with Quote
I was gonna say exactly what Bryk did. So, for example, if you moved MX pixels with each tile 16 pixels wide:

If MX / 16 > 1 Then
For LoopX = 1 To Int(MX / 16)
If MapTile(LoopX + UserX, UserY).Blocked = True Then Exit sub
Next LoopX
End If

So for the first part, you check if you need to loop through with loopX. The second part gets the amount of tiles to check (rounded down because moving 1.9 tiles still wont be touchign tile 2 unless your game is on acid). The the part in the loop simply just checks if the tile is blocked, and if it is, it exits the sub - no movement takes place.

vbGORE
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
VBGamer © Go To Top Of Page
This page was generated in 0.19 seconds. Snitz Forums 2000

Copyright © 2002 - 2004 Eric Coleman, Peter Kuchnio , et. al.