changed arr to a pixel property
This commit is contained in:
parent
8ca548910c
commit
ae9d234bee
|
|
@ -1,8 +1,9 @@
|
|||
elements.room = {
|
||||
name: "Room",
|
||||
color: "#ffffff",
|
||||
arr: [],
|
||||
tick: function(pixel) {
|
||||
arr =[["brick", "brick", "brick", "brick", "brick", "brick", "brick", "glass", "glass", "glass", "glass", "glass", "brick", "brick", "brick", "brick", "brick", "brick", "brick"],
|
||||
pixel.arr=[["brick", "brick", "brick", "brick", "brick", "brick", "brick", "glass", "glass", "glass", "glass", "glass", "brick", "brick", "brick", "brick", "brick", "brick", "brick"],
|
||||
["brick", "brick", "brick", "brick", "brick", "brick", "brick", "glass", "glass", "glass", "glass", "glass", "brick", "battery","brick", "brick", "brick", "brick", "brick"],
|
||||
["glass", "glass", "air", "air", "air", "air", "air", "air", "air", "air", "air", "air", "light","light_bulb","air", "air", "air", "glass", "glass"],
|
||||
["glass", "glass", "light", "light", "air", "air", "air", "air", "air", "air", "air", "air", "air", "light", "air", "air", "air", "glass", "glass"],
|
||||
|
|
@ -15,37 +16,37 @@ elements.room = {
|
|||
["brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick"],
|
||||
["brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick"]]
|
||||
|
||||
/*arr = [["brick","brick","brick","brick","brick"], //(Test Array)
|
||||
/*pixel.arr = [["brick","brick","brick","brick","brick"], //(Test pixel.array)
|
||||
["brick","air", "iron", "air", "brick"],
|
||||
["brick","iron", "air", "iron", "brick"],
|
||||
["brick","air", "air", "air", "brick"],
|
||||
["brick","brick","brick","brick","brick"]]*/
|
||||
|
||||
aa = (0 - (Math.floor(arr[0].length / 2)))
|
||||
aa = (0 - (Math.floor(pixel.arr[0].length / 2)))
|
||||
na = Math.abs(aa)
|
||||
if(arr[0].length % 2 == 1) {
|
||||
bb = ((Math.floor(arr[0].length / 2)) + 1)
|
||||
} else if(arr[0].length % 2 == 0) {
|
||||
bb = (Math.floor(arr[0].length / 2))
|
||||
if(pixel.arr[0].length % 2 == 1) {
|
||||
bb = ((Math.floor(pixel.arr[0].length / 2)) + 1)
|
||||
} else if(pixel.arr[0].length % 2 == 0) {
|
||||
bb = (Math.floor(pixel.arr[0].length / 2))
|
||||
}
|
||||
|
||||
cc = (0 - (Math.floor(arr.length / 2)))
|
||||
cc = (0 - (Math.floor(pixel.arr.length / 2)))
|
||||
nc = Math.abs(cc)
|
||||
if(arr.length % 2 == 1) {
|
||||
dd = ((Math.floor(arr.length / 2)) + 1)
|
||||
} else if(arr.length % 2 == 0) {
|
||||
dd = (Math.floor(arr.length / 2))
|
||||
if(pixel.arr.length % 2 == 1) {
|
||||
dd = ((Math.floor(pixel.arr.length / 2)) + 1)
|
||||
} else if(pixel.arr.length % 2 == 0) {
|
||||
dd = (Math.floor(pixel.arr.length / 2))
|
||||
}
|
||||
for (let j = cc; j < dd; j++) {
|
||||
for (let i = aa; i < bb; i++) {
|
||||
if(!isEmpty(pixel.x+i,pixel.y+j) && !outOfBounds(pixel.x+i,pixel.y+j)) {
|
||||
if(arr[j+nc][i+na] != "null" || arr[j+nc][i+na] == "air") {
|
||||
if(pixel.arr[j+nc][i+na] != "null" || pixel.arr[j+nc][i+na] == "air") {
|
||||
deletePixel(pixel.x+i,pixel.y+j)
|
||||
}
|
||||
}
|
||||
if(arr[j+nc][i+na]) {
|
||||
if(isEmpty(pixel.x+i,pixel.y+j) && arr[j+nc][i+na] != "null" && arr[j+nc][i+na] != "air" && !outOfBounds(pixel.x+i,pixel.y+j)) {
|
||||
createPixel(arr[j+nc][i+na],pixel.x+i,pixel.y+j)
|
||||
if(pixel.arr[j+nc][i+na]) {
|
||||
if(isEmpty(pixel.x+i,pixel.y+j) && pixel.arr[j+nc][i+na] != "null" && pixel.arr[j+nc][i+na] != "air" && !outOfBounds(pixel.x+i,pixel.y+j)) {
|
||||
createPixel(pixel.arr[j+nc][i+na],pixel.x+i,pixel.y+j)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue