I having a problem with the flash Random. It´s not random enough. I use random to generate the position X where the enemies spawn and the type of enemy (between 5 types).
Random in Flash generate clustered values. Sometimes a lot of one type of enemy spawn. There are tricks I can use to get a more varied random results?
Ex (not the entire code):
// random function between 5 types of enemies, with different frequence
this.onEnterFrame = function()
{
_root.pE = (Math.random()*1000);
if ( ((_root.pE >30) and (_root.pE <250)) or ((_root.pE >600) and (_root.pE <750)) or ((_root.pE >800) and (_root.pE <850)))
{
_root.qI="e01p";
}
if ( ((_root.pE >250) and (_root.pE <320)) or ((_root.pE >750) and (_root.pE <800)) )
{
_root.qI="e02p";
}
if ( ((_root.pE >320) and (_root.pE <400)) or ((_root.pE >850) and (_root.pE <920)) )
{
_root.qI="e03p";
}
if ( ((_root.pE >400) and (_root.pE <450)) or ((_root.pE >950) and (_root.pE <1000)) )
{
_root.qI="e04p";
}
if ( ((_root.pE >0) and (_root.pE <30)) or ((_root.pE >920) and (_root.pE <950)) )
{
_root.qI="e05p";
}
//control how much ships are generate each time
if(_root.iTotalShips <10)
{
_root.iEnemies++;
_root.attachMovie(_root.qI, "Enemy" + _root.iEnemies, _root.getNextHighestDepth());
_root["Enemy" + _root.iEnemies]._x = 20+random((_root.horizontalspace)-60);
_root["Enemy" + _root.iEnemies]._y = -30 - (random(400));
_root.iTotalShips++;
}
[/quote]
Link for the game (not finished):
http://mcn78.sites.uol.com.br/Game1m.html