A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Help with Strategy game

Threaded View

  1. #1
    Senior Member
    Join Date
    Feb 2003
    Posts
    146

    Help with Strategy game

    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.

    Code:
    function starts () {
    	c = 2;
    	while (c<=6) {
    		num = Math.round(random(99))+1;
    		tellTarget (_root.num) {
    			gotoAndStop (_root.c);
    }
    		c = c+1;
    	}
    }
    starts();
    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.

    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:
    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();
    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.

    Any ideas?
    Last edited by Wattz; 04-27-2003 at 02:57 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center