Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Objects list : How to use it?
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
How you're doing with actors and game objects? Any progress?
I don't know how I can put the data in the Tilengine's Object List into the language's list
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.

TLN_ObjectList objects = TLN_LoadObjectList("filename.tmx", "layer_name");
TLN_ObjectInfo info;          // will hold data of queried objects
List dest_list = new List();  // create destination list

bool has_items = TLN_GetListObject(objects, &info); // query first object
while(has_items) {  // iterate all items in objects list
    Item item = new Item();  // create new item
    // TODO: copy "info" data into created item
    dest_list.add(item);  // adds new item to destination list
    has_items = TLN_GetListObject(objects, NULL);  // query next object
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?
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.

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:
  • if not empty, it returns the first element
  • if empty, it returns the next element in succession
You can define any data you want in Tiled, but tilengine will only load and offer you the custom type property. If you want to load any other custom gameplay-related data not used by Tilengine, then you must provide a custom loader for the .tmx data.
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
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.
and if I understand well, I can use the type for object's speed or what the object loots for exemple?
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.

Forum Jump:

Users browsing this thread: 1 Guest(s)