Under the Hood

Keeping this casual because I don't like writing formally! Maybe that will change with time, but I'd rather start like this than not start at all so let's get to it! 


I tried some brand new things with this project: I learned that Tilemap is a thing. Previously I was using code to arrange sprites in a grid based on their size (BAD, TIME CONSUMING, NOT MAINTAINABLE), but Tilemap is so much easier. With the stroke of a brush you can put sprites where they need to be and not worry about the rest of it. 

Not sure if this is a good use or not but I also used the Tilemap to position "non tile" objects like the houses and monsters. 

Monsters and houses have something like this to snap their positions to the centers of the tiles:

transform.position = tilemap.WorldToCell(transform.position) + new Vector3(0.5f, 0.5f);

Actually, I feel like there should be a setting somewhere that does this without code... Still learning! 

Another cool thing: The orange material bar is a Unity "Image" with the Image Type set to "Filled" and then you can just use the slider to make it go up and down. No need to figure out the math about it!

Another weird thing: Instead of using some kind of 2D array to keep track of positions like a normal person, the contents of tiles are actually in a Dictionary<Vector3, GameObject> where the Vector3 keys are specifically the centers of the tiles (like shown in the code above). I haven't encountered any issues with this and it saves the weirdness of translating rows and columns to x and y so I'm liking it so far.

Possible Future

This is more like a "dear future me" but if I were to keep working on this, I'd make the placement of the houses more physics based (like a slingshot?). Also maybe they can have different colours and it can be like a match three or something. Also definitely add a fail state because right now there's no winning or losing. 


My final words are that I'm proud of where I'm at! This demo only took me two days to put together despite a bunch of it being totally brand new. I'm hoping that with  ~documentation~ I can record what I'm learning and have something to look back on when I've made something really cool.


demo02.zip Play in browser
Feb 26, 2022

Leave a comment

Log in with itch.io to leave a comment.