Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function levelToString() {
- var string="";
- for (var i = 0; i < level.length; i++) {
- for (var j = 0; j < level[i].length; j++) {
- string+=level[i][j].toString();
- if (j!=level[i].length-1) {
- string+=",";
- }
- }
- if (i!=level.length-1) {
- string+="|";
- }
- }
- codeBox.codeText.text=string;
- }
- function stringToLevel) {
- var mySTR=codeBox.codeText.text;
- var myARR=mySTR.split("|");
- for (var i in myARR) {
- myARR[i]=myARR[i].split(",");
- }
- for (var x in myARR) {
- for (var y in myARR[x]) {
- myARR[x][y]=int(myARR[x][y]);
- }
- }
- level=myARR; // level is the 2DArray
- //places the tiles.
- for (var row:Number = 0; row<level.length; row++) {
- for (var column:Number = 0; column<level[row].length; column++) {
- if (level[row][column]==1) {
- placeTileType(column-1, row-1, "ground", true, true);
- }
- if (level[row][column]==2) {
- placeTileType(column-1, row-1, "bouncy", true, true);
- }
- if (level[row][column]==3) {
- placeTileType(column-1, row-1, "spike", true, true);
- }
- if (level[row][column]==4) {
- placeTileType(column-1, row-1, "left", true, true);
- }
- if (level[row][column]==5) {
- placeTileType(column-1, row-1, "right", true, true);
- }
- if (level[row][column]==6) {
- placeTileType(column-1, row-1, "start", true, true);
- }
- if (level[row][column]==7) {
- placeTileType(column-1, row-1, "end", true, true);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement