# ActionScript 3

Currently Being Moderated

## game logic/structure

### Mar 7, 2009 8:10 AM

hi wondered if someone could through me a few pointers. Im buidling a simple little game in flash. Basically there are 4 sets of different coloured numbers. And the user will be asked to do sums on them ie. multiply the lowest red number by the highest blue, divide the second highest yellow number by the second lowest green.

What im struggling with is working out the best way to code the question engine. The system needs to obvisouly pick:

two colours
two number ranges (lowest, highest etc)
a sum type (multiply etc)

It also needs to not ask the same question more than once. Ive started to go down the route of making arrays to store all the variations such as:

this._quizColourArray = [ 'red', 'blue', 'yellow', 'green'];
this._quizNumPattern = [ 'L-L', 'L-M', 'L-H', 'M-L', 'M-M', 'M-H', 'H-L', 'H-M', 'H-H']; (L-L = lowest to lowest)
this._quizSumType = [ 'add', 'subtract', 'multiply', 'divide'];

But this how to fit it all together that i'm struggling with, any pointers would be greatly appreciated.

Replies
• 62,219 posts
Jul 21, 2002
Currently Being Moderated
Mar 7, 2009 9:15 AM   in reply to zibber
create question array. use a triple nested for-loop to loop through all your colors, patterns and operations and push each triple into the question array. then randomize your array and proceed:

var questionA:Array = [];
for(var i=0;i<_quizColourArray.length,i++){
for(var j=0;j<_quizNumPattern.length,j++){
for(var k=0;k<_quizSumType.length,k++){
questionA.push([_quizColourArray[ i ],_quizNumPattern[j],_quizSumType[k]]);
}
}
}
shuffleF(questionA); // search the forums for the shuffleF().

// you can now loop through questionA presenting randomized questions.

|
Mark as:
Actions

#### More Like This

• Retrieving data ...