![]() |
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) |
RE: Objects list : How to use it? - System64 - 12-21-2020 Quote:Sometimes you'll need feedback from the actors list to the landmarks list: for example, when a spawn point creates an enemy at a specific place, and the player defeats the enemy, you will have to disable (or delete) that spawn point. If not, the enemy will resurrect each time the player goes to that zone again. This is not what you expect: once an enemy is defeated, it's gone forever. Except in 2D Mario games : if you kill an ennemy, it can respawn, except if you killed it with a fireball Yeah, this mecanic is weird, I'm agree RE: Objects list : How to use it? - megamarc - 12-24-2020 Hi, How you're doing with actors and game objects? Any progress? RE: Objects list : How to use it? - System64 - 12-24-2020 I don't know how I can put the data in the Tilengine's Object List into the language's list RE: Objects list : How to use it? - megamarc - 12-24-2020 In pseudo-code should be something like this. I can't put an exact implementation because each language has its own way to deal with lists. Other languages like C don't even have native list, you have to provide your own implementation -or use a third party library-. In this example, List and Item are ficticious elements -they don't exist in C-, but you got the idea. Code: TLN_ObjectList objects = TLN_LoadObjectList("filename.tmx", "layer_name"); RE: Objects list : How to use it? - System64 - 12-24-2020 It iterates to the next item automatically? I thought I had to use a for loop to iterate through the list with a for loop by increasing the index variable (the common way to iterate through a list) Also, can I define data such as the number of hp, the loot that the ennemy drops when killed, ... in Tiled? RE: Objects list : How to use it? - megamarc - 12-25-2020 Hi, Usual way to iterate lists is not with an index, but with a foreach clause and/or getfirst()/getnext() accessors. Index-based access is used in fixed length vectors. https://www.csharp-examples.net/foreach/ In Tilengine there are no separate getfirst and getnext functions, just one function. The info parameter to hold returned data is used as a switch:
RE: Objects list : How to use it? - System64 - 12-25-2020 I usually use a for(int c = 0; c < array.length - 1; c++) { // code } And if I understand well, my object has to possess the same attributes as the ObjectInfo structure also, what is the Object Type for? I checked the Python TMX exemple, the type field is empty RE: Objects list : How to use it? - megamarc - 12-27-2020 Yes, your created object should have the same attributes as the TLN_ObjectInfo structure, or at least the attributes you're interested on keeping. The type property holds the type custom attribute you define in Tiled. You can't see it in Python Platformer example because when I did that project, I hadn't implemented yet in Tilengine, so the binding doesn't have this functionality. This example uses the gid (graphic identifier) of the object's tileset being used for each enemy type. However, a custom type property is more flexible than using directly the gid attribute. RE: Objects list : How to use it? - System64 - 12-27-2020 and if I understand well, I can use the type for object's speed or what the object loots for exemple? RE: Objects list : How to use it? - megamarc - 12-28-2020 Yes, the actual value of type custom attribute is entirely upo to you, the game designer, to mean anything you decide. Tilengine will just tell you what value have you put in that property, but won't use it for anything. |