so I'm making a game where I open boxes by clicking them on the HTML5 Canvas and try to match the numbers inside the box (long story short, getting a match = a win, i.e. 1st box could be a 5, if the 2nd box is also 5, I win).
When a box is clicked, a random number is generated between a certain range. What I need is a way to compare the numbers that are generated to check if the player has won or if they need to continue opening boxes.
I had thought about storing the randomly generated number, like so:
var firstChoice = Math.floor(Math.random() * (10 - 5 + 1) + 10);
var secondChoice = Math.floor(Math.random() * (10 - 5 + 1) + 10);
But I don't know how to have the program recognise when secondChoice, thirdChoice, fourthChoice etc. needs to be run for the next boxes instead of firstChoice.
Any tips?
Aucun commentaire:
Enregistrer un commentaire