Posts: 187
Threads: 22
Joined: Dec 2020
Reputation:
1
I want to put some objects in my world and make them spawn on screen and self-destruct outside the screen
But I don't understand how to use theses list. Can you explain clearely how can I achieve that please? I know I have to code functions that inserts and remove objets from the list but that's all
Posts: 187
Threads: 22
Joined: Dec 2020
Reputation:
1
So if I understand well, I have to provide to TLN_LoadObjectList a tilemap file and a layer name?
My object Layer is stored with a tilemap layer in Tiled, so I have to provide this tilemap layer with the name of this object layer?
Posts: 187
Threads: 22
Joined: Dec 2020
Reputation:
1
12-19-2020, 11:29 PM
(This post was last modified: 12-19-2020, 11:42 PM by System64.)
The function TLN_Init() asks for a number of sprites, what is it for?
Posts: 673
Threads: 33
Joined: Jan 1970
Reputation:
13
Sprites in Tilengine are statically allocated during init, you set the maximum number of sprites the engine will manage. All sprite functions take an index number indicating which sprite are you dealing with. Background layers work this way too. This is to mimick actual 2D graphic chips, where sprites and layers are hardware slotted and you don't create or destroy them, but instead you enable/configure them.
The sega megadrive/genesis has 80 sprites, the super nintendo/famicom 128, and the NeoGeo has 380 -but no background layers-, to give you an idea.
Posts: 187
Threads: 22
Joined: Dec 2020
Reputation:
1
And is that related to the objects list?
Posts: 673
Threads: 33
Joined: Jan 1970
Reputation:
13
No, they're unrelated. Object list can have an arbitrary number of items, and are related to background layers, not to sprites.
Posts: 187
Threads: 22
Joined: Dec 2020
Reputation:
1
and if I understand well, if an object (an ennemy for exemple) creates another object (a bullet for exemple), this bullet goes in this list?
Posts: 673
Threads: 33
Joined: Jan 1970
Reputation:
13
Yes, each created entity must go to the list of active actors, that must be processed each frame. And when you delete an actor, release its resources (for example its assigned sprite) and remove it from the list.