Log In  


Cart #sasnagoza-0 | 2020-12-30 | Code ▽ | Embed ▽ | No License
2

Arrow keys to move around, X to place a grass tile. Just a quick and dirty implementation of tile bitmasking.

Basic process is:

  • Create table same width/height as map, store what kind of tile is here (empty,grass,water,etc)
  • When you hit the X key, assign the corresponding index in the table to 1
  • Run a function to update the map accordingly
  • Show map and cursor

The autotile function checks the cardinal directions for neighboring tiles of the same type using the table, then returns a value 0-15 depending on what came back. Then we pull from another table filled with sprite indexes to figure out what should go on the map.

I used this article to figure out the best way to go about this: https://gamedevelopment.tutsplus.com/tutorials/how-to-use-tile-bitmasking-to-auto-tile-your-level-layouts--cms-25673

This current implementation is quite token heavy and isn't the cleanest thing in the world, but it's a good start I think!

2


Love it



[Please log in to post a comment]