Loops within Loops and the Variables they Love

0 favourites
  • 1 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • 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?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)