Loops within Loops and the Variables they Love

Get help using Construct 2

Post » Fri Feb 24, 2012 1:58 am

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

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

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?

Posts: 14
Reputation: 3,850

Return to How do I....?

Who is online

Users browsing this forum: Canofsuup and 20 guests