hey, im new here
and i have a problem with Math.random()
here is part of the code:
//FIRST PLATFORM
if (P1.vy > 0 && d1 <= 0)
{
var Plt1:Platform = new Platform(stage);
Plt1.addEventListener(Event.REMOVED_FROM_STAGE,remove,false,0,true);
PFlist.push(Plt1);
stage.addChild(Plt1);
Plt1.x = Math.random() * (stage.stageWidth - Plt1.width);
d1 = Math.floor(Math.random() * rndm + rndm2);
trace (d1);
}
//SECOND PLATFORM
if (P1.vy > 0 && d2 <= 0)
{
var Plt2:Platform2 = new Platform2(stage);
Plt2.addEventListener(Event.REMOVED_FROM_STAGE,remove,false,0,true);
PF2list.push(Plt2);
stage.addChild(Plt2);
Plt2.x = Math.random() * (stage.stageWidth - Plt2.width);
d2 = Math.floor(Math.random() * rndm + rndm2);
}
//RANDOM d
d1--;
d2--;
as you can see i have Math.random twice, and 99% of the time they return the same value…