Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package
- {
- import net.flashpunk.World;
- import net.flashpunk.utils.Input;
- import net.flashpunk.FP;
- public class GameWorld extends World
- {
- //Current X on the grid
- public var xInt:uint = 0;
- //current Y on the grid
- public var yInt:uint = 0;
- //pixel coordinates on screen
- public var pixelX:uint = 1;
- public var pixelY:uint = 1;
- //current layer of map build
- public var layerInt:uint = 20;
- //tile that's being built
- public var currentTile:uint = 0;
- //current Z value in the heightmap
- public var currentHeight:uint = 1;
- //the lowest known height of each tile in the immediate vicinity of the current tile
- public var lowestHeightNear:uint = 0;
- //used to assign layers to tiles spawned under others to fill gaps
- public var layerPlaceholder:Number;
- //Build the tilemap
- public var a01Row:Array = [07, 08, 09, 10, 11, 12, 11, 07, 07, 07, 07, 08, 09, 10, 11, 08, 08, 09, 10, 08];
- public var a02Row:Array = [07, 08, 09, 10, 11, 11, 11, 07, 07, 07, 07, 08, 09, 10, 11, 08, 08, 09, 10, 08];
- public var a03Row:Array = [07, 08, 09, 10, 11, 11, 11, 07, 07, 07, 07, 08, 09, 10, 11, 08, 08, 09, 10, 08];
- public var a04Row:Array = [09, 08, 09, 10, 11, 11, 11, 07, 07, 07, 07, 08, 09, 10, 11, 08, 08, 09, 10, 08];
- public var a05Row:Array = [09, 08, 09, 10, 11, 12, 11, 07, 07, 07, 07, 08, 09, 10, 11, 08, 08, 09, 10, 08];
- public var a06Row:Array = [09, 08, 09, 10, 11, 12, 11, 07, 07, 07, 07, 08, 09, 10, 11, 08, 08, 09, 10, 08];
- public var a07Row:Array = [08, 08, 09, 10, 11, 11, 11, 08, 07, 08, 08, 08, 09, 10, 11, 08, 08, 09, 10, 08];
- public var a08Row:Array = [08, 08, 09, 10, 11, 12, 11, 07, 07, 07, 07, 08, 09, 10, 11, 08, 08, 09, 10, 08];
- public var a09Row:Array = [07, 08, 09, 07, 11, 12, 11, 07, 07, 07, 07, 08, 09, 10, 11, 08, 08, 09, 10, 08];
- public var a10Row:Array = [07, 08, 09, 10, 11, 12, 11, 07, 07, 09, 07, 08, 09, 12, 11, 08, 08, 09, 10, 08];
- public var a11Row:Array = [07, 08, 09, 10, 11, 12, 11, 07, 07, 07, 09, 08, 09, 10, 11, 08, 08, 09, 10, 08];
- public var a12Row:Array = [08, 09, 09, 10, 11, 12, 11, 08, 07, 07, 07, 08, 09, 10, 11, 08, 08, 09, 10, 08];
- public var a13Row:Array = [08, 08, 09, 07, 11, 12, 11, 07, 07, 07, 07, 08, 09, 10, 11, 08, 08, 09, 10, 08];
- public var a14Row:Array = [08, 08, 09, 10, 11, 12, 11, 07, 07, 10, 09, 08, 09, 10, 11, 08, 08, 09, 10, 08];
- public var a15Row:Array = [08, 08, 09, 10, 11, 12, 11, 07, 07, 07, 07, 08, 12, 10, 11, 08, 08, 09, 10, 08];
- public var a16Row:Array = [07, 08, 09, 10, 11, 12, 10, 08, 10, 07, 07, 08, 09, 10, 11, 08, 08, 09, 10, 08];
- public var a17Row:Array = [07, 08, 09, 10, 11, 12, 11, 07, 09, 07, 07, 08, 09, 10, 11, 08, 08, 09, 10, 08];
- public var a18Row:Array = [07, 08, 09, 10, 11, 12, 11, 07, 07, 07, 07, 08, 09, 10, 11, 08, 08, 09, 10, 08];
- public var a19Row:Array = [08, 08, 09, 07, 10, 12, 11, 07, 07, 07, 07, 08, 09, 10, 11, 08, 08, 09, 10, 08];
- public var a20Row:Array = [08, 08, 09, 10, 11, 12, 11, 07, 07, 07, 07, 08, 09, 10, 11, 08, 08, 09, 10, 08];
- public var map1Array:Array = [a01Row, a02Row, a03Row, a04Row, a05Row, a06Row, a07Row, a08Row, a09Row, a10Row, a11Row, a12Row, a13Row, a14Row, a15Row, a16Row, a17Row, a18Row, a19Row, a20Row];
- //Build the height map
- public var h01Row:Array = [01, 01, 02, 09, 03, 03, 04, 04, 05, 05, 06, 06, 07, 07, 08, 08, 09, 09, 10, 10];
- public var h02Row:Array = [01, 01, 02, 02, 03, 03, 04, 04, 05, 05, 06, 06, 07, 07, 08, 08, 09, 09, 10, 10];
- public var h03Row:Array = [01, 01, 02, 02, 03, 03, 04, 04, 05, 05, 06, 06, 07, 07, 08, 08, 09, 09, 10, 10];
- public var h04Row:Array = [01, 01, 02, 02, 03, 03, 04, 04, 05, 05, 06, 06, 07, 07, 08, 08, 09, 09, 10, 10];
- public var h05Row:Array = [01, 01, 02, 02, 03, 03, 04, 04, 05, 05, 06, 06, 07, 07, 08, 08, 09, 09, 10, 10];
- public var h06Row:Array = [01, 01, 02, 02, 03, 03, 04, 04, 05, 05, 06, 06, 07, 07, 08, 08, 09, 09, 10, 10];
- public var h07Row:Array = [01, 01, 02, 02, 03, 03, 04, 04, 05, 05, 06, 06, 07, 07, 08, 08, 09, 09, 10, 10];
- public var h08Row:Array = [01, 01, 02, 02, 03, 03, 04, 04, 05, 05, 06, 06, 07, 07, 08, 08, 09, 09, 10, 10];
- public var h09Row:Array = [01, 01, 02, 02, 03, 03, 04, 04, 05, 05, 06, 06, 07, 07, 08, 08, 09, 09, 10, 10];
- public var h10Row:Array = [01, 01, 02, 02, 03, 03, 04, 04, 05, 05, 06, 06, 07, 07, 08, 08, 09, 09, 10, 10];
- public var h11Row:Array = [01, 01, 02, 02, 03, 03, 04, 04, 05, 05, 06, 06, 07, 07, 08, 08, 09, 09, 10, 10];
- public var h12Row:Array = [01, 01, 02, 02, 03, 03, 04, 04, 05, 05, 06, 06, 07, 07, 08, 08, 09, 09, 10, 10];
- public var h13Row:Array = [01, 01, 02, 02, 03, 03, 04, 04, 05, 05, 06, 06, 07, 07, 08, 08, 09, 09, 10, 10];
- public var h14Row:Array = [01, 01, 02, 02, 03, 03, 04, 04, 05, 05, 06, 06, 07, 07, 08, 08, 09, 09, 10, 10];
- public var h15Row:Array = [01, 01, 02, 02, 03, 03, 04, 04, 05, 05, 06, 06, 07, 07, 08, 08, 09, 09, 10, 10];
- public var h16Row:Array = [01, 01, 02, 02, 03, 03, 04, 04, 05, 05, 06, 06, 07, 07, 08, 08, 09, 09, 10, 10];
- public var h17Row:Array = [01, 01, 02, 02, 03, 03, 04, 04, 05, 05, 06, 06, 07, 07, 08, 08, 09, 09, 10, 10];
- public var h18Row:Array = [01, 01, 02, 02, 03, 03, 04, 04, 05, 05, 06, 06, 07, 07, 08, 08, 09, 09, 10, 10];
- public var h19Row:Array = [01, 01, 02, 02, 03, 03, 04, 04, 05, 05, 06, 06, 07, 07, 08, 08, 09, 09, 10, 10];
- public var h20Row:Array = [01, 01, 02, 02, 03, 03, 04, 04, 05, 05, 06, 06, 07, 07, 08, 08, 09, 09, 10, 10];
- public var height1Array:Array = [h01Row, h02Row, h03Row, h04Row, h05Row, h06Row, h07Row, h08Row, h09Row, h10Row, h11Row, h12Row, h13Row, h14Row, h15Row, h16Row, h17Row, h18Row, h19Row, h20Row];
- public function GameWorld()
- {
- add(new TileSetTest);
- for (var i:int = 0; i < 400; i++)
- {
- layerInt++;
- if (xInt > 19)
- {
- xInt -= 20;
- yInt++;
- layerInt -= 21;
- }
- currentTile = map1Array[yInt][xInt];
- currentHeight = height1Array[yInt][xInt];
- // 0 = the X offset in this equasion, necessary for different sized objects
- pixelX = 0 + ((xInt * 22) + (yInt * 22));
- // 343 = the Y offset in this equasion, necessary for different sized objects
- pixelY = 343 - ((xInt * 11) - (yInt * 11));
- pixelY = (pixelY -= (currentHeight * 11));
- add(new TileEntity(pixelX, pixelY, layerInt, currentTile));
- layerPlaceholder = layerInt;
- if (!xInt == 0)
- {
- if (height1Array[yInt][(xInt - 1)] < height1Array[yInt][xInt])
- {
- lowestHeightNear = height1Array[yInt][xInt - 1];
- for (var j:int = 0; j < 9; j++)
- {
- if (lowestHeightNear < currentHeight)
- {
- currentHeight --;
- layerPlaceholder ++;
- pixelY = (343 - ((xInt * 11) - (yInt * 11)));
- pixelY = (pixelY -= (currentHeight * 11));
- add(new TileEntity(pixelX, pixelY, layerPlaceholder, currentTile));
- }
- }
- }
- }
- if (!xInt == 16)
- {
- trace("butts");
- }
- xInt++;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement