mercredi 13 mai 2015

How to get every image to be different when button is selected, no two same images should appear

i am making a simple maths game. When you select the start button, three random tickets should appear all containing a different equation and a random price will appear. The player has to select the correct maths equation which equals to the price.

I have the start button working where the random price and the random equations appear, my problem is, is that all three of the equations are the same, i want each one to be different?

I have the equations as images, ie they are like tickets with 3+4 inside them for example.

I can't get each image to be different and i only have three different equations...

I forgot to mention that i am using javascript

this is the javascript that i have so far for this part

function start(){
    comp = Math.floor(Math.random()*3)+1;   
    document.getElementById('speechbubble1').src = 'bubble/price' +comp+ '.gif';
    document.getElementById("tktbtn1").disabled= false;
    document.getElementById("tktbtn2").disabled= false;
    document.getElementById("tktbtn3").disabled= false;
    document.getElementById("resetscore").disabled= false;
    document.getElementById('equation1').src = 'tickets/maths' +comp+ '.gif';
    document.getElementById('equation2').src = 'tickets/maths' +comp+ '.gif';
    document.getElementById('equation3').src = 'tickets/maths' +comp+ '.gif';
}

I would appreciate any help or any form of direction on where to discover how to do this

Aucun commentaire:

Enregistrer un commentaire