Guest User

Untitled

a guest
Jan 22nd, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package classes
  2. {
  3.     import net.flashpunk.*;
  4.     import net.flashpunk.graphics.*;
  5.     import net.flashpunk.masks.*;
  6.     import classes.*;
  7.    
  8.    
  9.     public class Grounds extends Entity
  10.     {
  11.        
  12.         private static const TILES:Class=Assets.TILES_LEVEL;
  13.        
  14.         /**
  15.          * Floors information.
  16.          */
  17.         public var tiles:Tilemap;
  18.         public var grid:Grid;
  19.        
  20.         public function Grounds(level:XML)
  21.         {
  22.             // set entity type
  23.             type = "solid";
  24.            
  25.             trace(level.@width+" "+level.@height);
  26.             // create and populate the tilemap from the level XML
  27.             //tiles = new Tilemap(Assets.TILES_LEVEL, 1024, 1024, 16, 16);
  28.             graphic = tiles = new Tilemap(TILES, level.@width, level.@height, 16, 16);
  29.            
  30.             for each (var tilexml:XML in level.Tiles[0].tile)
  31.             {
  32.                
  33.                 tiles.setTile(tilexml.@x/ 16 , tilexml.@y/ 16, tiles.getIndex(tilexml.@tx/ 16 , tilexml.@ty/ 16 ));
  34.             }
  35.            
  36.            
  37.             // create and populate the collision grid mask from the level XML
  38.             mask = grid = new Grid(level.@width, level.@height, 16, 16);
  39.             for each (var solid:XML in level.Grid_Ground[0].rect)
  40.             {
  41.                 grid.setRect(solid.@x / 16, solid.@y / 16, solid.@w / 16, solid.@h / 16);
  42.             }
  43.            
  44.         }
  45.        
  46.     }
  47.  
  48. }
Add Comment
Please, Sign In to add comment