Click to See Complete Forum and Search --> : game help!!!
tonyp
Apr 17th, 2000, 12:38 AM
im trying to make a rpg but if i
move the man to a tree how do i
make the man stop there??
Apollo
Apr 17th, 2000, 10:15 AM
You seriously want to know??? Because I have developed flawless collision detection...
Fox
Apr 17th, 2000, 12:14 PM
Depends on how you store the tiles (I wouldn't know how to do it without tiles, so if you aren't using tiles please do ;)). If you have a 2D map of tiles you draw on the screen you can just look in your map if there's a tree like this:
Public Sub Player.Move(iX as Long, iY as Long)
'For example if 1 is a tree
If Map( (Player.x + iX) / TileWidth, (Player.Height + iY) / TileHeight ) <> 1 Then
'No collision so move
Player.x = Player.x + iX
Player.y = Player.x + iY
End If
End Sub
Well, that doesn't work perfectly because you have to set a collision range for the player, but I think you'll get an idea how to do it :).
KENNNY
Apr 17th, 2000, 04:34 PM
Apollo, how do you do your detection, because mine sometimes fails and units get stuck inside each other :(
Fox
Apr 17th, 2000, 05:39 PM
Hm.. mine is flawless too ;)
Apollo
Apr 17th, 2000, 10:51 PM
Instead of checking for collision actually on your objects, I check for it a few steps ahead of them, like where they're about to go. And if they try to turn around, I check if there is something anywhere behind them, if not then start moving. I was having the same problem as you Kenny, because I would walk into an object, but get stuck, because the collision flag would be set to true as long as I was inside of the object, so I developed this little idea. It works perfectly for me, and I'm positive it will for you too.
If anyone wants a visual to represent what I'm saying, then I will provide one. Ya just have 2 ask.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.