Random et possibilité unique
Allo à tous,
j'ai un petit jeu, la première fois que j'utilisais du random :
http://www.coco-game.com/jeux_en_vrac.htm
Il faut cliquer la bonne image. Seulement, il faudrait pour que ce soit plaisant qu'il y est 9 images différentes tout le temps, et donc une seule bonne possibilité. Dans le moment, voilà ce que j'ai fait (c simple) :
J'ai 9 boutons dans un mc, a peu près comme suit (a part le mc appelé 'bleue' qui change pour chaque bouton) :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| on (press){
_root.bleue.gotoAndPlay(2);
_root.nb1 = Math.round (Math.random ()*9)-1;
_root.nb2 = Math.round (Math.random ()*9)-1;
_root.nb3 = Math.round (Math.random ()*9)-1;
_root.nb4 = Math.round (Math.random ()*9)-1;
_root.nb5 = Math.round (Math.random ()*9)-1;
_root.nb6 = Math.round (Math.random ()*9)-1;
_root.nb7 = Math.round (Math.random ()*9)-1;
_root.nb8 = Math.round (Math.random ()*9)-1;
_root.nb9 = Math.round (Math.random ()*9)-1;
_root.nb9b = Math.round (Math.random ()*9)-1;
} |
et à la racine:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| depart=new Date();
compte=0;
d=depart.getTime()/1000;
stop();
onEnterFrame = function(){
temps2 = new Date();
t = temps2.getTime() / 1000;
_root.chrono = 60-Math.floor(t - _root.d); //10 est le temps du compte a rebours, t est le temps qui s'ecoule et d le temps initial de l anim
if (_root.chrono==-1) {_root.gotoAndStop("final");}
if (nb1==1)
{
_root.chef.gotoAndStop(nb2);
}
if (nb1==2)
{
_root.chef.gotoAndStop(nb9b);
}
if (nb1==3)
{
_root.chef.gotoAndStop(nb3);
}
if (nb1==4)
{
_root.chef.gotoAndStop(nb4);
}
if (nb1==5)
{
_root.chef.gotoAndStop(nb5);
}
if (nb1==6)
{
_root.chef.gotoAndStop(nb6);
}
if (nb1==7)
{
_root.chef.gotoAndStop(nb7);
}
if (nb1==8)
{
_root.chef.gotoAndStop(nb8);
}
if (nb1==0)
{
_root.chef.gotoAndStop(nb9);
}
if (nb2==1) |
Quelqu'un aurait une idée simple pour quelqu'un qui n'ai pas encore prêt à sauté dans un concept de tiles maintenant?
Merci infiniment!