Hello there people,
I'm trying to implement a custom car maker, well basically the player is given a 32 by 32 grid, which they can place 4 by 4 pixel blocks on like so
now this will be of course stored in a 2D array, now for this example lets state that we have a 2D array which can hold 4 by 4
int carDesign[3][3]
the player then designs their car by placing blocks, at the end the player has something like this
0,1,1,0
1,0,0,1
1,0,0,1
0,1,1,0
now we first step through the 2D array and draw a block every time we reach a 1
so the first row would be like
no block, block, block, no block
each row element is X position 4 * element number
each column element is Y position 4 * element number
so at the end we have something like so draw on the screen
now this is awesome, this is something that I want and I can implement without a problem but here is the my problem, later on the game the player can create a 128 by 128 car, the 2D array would have a total of 1024 blocks to check, and it would have to do that for loop every frame to draw this custom car, now this would eat up tons of process as I plan to allow 8 players via network to play together, and draw 8 of these is 8192 blocks to draw every frame.
So i'm wondering if we had a 32 by 32 car design which is stored in a 2D array, could we not step though the 2D array elements once, save the outcome in a texture, then I can call stick that texture into a sprite and use that sprite, this then becomes a 1 block step compared to a large 1024 for loop to draw the same image, I am thinking I could allow the program to save the outcome as a image file and then load that up, but I would prefer if I could store the image output into a texture in the program for later use, does anyone have any ideas on who I could do that?
Thank you for reading.
Canvas.