Hi! Im new with actionscript and wanders whats wrong with this code…I want “unit” to start at a random place where the value is 0 I have got it to work so it starts at a random place but sometimes on 1… this code dont work! But i hope it shows what i want to do.
map = [
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
,1,1,1],
[1,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
,0,0,1],
[1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,1,1,1,0,0,0
,0,0,1],
[1,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0
,1,0,1],
[1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0
,0,0,1],
[1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0
,0,0,1],
[1,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,1,1,1
,0,0,1],
[1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0
,0,0,1],
[1,0,0,1,0,0,0,1,0,1,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0
,0,0,1],
[1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0
,0,1,1],
[1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,0,1,0,0,1,0,0
,0,0,1],
[1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,1,0,0,0,0
,1,0,1],
[1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0,1,0
,1,0,1],
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
,1,1,1]
];
// x,y
mappos = false;
for ( mappos = true ); {
unitxpos = Math.round(Math.random()(2-27))+27;
unitypos = Math.round(Math.random()(2-13))+13;
unit = [[unitxpos,unitypos]];
if ( map[unit] == 0 ); {
mappos = true;
}
(Sorry for the poor english)