core function for game not fully working
I am using code that generates words onto a map from an array. A function stops the words from being deployed in an area of a rectangle called block. However it does not work, the functions stops the player from entering but placing the words from the array seem to still deploy at random but not using the function to take consideration to the blocks...
Any help much appreciated!!
The code i am using
public function placeWords()
{
objects = new Array();
var goodObjects:Array = ["VerbObject1","VerbObject2","VerbObject3","VerbObject4",
"VerbObject5","VerbObject6","VerbObject7","VerbObject8",
"VerbObject9","VerbObject10",];
var badObjects:Array = ["NounObject1","NounObject2","NounObject3","NounObject4",
"NounObject5","NounObject6","NounObject7","NounObject8",
"NounObject9","NounObject10"];
for (var i:int=0; i<numWordObjects; i++)
{
while (true)
{
// random location
var x:Number = Math.floor(Math.random() * mapRect.width) + mapRect.x;
var y:Number = Math.floor(Math.random() * mapRect.height) + mapRect.y;
// check all blocks to see if it is over any
var isOnBlock:Boolean = false;
for (var j:int=0; j<blocks.length; j++)
{
if (blocks
{
isOnBlock = true;
break;
trace(isOnBlock);
}
}
// not over any, so use location
if (!isOnBlock)
{
if (Math.random() < .5)
{
var r:int = Math.floor(Math.random() * goodObjects.length);
var classRef:Class = getDefinitionByName(goodObjects
var newObject:MovieClip = new classRef();
newObject.typestr = "good";
}
else
{
r = Math.floor(Math.random() * badObjects.length);
classRef = getDefinitionByName(badObjects
newObject = new classRef();
newObject.typestr = "bad";
}
newObject.x = Math.floor(Math.random() * mapRect.width) + mapRect.x;
newObject.y = Math.floor(Math.random() * mapRect.height) + mapRect.y;
gamesprite.addChild(newObject);
objects.push(newObject);
break;
trace(gamesprite.stage);
trace(objects);
}
}
}
}