Let’s imagine there are 5 items, displayed as photos on an html5-canvas.
Every picture (unit) has a distinct dimension. For the sport I have to know the dimensions of that unit, and in addition it is center level.
How and the place do I save this knowledge?
If I load the picture, do I save that picture knowledge in a, f.e., an array of objects, the place every object has that picture attributes?
What do I do if that unit dies, do I delete that object from the array? And do I simply create a object once I create a brand new unit once more?
What construction can I exploit right here? An array of objects would not appear very environment friendly to me (I do not even know if it really works, not very skilled).
I had one thing like this in thoughts:
let unit_imgs = [
{
width,
height,
midpoint,
},
{
width,
height,
midpoint,
},
{ ... },
];
Every other, higher, methods to do that?