1. #1

    Ignore targets in an Array that have been destroyed?

    I have 50+ orbs that can be destroyed.
    Each second, a random one changes color.
    How to ensure the code will ignore the destroyed orbs when choosing one to change its color?
    In other words, how to ensure it doesn't keep targeting 49 missing orbs when only 1 remains?
    Trying to avoid a ton of IF/THEN statements :/.

    So far I'm thinking setting it's grid position in a 2D Vector to 0, then IF rand(address)=0, THEN roll again.. but I will end up with a pile of zeros when all I need is a 1.
    Share this post

  2. #2
    Waistless's Avatar Member
    Join Date
    Nov 2014
    Location
    Australia
    Posts
    137
    What I would suggest doing: create another array which contains parallel values (variable data source, 0 for no 1 for yes) of if an orb is destroyed, and use the same index as you're using to reference the orbs to do a condition check if the orb is destroyed.

    So for instance when an orb is destroyed set that array(index) to destroyed (so set value on that to 1), then you can use a check later on that index to see if its destroyed, then handle that how you wish.
    Share this post