Hi everyone !
I have big performance issues with my current game project (a real time tactical game, with terrain invasion (like Splatoon or Starcraft's Zerg creep !)).
100% CPU usage and 4~10 FPS.
The game area is a 40x40 grid, made of 32x32 pixels Tiles (1280px wide)
There is a 3D Array to save Race (humans, aliens,...), Type (hill, river, building,...) and Discovery Status (yes or no).
And there is a Fog of War function : units explore to reveal the map, and all the tiles = PlayerRace are auto-discovered (on layout start if any, or at anytime).
The goal : units move on a yet undiscovered and neutral map, and they can explore and invade tiles (=> the tile image changes according to the race it belongs).
I first created the grid with sprites (using several animations and frames to display the various informations but there should be 5 races, with a lot of tiles each. One tilemap per race seems the best deal, for me). For now, I work with a single TileMap containing the 6 Race Color Tile Sprites and Fog Tile Sprite.
But as I'm learning more and more about C2, I want to improve my event sheet with less events, and more complicated stuff (loop). I thought it'd be a good idea to use tilemap and For Each (already used and approved for my training game JumpLin Game (check my profile)).
Now I don't know what to do to make this system work.
The current code :
(on start of layout, the array is filled with a "0" value. In 1D, it's for neutral ownership. In 2D for the basic environnement. In 3D for "undiscovered" status. And after that, the grid is filled with tiles, all neutral for now).
The CPU killer code :
Few adjustments. No more 100% CPU, 15FPS... but no tiles displayed X)
For Each XYZ element :
___ check Z = 2 ||||||||||||||||||| Set Fog of War Tile Sprite
___ check value = undiscovered
___ check Z=2 |||||||||||||||| Set Race Tile Sprite (according to Z=0)
___ check value = discovered
___ check "Race on Tile = Player Race" ||||| Set Tile to discovered (in Z=2)
___ For Each FamilyUnits
________ -3 < X > +3 ||||||||||||||| Set Tile to discovered (in Z=2)
________ -3 < Y > +3
All the planned functionalities are not yet added and it already doesn't work ! X)
What can I do please ?
Go back to Sprites, animations and frames ? (I don't think the problem is here...)
Improve my usage of "For Each" loop ?
Don't use a single Array ?
Thank you for your help ! I hope i've been clear (sorry for my bad english).