Thursday, August 18, 2022
HomeGame Developmentjavascript - How do I'm going about creating photos, that are items...

javascript – How do I’m going about creating photos, that are items with traits?


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?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments