I'm creating a game where I need to find operate on a list of objects in relation to other objects in that list. For example, I have some sprites with I call Creatures. The creatures need to figure out how far they are from all the other creatures and they do an action based on that distance.
My thought had to been to use a loop inside a loop like so:
// Loop through each creature
for each Creature
// Then, for each creature, loop through them again
for each Creature
// If we find a creature that matches some condition
if CreatureFromFirstLoop.condition
// Do something
CreatureFromFirstLoop.setInstanceVar(CreatureFromSecondLoop.data)
The problem is that I dont know how to appropriately refer to CreatureFromFirstLoop and CreatureFromSecondLoop.
With Construct2, this is all I know how to do:
for each Creature
for each Creature
if Creature.condition
Creature.setInstanceVar(Creature.data)
The problem is that this wont do what I want it to do.
Does someone know how to the change the second one into the first one? Or some other way to do it?
Can someone help or give me an alternate strategy?