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.

Dark GDK / get collision on some objects in a 2d map using tiles

Author
Message
Wikaman1
16
Years of Service
User Offline
Joined: 17th Aug 2008
Location: Scotland
Posted: 29th Jan 2009 23:50
hi, I've just created a 2d map using tile studio(see the attached image). I want the player to be able to walk on the grass but not go into the water. Is there a way of telling what tile the player is standing on?

Attachments

Login to view attachments
Hayer
18
Years of Service
User Offline
Joined: 4th Nov 2005
Location: Norway
Posted: 1st Feb 2009 14:33
1 solution could be to create to layers

1 layer with the no-collision tiles.
2 layer with the collision tiles.
3 layer with enemyes

Just an example.

AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 1st Feb 2009 16:03
Have you successfully exported a map from Tile Studio? If not I can help. If you have then you can do the following calculation:



where PlayerPos is the position of the player and TileSize is the size in pixels of one tile. That will give you the tile coordinates of the tile the player is on. Then you can access your tile array with PlayerTileX and PlayerTileY and check what image the tile is. If it's water then the player can't walk on it, otherwise he can.

Login to post a reply

Server time is: 2024-09-30 17:38:58
Your offset time is: 2024-09-30 17:38:58