@Jurgen5586 You need to use tile attributes. I set attributes for BlockedNorth, BlockedSouth, etc and check them when the player is moving. If the player is about to move north, the game checks if the tile one north of the player's position has a BlockedSouth property. I do the properties on the tileset, so you check the map's layer's tile's TileIndex. If the player is at (4, 3), you check if Map.Layer[int layerumber].Tile[4, 2].TileIndex.ContainsProperty(BlockedSouth) == true.
@FactoryEight Yeah.. About that.. To be honest that didn't make much sense to me. If it does not take too much time, could you write me a simple guide or make a video? :)
@Jurgen5586 Give your player object a CheckForCollisions function that returns a boolean. If it returns false, let the character move. In the function, you need to determine what tile the character is standing on, and check the properties of the tile that they'd be on if they were to move. Just play around with the xTile functions and get an idea of what properties there are in a map that you can check. There's also some good code snippets on the tIDE forums to explain Tile/TileIndex properties.
@FactoryEight I think I came up with somthing! :D if (keyState.IsKeyDown(Keys.Right) && map.Layers[2].Tiles[playerLocation.Right / 64].TileIndex == 14) playerLocation.X += 6;
Tileindex 14 is the tile which you should be able to walk on and so far it seems to work! :D :D
The only thing I need help with now is translating location(in pixels) to locations in tiles. Do you know any simple method to do that? :)
@theotherther1 Ignore the art, those are just placeholder sprites. That's a sprite template from OpenGameArt, and won't be final art in whatever I end up making. Right now, focus is on the engine itself.
Is there by any chance a possibility for you to make a tutorial on how you can make collision in xTile like that?
I've been trying to learn XNA and xTile and I always get stuck on the collision part.
I would be grateful if you did. :D
Jurgen5586 3 months ago
@Jurgen5586 You need to use tile attributes. I set attributes for BlockedNorth, BlockedSouth, etc and check them when the player is moving. If the player is about to move north, the game checks if the tile one north of the player's position has a BlockedSouth property. I do the properties on the tileset, so you check the map's layer's tile's TileIndex. If the player is at (4, 3), you check if Map.Layer[int layerumber].Tile[4, 2].TileIndex.ContainsProperty(BlockedSouth) == true.
FactoryEight 3 months ago
@FactoryEight Yeah.. About that.. To be honest that didn't make much sense to me. If it does not take too much time, could you write me a simple guide or make a video? :)
Jurgen5586 3 months ago
@Jurgen5586 Give your player object a CheckForCollisions function that returns a boolean. If it returns false, let the character move. In the function, you need to determine what tile the character is standing on, and check the properties of the tile that they'd be on if they were to move. Just play around with the xTile functions and get an idea of what properties there are in a map that you can check. There's also some good code snippets on the tIDE forums to explain Tile/TileIndex properties.
FactoryEight 3 months ago
@FactoryEight After a little bit of fiddling I found out a way that worked like a charm. Thanks! :D:D
Jurgen5586 3 months ago
Comment removed
Jurgen5586 3 months ago
This has been flagged as spam show
@FactoryEight I think I came up with somthing! :D if (keyState.IsKeyDown(Keys.Right) && map.Layers[2].Tiles[playerLocation.Right / 64].TileIndex == 14) playerLocation.X += 6;
Tileindex 14 is the tile which you should be able to walk on and so far it seems to work! :D :D
The only thing I need help with now is translating location(in pixels) to locations in tiles. Do you know any simple method to do that? :)
Jurgen5586 3 months ago
teh old final fantasys
ethansleepybear 6 months ago
What are they supposed to be, monkeys? Cavemen? Nudists?
theotherther1 6 months ago
@theotherther1 Ignore the art, those are just placeholder sprites. That's a sprite template from OpenGameArt, and won't be final art in whatever I end up making. Right now, focus is on the engine itself.
NayusDante 6 months ago