Wow. This is out of the blue. Very old post. try changing the mindist variable
Printable View
Wow. This is out of the blue. Very old post. try changing the mindist variable
Changing minDist to something big like 400 works for the first couple of words but then seems to set itself to something smaller...
Here is your function:
function positionLetter(target) {
while (true) {
target._x = random(Stage.width-target._width);
target._y = random(Stage.height-target._height);
Can you please comment the lines below?
if (Math.pow(alphabetipede_mc._x-target._x, 2)+Math.pow(alphabetipede_mc._y-target._y, 2)>minDist*minDist) {
As I see it this works for the first two words but then it seems to give up and place letters anywhere. If you help by commenting the above I can see where it goes wrong and perhaps write my own code.
Cheers for not gving up on me.
My previous code was to make sure that the stuff doesn't get placed next to each other. If it doesn't matter than it will make things simpler.
Cheers Dude... `i appreciate the pointers... You wrote the code so you're the only one who can help with this last bit
This is what I need to say in the position letter function
if ( target._x > guy._x - 100 ||
target._y > guy._y + 100 ||
target._y > guy._x - 100 ||
target._y > guy._y + 100 ) {
break loop to place random letters}
so what I am trying to do is draw an invisible box around guy so the letters are not placed too close to him as it is too easy to die when the new word is started and random letters placed on screen.
Can you tell me where to place the above code in the position letter function? when I try it messes the whole game up and causes the flash player to run slowly...
function positionLetter(target) {
while (true) {
target._x = random(Stage.width-target._width);
target._y = random(Stage.height-target._height);
if (Math.pow(alphabetipede_mc._x-target._x, 2)+Math.pow(alphabetipede_mc._y-target._y, 2)>minDist*minDist) {
var tBool:Boolean = true;
for (m=0; m<onStageLetterArray.length; m++) {
if (onStageLetterArray[m] == target) {
continue;
}
if (Math.pow(onStageLetterArray[m]._x-target._x, 2)+Math.pow(onStageLetterArray[m]._y-target._y, 2)<Math.pow(target._height, 2)) {
tBool = false;
break;
}
}
if (tBool) {
break;
}
}
}
}
Sorry to bug you dude but I imagine you'll be famous soon as this thread has had over 550 hits...
The problem is you are continually having more areas that you can't place anything. I just thought of a good idea that should work. Instead of randomly placing somewhere on the screen then moving it again if the guy's there. Generate a random number and use this to determine what quadrant of the screen it will get placed. The four quadrants would be above below left and right of the player. You basically can place the clips in between the player and the side of the screen.
This method would be a lot more efficient because you would only need to check the movieclips against other clips and not the player.