Reputation: 365
I am making a choice based game.. where I have given the user different objects each time and ones that they click gets a specific value....
this is where the problem comes in when I have to export this into showing their choices I have to write an if statement for everysingle object asking to check it's value.. if it's the one user picked then draw the object on to the stage.. now this gets really messy does anybody know a way around this? can u please explain it to me step by step since I am fairly new at this...
Upvotes: 1
Views: 87
Reputation: 324650
Depending on how many different items you have, you might be able to save a bitmask, like this:
items = 00001101110011
Where 1 represents an item the user has, and 0 one they don't have.
Then, you just need one loop, iterating i
, and then check if (1<<i) & items
and get the item's data from an array.
Upvotes: 2