Moving platforms as tiles or objects?

Hi guys,

I am curious to know some of you have gone about implementing moving platforms in your games, whether you use a custom tile map system or Tiled.

I am currently looking to write a TileMap system and can imagine two possible ways of handling moving platforms:

  • I can animate the platform tiles within the tile map by manipulating the map array. This could be a nightmare to manage as each platform will have different constraints on how and where it moves, but I can handle entity collisions with the platforms in the same way as all other tiles, which would be nice.
  • I create objects external from the TileMap system, which would be nice in the way of setting their travel paths, speeds and the like, but handling collisions would be more difficult

With my previous attempt at a tile map system, I handle collisions by updating entity velocity and then processing the x and y components separately, adjusting the velocity magnitude if a blocked tile is in the path of travel. If I have moving platforms as external objects, then would it be as simple as to check both the map and a list of moving platform objects during this collision checking process?

I would suggest making moving platforms entities like your enemies and player because eventually you’ll have to handle enemy collision. Yes, you can check for an entity in your path with your tile collision. If you have a large number of entities in a large area, try using a quadtree to sort out entities that definitely aren’t in your path.

Thank you for the suggestion Chrisio, that sounds like the cleaner way to go. It can be difficult to foresee some of the future challenges that will break a system.