[AS2] how to generate Random Questions for a game?
HI... i'm trying to make a "Who wants to be millionaire" flash game. but the questions are allways the same and in the same order. I had an idea: let Actionscript choose 1 question out of 100... so the question DONT repeat.
But the problem is: I dont know how to generate random questions... i just know how to generate random Numbers. plz help
I wouldn't recommend picking questions at random since you'll probably end up selecting the same question more than once before you go through all the questions. A better suggestion might be to shuffle the contents of the array then to go through the array in order so you don't repeat any questions.
You should be able to find a shuffle function by searching the forums for "shuffle".
Hey guys, I am newbie in flash. Im working on this quiz game whereby the player will shoot the correct balloon. When the player shoot the correct answer , the score will increase by 1. The player also have to complete the quiz within the time limit of 10 seconds.
Now my problem is , I dont know how to store the questions and answers in the xml file and make it appear on my flash game.
I have also attached how the game is like in this thread.
Please advise!! Much appreciated!
If your questions are going to be held in objects than you can do something like this:
Code:
// array to hold all of the questions
questionArray = new Array();
// question object
function QuestionObject() {
// set id to random number
this.id = Math.floor(Math.random()*10000));
this.questionType = null;
this.answeredStatus = null;
this.someParam = null;
}
// create questions
questionArray.push(new QuestionObject());
questionArray.push(new QuestionObject());
questionArray.push(new QuestionObject());
// order array based on random id
questionArray.sortOn("id");
Each object gets a unique id and then using the sortOn array method it reorders them based on that id.
__________________
â€* GOD Is Near â€*
Questions Don't PM for Questions . Thanks
An eye for an eye, make the whole world blind
_____________________________________________GHANDI
var totalFrames = 5
theLevel_btn.onRelease = function(){
_level0.gototAndStop(Math.rounf(Math.random()*totalFrames+1))
}
__________________
â€* GOD Is Near â€*
Questions Don't PM for Questions . Thanks
An eye for an eye, make the whole world blind
_____________________________________________GHANDI