Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / array collision

Author
Message
dax24
20
Years of Service
User Offline
Joined: 2nd Feb 2004
Location:
Posted: 31st Mar 2004 14:32
i am a complete begineer to dbpro and i am trying to find some info on how to make a collision with a data file (array). hope this makes sense to people.

i have the code written out, what would i need to do to make a sprite react witht the tiles loaded from the data file?
dax24
20
Years of Service
User Offline
Joined: 2nd Feb 2004
Location:
Posted: 31st Mar 2004 19:07
also does anybody know how to make a collision work for a sprite and a tile using the code posted above?????

this thing is really hurting my brain
Scouseknight
20
Years of Service
User Offline
Joined: 15th Mar 2004
Location: Bootle, Merseyside, UK
Posted: 31st Mar 2004 19:45 Edited at: 31st Mar 2004 19:45
You will need to convert the sprite's X and Y positions (which could be anything from 0 to 320 for the X, and 0 to 240 for the Y) to array elements :

PlayerX# = PlayerX# / 16
PlayerY# = PlayerY# / 16

Next, work out the integer values of the above :

PlayerX = Int(PlayerX#)
PlayerY = Int(PlayerY#)

Now, use the PlayerX and PlayerY you have to check the adjacent cells :

PlayerUp = level_tiles(PlayerX, PlayerY-1)
PlayerDown = level_tiles(PlayerX, PlayerY+1)
PlayerLeft = level_tiles(PlayerX-1, PlayerY)
PlayerRight = level_tiles(PlayerX+1,PlayerY)

If you want to see an example of this in action then check out my Pac Man guide which has array-based collision detection along the same lines as yours :

http://darkbasic.thegamecreators.com/?m=forum_view&t=28865&b=7

Hope this helps.

dax24
20
Years of Service
User Offline
Joined: 2nd Feb 2004
Location:
Posted: 2nd Apr 2004 12:12
thanks for that Scouseknight, helped me out alot.

also, nice tutorial on the pacman game.

Login to post a reply

Server time is: 2024-09-22 04:42:41
Your offset time is: 2024-09-22 04:42:41