hey, probably a really simple error, but here goes…
I am making a game, called manior impossible (a rip of mansion impossible, pretty much). In it, I need random spawning houses. So I have set up an array to keep track of where they are, and I have set out a random number to choose where it goes.
However, everytime it makes a house, it replaces the last one, and I have no idea why!
Here is the code:
//to make a house appear
function houseAppear() {
houseInt = setInterval(house, (random(15)+15)*500);
function house() {
//whichH = random(3)+1
whichH = 1;
switch (whichH){
case 1:
houseid = random(shouse.length);
if (shouse[houseid][2] == "1"){
trace("this spot is actually taken");
}else{
trace("small at "+shouse[houseid][0]+","+shouse[houseid][1]+" of ID mc_house"+houseid);
shouse[houseid][2] = "1";
attachMovie("mc_shouse", ("mc_shouse"+houseid), (this._x + this._y*450), {_x:shouse[houseid][0], _y:shouse[houseid][1]});
}
break;
case 2:
trace("m");
break;
case 3:
trace("l");
break;
}
}
}
as you can see, there will be 3 types of hosues, but I am just made it so that only one appears for now. I apologise for the horrible coding!
here is the fla if you need it too:
http://munkydesigns.co.uk/game.fla
cheers if anyone can shed some light on this!