Advertisement
Guest User

Untitled

a guest
Sep 14th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // For simple tower defense game.
  2.  
  3. import twd;  // Use the class file twd.as
  4. var twdgame = new twd();
  5.  
  6. var wp_x;
  7. var wp_y;
  8.  
  9. _root.onLoad
  10. {
  11.     // Add the actual playing field for the game.
  12.     myBoard = _root.attachMovie("twd_board_a", "twd_board_a", 100, {_x:0, _y:0});          
  13.     // Add the life box UI component to the board.
  14.     _root.attachMovie("mo_txt_lifebox", "mo_txt_lifebox", 120, {_x:700, _y:550});              
  15.     // Add a test "tower" to the board.
  16.     _root.attachMovie("twd_tw_basic", "twd_tw_basic", 500, {_x:170, _y:200});                  
  17.  
  18.     loadWpCoords(myBoard); // Load up the critter pathpoints.
  19.    
  20. }
  21.  
  22. // Fill the Array with the appropriate X,Y waypoint coords.
  23. // This is for creep pathfinding.
  24. // Since the boards can be different, so too can these.  Should be
  25. // generated every time. (for now)
  26. function loadWpCoords(myBoard:MovieClip) {
  27.  
  28.     var myStr:String;
  29.     var wpNum:Number;
  30.     wpCount = 1;
  31.  
  32.    
  33.     // wp_start = first one
  34.     wp_x[0] = myBoard.wp_start._x;
  35.     wp_y[0] = myBoard.wp_start._y
  36.     // First goes through every object inside board
  37.     for (var mov:String in myBoard){
  38.         if (mov.substring(0, 3) == "wp_"){  // If first 3 letters match proper tag..
  39.             wpNum = int(mov.substring(3,5)); // Grab the actual number.
  40.             wp_x[wpNum] = [mov]._x;  // This line is the problem, can't reference
  41.             trace(wp_x[wpNum]);
  42.             //wp_y[wpNum] = mov._y;
  43.             wpCount++;
  44.         }
  45.     }
  46.     // wp_end = last wp, tack on at end
  47.     wp_x[wpCount] = myBoard.wp_end._x;
  48.     wp_y[wpCount] = myBoard.wp_end._y;     
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement