Objects list : How to use it? - Printable Version +- Tilengine - The 2D retro graphics engine forum (http://tilengine.org/forum) +-- Forum: English forums (http://tilengine.org/forum/forumdisplay.php?fid=3) +--- Forum: Support (http://tilengine.org/forum/forumdisplay.php?fid=7) +--- Thread: Objects list : How to use it? (/showthread.php?tid=982) |
Objects list : How to use it? - System64 - 12-19-2020 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 RE: Objects list : How to use it? - megamarc - 12-19-2020 Hi, This is a gameplay mechanic topic. Tilengine itself is a graphics engine, no a full game engine, so it doesn't provide direct support for things like actors or game entities. This is something you must provide in your game code. However, this is a basic approach: Define your basic game entity -the "actor"-. It can be a hierarchy of classes or a simple structure, whatever you decide. It depends on type of game being designed, but typical properties are:
Have a list of active actors. This list is empty at the beginnig. At each frame, search list of spawn points and find which one(s) is candidate for spawn:
https://github.com/megamarc/TilenginePythonPlatformer Let me know RE: Objects list : How to use it? - System64 - 12-19-2020 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? RE: Objects list : How to use it? - megamarc - 12-19-2020 If you just want to use an object list as non-interactive "decorations", Tilengine can draw them by itself. To see a working example, chech the sample "forest" and its related assets: https://github.com/megamarc/Tilengine/blob/master/samples/Forest.c The graphic objects must be stored bitmap-based Tiled .tsx file. Check guide here: http://www.tilengine.org/doc/md_layers.html#autotoc_md31
RE: Objects list : How to use it? - System64 - 12-19-2020 The function TLN_Init() asks for a number of sprites, what is it for? RE: Objects list : How to use it? - megamarc - 12-19-2020 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. RE: Objects list : How to use it? - System64 - 12-20-2020 And is that related to the objects list? RE: Objects list : How to use it? - megamarc - 12-20-2020 No, they're unrelated. Object list can have an arbitrary number of items, and are related to background layers, not to sprites. RE: Objects list : How to use it? - System64 - 12-20-2020 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? RE: Objects list : How to use it? - megamarc - 12-20-2020 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. |