Hi guys, I was trying to make a mini-map like the one in metroid or axiom verge.
My idea was to create a 2D Array of bools and, based on which room the player is in, turn the corresponding bool to true, and then, based on which bool is true and which false, display the correct tile in the correct position on a canvas.
The problem is that I don’t know how to make this, I tried making a 2D array of bool, and make a switch statement that takes the name of the current scene and based on that turn true the appropriate bool, but beyond that I’m stuck!
First, let’s review what you’re trying to make here… something like this, right?
You could do this with a little Image in a canvas for every square, but it’s going to be a lot of work to set up, hard to maintain, and perform poorly.
What I’d probably do instead is make an image of the full map, including all the icons and labels and so on; and then layer a PixelSurface on top of that, and simply paint over the areas that haven’t been explored yet. (Or to flip it around: initialize the PixelSurface with an image of the white-on-black grid, and then erase parts of this as you explore.) PixelSurface includes functions to draw/fill rectangles, so that’d be pretty easy to do.
But, full disclosure, I made PixelSurface, so I may be considered biased.
I guess another way to do the same thing would be to write some code to create little black squares in a loop, covering the entire map except for the areas you have explored. (Or covering the entire map initially, and then deleting or disabling them as you explore.) That’s not likely to perform as well, but on modern machines it probably doesn’t matter.