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!

It depends what you are trying to do , i think you are attempting to do a radius. So for a radius use a = Atan(angle) to plot your directions then add sin(a) to x each time and cos(a) to y each time. then draw the respective tile.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org