Hello. I’ve been working on a side project of mine, tile-based (Easiest thing ever, right?) strategy game. I have given each “unit” a method to “see” tiles, based on a “viewRange” integer. The way that I have it set up right now is that in my “Tile” class, if a tile is not within the view range of any units, it just defaults to a gray “Fog of War” tile. Otherwise, it draws the actual tile image (Grass, Mountain, whatever).
Anyways, I’m having difficulty setting up a loop that will take care of this automatically, and can be applied as-is without hard-coding anything specific to each “unit” type. The unit I’m experimenting with is a “scanProbe”, that can has a 5-tile viewRange. My current method is to have a for loop, starting at -viewRange (To start the value of viewRange to the left/above unit), and adding 1 for every iteration. I’m then setting “tile[unitTileX + i][unitTileY + i].canBeSeen = true;”. Github for more in-depth study is here: https://github.com/RyanMB97/TileBasedStrategy. Classes worth mentioning are: “Level”, “Tile”, “Entity”, and “ScanProbe”.
A quick thanks in advance for whoever can help me solve this. Also, seems worth mentioning, but could anyone tell me how to get either a block-like view area, or a diamond-like view area? Thanks again!
P.S.: Almost forgot that a picture would probably be useful: