This right here is a code post. I'm gonna be going through my code from beginning to end on what I have so far. Right now this is all level editor shit. All were concerned about is building maps. No character movement or any of that other shit. So without further ado here are the first lines of codes I got:
var game:MovieClip = new MovieClip();
addChild(game);
var bgArray:Array = new Array();
var fgArray:Array = new Array();
var bgData:Array = new Array();
var limitX:Number = 10;
var limitY:Number = 8;
var limitT:Array = [[0,2],["G",13],["H",15]];
var i:Number = 0;
var j:Number = 0;
var k:Number = 0;
First we declare game, that’s the empty movieclip where all the tiles will go. addChild(game) adds the game movieclip to the stage. bgArray will hold all of the Layer 4 tile movieclips. fgArray will hold all the Layer 3 tile movieclips. Soon I’ll add Layers 2 and 1. bgData holds all the data for each layer of each tile. There is no fgData, that data will be in bgData. LimitX and LimitY are arbitrary width and height values for our stage. LimitT has to do with textures. There are two catagories,Ground, with 13 textures, and House with 15 textures. i,j, and k will be useful whenever we need some number variables to manipulate. They will be used wherever needed throughout the code.
for (i=0; i<limitY; i++) {
bgArray.push([]);
fgArray.push([]);
bgData.push([]);
for (j=0; j<limitX; j++) {
bgArray[i][j] = new T0();
bgArray[i][j].x = j * 32;
bgArray[i][j].y = i * 32;
game.addChild(bgArray[i][j]);
fgArray[i][j] = new Tclear();
fgArray[i][j].x = j * 32;
fgArray[i][j].y = i * 32;
game.addChild(fgArray[i][j]);
bgData[i].push([0,0,0,0]);
//bgData[item#,category,item#overlay,cat.overlay]
}
}
This guy builds the arrays that will house are data. With the two for functions I have created a 10×8 grid, and in each place is a bgArray movieclip, a fgMovieClip, and an array in bgData that tells us the properties of this item. Soon there will be more data per block, at the moment it just records what texture it is, which is defaulted to T0, my blank block (More on the textures in the next post!)
No comments:
Post a Comment