I'm trying to make a strategy game where you build up an empire and army and all that and try to win the whole map. So I have the map and the players set up and everything, but what I need to do is have an initial city placed on each of the player's first territories.
There are 100 territories set up in a grid. I then use this code to pick and place the 5 players on random starting spots.
c is the frame number of the territory MC. The MC has 6 total, 1 is blank for nuetral territory, and the other 5 are different colors to represent different players. So c starts at 2 because it's the first player color.Code:function starts () { c = 2; while (c<=6) { num = Math.round(random(99))+1; tellTarget (_root.num) { gotoAndStop (_root.c); } c = c+1; } } starts();
num picks the random territory to place the player on. So now I want to place the player's capital city on their first territory so that the game can start. And I tried this:
But this doesn't work. I use +20 on both of them because each territory is 40 pixels wide, and this would place the city in the middle of territory. _root.basecity is the MC of the city that I placed off the side of the stage in order to duplicate it. I guess I could have linked it in library instead, but oh well.Code:function starts () { c = 2; while (c<=6) { num = Math.round(random(99))+1; tellTarget (_root.num) { gotoAndStop (_root.c); duplicateMovieClip (_root.basecity, _root.city[c][num], c); _root.city[c][num]._x = _root[num]._x + 20; _root.city[c][num]._y = _root[num]._y + 20; } c = c+1; } } starts();
Any ideas?




Reply With Quote