I recently quit my job to pursue my dream of making an indie game. Part of the game involves procedurally generated tilemaps with enemies, the player, and any game objects (projectiles, traps, events).
Originally I was going to go simple ala Stardew Valley with four main directions and a view that matched. But I wanted the combat to feel better and I wanted the player to go in any direction they want - and it really just feels like isometrics views in games like Bastion, Path of Exile, Diablo, and Hades lend themselves to better combat.
I thought that it would be simple to use a basic non-isometric rectangle on the backend to track object positions and collision. It would allow me to easily calculate the tile a given object was located in based on origin by doing a simple integer divide on the width/height of a tile. Then when it came to drawing, I would just translate the location in the backend interpretation of the gameplay area into the actual screen position and then draw it.
But when I went to implement it, I realized that it would require that I do some calculation like:
double hyp = Math.Sqrt(Game.playerX^2 + Game.playerY^2);
float transX = (float)(Math.Sin(45) * hyp);
float transY = (float)(Math.Cos(45) * hyp);
I’d like to be able to scale to having hundreds of movable game objects in play at once, and calculating the above on each draw seems inefficient.
Should I explore ways to implement an isometric tilemap with collision detection on the backend, or is there a smarter way for me to do this? I did consider that stationary objects would only need to calculate their ‘translated’ X/Y once. Maybe I should have movable game objects store both their conceptual backend location and their translated position on initialization, update their position in update on the backend and do collision detection, and then if there’s a change in position update their draw position based on a simpler calculation? Like store both vectors, and if they conceptually in the backend implementation move 30 degrees below the x-axis down-left, and they move 0.2f, then update their draw vector based on a 45 degree clockwise shift which would be 15 degrees above the x-axis up-right?
Or is there like a super simple solution to this already and I’m just not seeing it?