This commit is contained in:
parent
5b9950aa23
commit
9d369de6e2
|
|
@ -591,7 +591,7 @@ let channelVar = "0"
|
||||||
elements.sculk_wifi_transmitter = {
|
elements.sculk_wifi_transmitter = {
|
||||||
color: "#142c47",
|
color: "#142c47",
|
||||||
category: "minecraft",
|
category: "minecraft",
|
||||||
behaviors: behaviors.WALL,
|
behavior: behaviors.WALL,
|
||||||
tempHigh: 250,
|
tempHigh: 250,
|
||||||
stateHigh: "dirt",
|
stateHigh: "dirt",
|
||||||
hoverStat: function(pixel){
|
hoverStat: function(pixel){
|
||||||
|
|
@ -643,4 +643,164 @@ elements.sculk_wifi_receiver = {
|
||||||
tick: function(pixel){
|
tick: function(pixel){
|
||||||
if (!pixel.channel){pixel.channel = channelVar}
|
if (!pixel.channel){pixel.channel = channelVar}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
drawRectangle = function(ctx, color, x, y, width, height, xoffset, yoffset){
|
||||||
|
ctx.fillStyle = color;
|
||||||
|
ctx.fillRect(canvasCoord(x+xoffset), canvasCoord(y+yoffset), pixelSize*width, pixelSize*height)
|
||||||
|
}
|
||||||
|
autoFillDrawRectangle = function(ctx, pixel, width, height, xoffset, yoffset){
|
||||||
|
ctx.fillStyle = pixel.color;
|
||||||
|
ctx.fillRect(canvasCoord(pixel.x+xoffset), canvasCoord(pixel.y+yoffset), pixelSize*width, pixelSize*height)
|
||||||
|
}
|
||||||
|
autoFillColorRectangle = function(ctx, pixel, color, width, height, xoffset, yoffset){
|
||||||
|
ctx.fillStyle = color;
|
||||||
|
ctx.fillRect(canvasCoord(pixel.x+xoffset), canvasCoord(pixel.y+yoffset), pixelSize*width, pixelSize*height)
|
||||||
|
}
|
||||||
|
grabDistances = function(pixel){
|
||||||
|
let element = pixel.element
|
||||||
|
// first we find upper not the same
|
||||||
|
let results = {}
|
||||||
|
for (let i = 0; i < height; i++){
|
||||||
|
if (isEmpty(pixel.x, pixel.y-i, true) || pixelMap[pixel.x][pixel.y-i].element != element){
|
||||||
|
results.top = i
|
||||||
|
if (isEmpty(pixel.x, pixel.y-i, true)){
|
||||||
|
results.topelement = "air"
|
||||||
|
} else {
|
||||||
|
results.topelement = pixelMap[pixel.x][pixel.y-i].element
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// now bottom not same
|
||||||
|
for (let i = 0; i < height; i++){
|
||||||
|
if (isEmpty(pixel.x, pixel.y+i, true) || pixelMap[pixel.x][pixel.y + i].element != element){
|
||||||
|
results.bottom = i
|
||||||
|
if (isEmpty(pixel.x, pixel.y+i, true)){
|
||||||
|
results.bottomelement = "air"
|
||||||
|
} else {
|
||||||
|
results.bottomelement = pixelMap[pixel.x][pixel.y + i].element
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return results
|
||||||
|
}
|
||||||
|
elements.dripstone_spike = {
|
||||||
|
color: "#927965",
|
||||||
|
category: "minecraft",
|
||||||
|
behavior: behaviors.WALL,
|
||||||
|
tempHigh: 1810,
|
||||||
|
stateHigh: "molten_dripstone",
|
||||||
|
density: 2550,
|
||||||
|
renderer: function(pixel, ctx){
|
||||||
|
if (pixel.spikeType == 1){
|
||||||
|
autoFillDrawRectangle(ctx, pixel, 1, 1/3, 0, 0)
|
||||||
|
autoFillDrawRectangle(ctx, pixel, 2/3, 1, 1/6, 0)}
|
||||||
|
else if (pixel.spikeType == 2){
|
||||||
|
autoFillDrawRectangle(ctx, pixel, 2/3, 1, 1/6, 0)
|
||||||
|
}
|
||||||
|
else if (pixel.spikeType == 3){
|
||||||
|
autoFillDrawRectangle(ctx, pixel, 2/3, 5/6, 1/6, 0)
|
||||||
|
autoFillDrawRectangle(ctx, pixel, 0.5, 1/3, 1/3, 2/3)
|
||||||
|
}
|
||||||
|
else if (pixel.spikeType == 4){
|
||||||
|
autoFillDrawRectangle(ctx, pixel, 0.5, 1/3, 1/3, 0)
|
||||||
|
autoFillDrawRectangle(ctx, pixel, 1/3, 1/3, 1/3, 1/6)
|
||||||
|
autoFillDrawRectangle(ctx, pixel, 1/6, 0.5, 1/3, 1/3)
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
drawSquare(ctx, pixel.color, pixel.x, pixel.y)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
tick: function(pixel){
|
||||||
|
let distance = grabDistances(pixel);
|
||||||
|
if (distance.bottom == 1)
|
||||||
|
{pixel.spikeType = 4}
|
||||||
|
else if (distance.bottom == 2)
|
||||||
|
{pixel.spikeType = 3}
|
||||||
|
else if (distance.bottom >= 3 && distance.top > 1)
|
||||||
|
{pixel.spikeType = 2}
|
||||||
|
else
|
||||||
|
{pixel.spikeType = 1}
|
||||||
|
if (!pixel.spikeType){console.log(distance)}
|
||||||
|
if (distance.topelement == "air" && distance.top == 1){
|
||||||
|
// make the entire spike fall
|
||||||
|
let fallList = []
|
||||||
|
for (let i = 0; i < height; i++){
|
||||||
|
if (!isEmpty(pixel.x, pixel.y+i, true) && pixelMap[pixel.x][pixel.y+i].element == "dripstone_spike"){
|
||||||
|
fallList.push(pixelMap[pixel.x][pixel.y+i])
|
||||||
|
} else {break}
|
||||||
|
}
|
||||||
|
fallList = fallList.reverse();
|
||||||
|
for (let i = 0; i<fallList.length;i++){
|
||||||
|
if (!tryMove(fallList[i], fallList[i].x, fallList[i].y+1)){
|
||||||
|
deletePixel(fallList[i].x, fallList[i].y)
|
||||||
|
if(!isEmpty(fallList[i].x, fallList[i].y+1, true)){
|
||||||
|
breakPixel(pixelMap[fallList[i].x][fallList[i].y+1])
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elements.dripstone = {
|
||||||
|
color: "#927965",
|
||||||
|
category: "minecraft",
|
||||||
|
behavior: behaviors.WALL,
|
||||||
|
tempHigh: 1810,
|
||||||
|
stateHigh: "molten_dripstone",
|
||||||
|
density: 2550
|
||||||
|
}
|
||||||
|
elements.molten_dripstone = {
|
||||||
|
color: ['#ff7b00', '#ff8d2d', '#ff9d4a', '#ffad65', '#ffbc80'],
|
||||||
|
category: "minecraft",
|
||||||
|
behavior: behaviors.MOLTEN,
|
||||||
|
tempLow: 1800,
|
||||||
|
stateLow: "dripstone",
|
||||||
|
temp: 1850,
|
||||||
|
density: 2500,
|
||||||
|
state: "liquid",
|
||||||
|
viscosity: 2000
|
||||||
|
}
|
||||||
|
elements.obsidian = { //subject to change
|
||||||
|
color: "#06030B",
|
||||||
|
category: "minecraft",
|
||||||
|
behavior: behaviors.WALL,
|
||||||
|
tempHigh: 1750,
|
||||||
|
stateHigh: "molten_obsidian",
|
||||||
|
density: 2400,
|
||||||
|
renderer: function(pixel, ctx){
|
||||||
|
autoFillColorRectangle(ctx, pixel, "#06030B", 1, 1, 0, 0)
|
||||||
|
autoFillColorRectangle(ctx, pixel, "#000001", 0.5, 1/6, 0, 0)
|
||||||
|
autoFillColorRectangle(ctx, pixel, "#000001", 1/6, 1/6, 1/6, 5/6)
|
||||||
|
autoFillColorRectangle(ctx, pixel, "#000001", 1/6, 1/6, 5/6, 2/3)
|
||||||
|
autoFillColorRectangle(ctx, pixel, "#100C1C", 1/6, 1/6, 0, 5/6)
|
||||||
|
autoFillColorRectangle(ctx, pixel, "#100C1C", 1/3, 1/5, 1/6, 0.5)
|
||||||
|
autoFillColorRectangle(ctx, pixel, "#100C1C", 1/6, 1/3, 1/3, 1/3)
|
||||||
|
autoFillColorRectangle(ctx, pixel, "#100C1C", 1/6, 1/6, 2/3, 0)
|
||||||
|
autoFillColorRectangle(ctx, pixel, "#100C1C", 1/6, 0.5, 2/3, 0.5)
|
||||||
|
autoFillColorRectangle(ctx, pixel, "#100C1C", 1/3, 1/6, 2/3, 0.5)
|
||||||
|
autoFillColorRectangle(ctx, pixel, "#100C1C", 1/3, 1/6, 0.5, 5/6)
|
||||||
|
autoFillColorRectangle(ctx, pixel, "#271E3D", 1/6, 1/6, 0, 2/3)
|
||||||
|
autoFillColorRectangle(ctx, pixel, "#271E3D", 1/6, 1/6, 1/6, 1/3)
|
||||||
|
autoFillColorRectangle(ctx, pixel, "#271E3D", 1/6, 1/6, 0.5, 0)
|
||||||
|
autoFillColorRectangle(ctx, pixel, "#271E3D", 1/6, 1/6, 5/6, 1/3)
|
||||||
|
autoFillColorRectangle(ctx, pixel, "#271E3D", 1/6, 1/6, 1/3, 5/6)
|
||||||
|
autoFillColorRectangle(ctx, pixel, "#3B2754", 1/6, 1/6, 0, 1/3)
|
||||||
|
autoFillColorRectangle(ctx, pixel, "#3B2754", 1/6, 1/6, 1/6, 1/6)
|
||||||
|
autoFillColorRectangle(ctx, pixel, "#3B2754", 1/3, 1/6, 1/3, 2/3)
|
||||||
|
autoFillColorRectangle(ctx, pixel, "#3B2754", 1/6, 1/6, 2/3, 1/3)
|
||||||
|
autoFillColorRectangle(ctx, pixel, "#3B2754", 1/6, 1/6, 5/6, 1/6)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elements.molten_obsidian = {
|
||||||
|
color: ['#ff7700', '#df6004', '#bf4905', '#9f3404', '#802000'],
|
||||||
|
category: "minecraft",
|
||||||
|
behavior: behaviors.MOLTEN,
|
||||||
|
tempLow: 1740,
|
||||||
|
stateLow: "obsidian",
|
||||||
|
temp: 1850,
|
||||||
|
density: 2300,
|
||||||
|
viscosity: 5000
|
||||||
}
|
}
|
||||||
|
|
@ -431,7 +431,7 @@ elements.destroyable_superheater = {
|
||||||
category:"machines",
|
category:"machines",
|
||||||
stateLow:["iron","copper"],
|
stateLow:["iron","copper"],
|
||||||
tempLow: -7,
|
tempLow: -7,
|
||||||
breakInto:["metal_scrap","oxidixed_copper"],
|
breakInto:["metal_scrap","oxidized_copper"],
|
||||||
},
|
},
|
||||||
elements.destroyable_heater = {
|
elements.destroyable_heater = {
|
||||||
color: "#881111",
|
color: "#881111",
|
||||||
|
|
@ -443,7 +443,7 @@ elements.destroyable_heater = {
|
||||||
category:"machines",
|
category:"machines",
|
||||||
stateLow:["iron","copper"],
|
stateLow:["iron","copper"],
|
||||||
tempLow: -7,
|
tempLow: -7,
|
||||||
breakInto:["metal_scrap","oxidixed_copper"],
|
breakInto:["metal_scrap","oxidized_copper"],
|
||||||
},
|
},
|
||||||
elements.destroyable_cooler = {
|
elements.destroyable_cooler = {
|
||||||
color: "#111188",
|
color: "#111188",
|
||||||
|
|
@ -455,7 +455,7 @@ elements.destroyable_cooler = {
|
||||||
category:"machines",
|
category:"machines",
|
||||||
stateHigh:["iron","copper"],
|
stateHigh:["iron","copper"],
|
||||||
tempHigh: 49,
|
tempHigh: 49,
|
||||||
breakInto:["metal_scrap","oxidixed_copper"],
|
breakInto:["metal_scrap","oxidized_copper"],
|
||||||
},
|
},
|
||||||
elements.destroyable_freezer = {
|
elements.destroyable_freezer = {
|
||||||
color: "#1111dd",
|
color: "#1111dd",
|
||||||
|
|
@ -2596,6 +2596,27 @@ elements.scuffed_circle_brush = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
elements.scuffed_triangle_brush = {
|
||||||
|
category: "special",
|
||||||
|
color: elements.drag.color,
|
||||||
|
excludeRandom: true,
|
||||||
|
state: "solid",
|
||||||
|
movable: false,
|
||||||
|
onSelect: function(){
|
||||||
|
var answerE = prompt("Element of the brush.",(circleElem||undefined));
|
||||||
|
if (!answerE) { return }
|
||||||
|
circleElem = mostSimilarElement(answerE);
|
||||||
|
},
|
||||||
|
tick: function(pixel){
|
||||||
|
let radius = mouseSize/2
|
||||||
|
if ((pixel.y - mousePos.y + mouseSize > 2 * (pixel.x - mousePos.x) + 0.5 * mouseSize) && (pixel.y - mousePos.y + mouseSize > -2 * (pixel.x - mousePos.x) + 0.5 * mouseSize)) {
|
||||||
|
deletePixel(pixel.x, pixel.y)
|
||||||
|
createPixel(circleElem, pixel.x, pixel.y)
|
||||||
|
} else {
|
||||||
|
deletePixel(pixel.x, pixel.y)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
function randomIntFromInterval(min, max) { // min and max included
|
function randomIntFromInterval(min, max) { // min and max included
|
||||||
return Math.floor(Math.random() * (max - min + 1) + min)
|
return Math.floor(Math.random() * (max - min + 1) + min)
|
||||||
}
|
}
|
||||||
|
|
@ -3098,6 +3119,36 @@ let pistonStart = 0
|
||||||
let pistonEnd = 0
|
let pistonEnd = 0
|
||||||
let pistonDistance = 1
|
let pistonDistance = 1
|
||||||
let pistonCooldown = 10
|
let pistonCooldown = 10
|
||||||
|
let pistonRepeat = 1
|
||||||
|
let pistonRepeatCooldown = 1
|
||||||
|
function pistonEmit(pixel, i){
|
||||||
|
pixel.cooldown = pixel.pistonCooldown
|
||||||
|
pixel.rcooldown = pixel.pistonRepeatCooldown
|
||||||
|
var dir = [0-squareCoords[i][0], 0-squareCoords[i][1]]
|
||||||
|
var startx = pixel.x+(dir[0]*(pixel.pistonStart+1))
|
||||||
|
var starty = pixel.y+(dir[1]*(pixel.pistonStart+1))
|
||||||
|
var magnitude = pixel.pistonEnd
|
||||||
|
var endx = startx+(magnitude*dir[0])
|
||||||
|
var endy = starty+(magnitude*dir[1])
|
||||||
|
// console.log("Direction seems to be " + dir)
|
||||||
|
var jcoords
|
||||||
|
if (pixel.pullOrPush == 1){jcoords = lineCoords(startx, starty, endx, endy, 1)}
|
||||||
|
else {jcoords = lineCoords(endx, endy, startx, starty, 1)}
|
||||||
|
|
||||||
|
|
||||||
|
// console.log(startx + " is the starting x, " + starty + " is the starting y, " + endx + " is the ending x, " + endy + " is the ending y. Result is " + jcoords)
|
||||||
|
let pCoord = jcoords[0]
|
||||||
|
for (var j = 0; j < jcoords.length; j++) {
|
||||||
|
var lcoord = jcoords[j];
|
||||||
|
var lx = lcoord[0];
|
||||||
|
var ly = lcoord[1];
|
||||||
|
if (!isEmpty(lx, ly, true)){
|
||||||
|
tryMove(pixelMap[lx][ly], pCoord[0], pCoord[1], null, true)
|
||||||
|
}
|
||||||
|
pCoord[0] = lx;
|
||||||
|
pCoord[1] = ly;
|
||||||
|
}
|
||||||
|
}
|
||||||
elements.specific_piston_ray_emitter = {
|
elements.specific_piston_ray_emitter = {
|
||||||
color: "#517597",
|
color: "#517597",
|
||||||
behavior: behaviors.WALL,
|
behavior: behaviors.WALL,
|
||||||
|
|
@ -3115,6 +3166,12 @@ elements.specific_piston_ray_emitter = {
|
||||||
pistonDistance = ans4
|
pistonDistance = ans4
|
||||||
var ans5 = parseInt(prompt("How many ticks should it wait to be charged again?", "6"))
|
var ans5 = parseInt(prompt("How many ticks should it wait to be charged again?", "6"))
|
||||||
pistonCooldown = ans5
|
pistonCooldown = ans5
|
||||||
|
var ans6 = parseInt(prompt("How many times should it repeat the push/pulling?", "1"))
|
||||||
|
pistonRepeat = ans6
|
||||||
|
if (pistonRepeat != 1){
|
||||||
|
var ans7 = parseInt(prompt("How many ticks should it wait between repeats?", "1"))
|
||||||
|
pistonRepeatCooldown = ans7
|
||||||
|
}
|
||||||
},
|
},
|
||||||
tick: function(pixel){
|
tick: function(pixel){
|
||||||
if (pixelTicks == pixel.start){
|
if (pixelTicks == pixel.start){
|
||||||
|
|
@ -3123,8 +3180,13 @@ elements.specific_piston_ray_emitter = {
|
||||||
pixel.pistonEnd = pistonEnd
|
pixel.pistonEnd = pistonEnd
|
||||||
pixel.pistonDistance = pistonDistance
|
pixel.pistonDistance = pistonDistance
|
||||||
pixel.pistonCooldown = pistonCooldown
|
pixel.pistonCooldown = pistonCooldown
|
||||||
|
pixel.pistonRepeat = pistonRepeat
|
||||||
|
pixel.pistonRepeatCooldown = pistonRepeatCooldown
|
||||||
}
|
}
|
||||||
if (!pixel.cooldown){pixel.cooldown = 0}
|
if (!pixel.cooldown){pixel.cooldown = 0}
|
||||||
|
if (!pixel.rcooldown){pixel.rcooldown = 0}
|
||||||
|
if (!pixel.repeatAmounts){pixel.repeatAmounts = 0}
|
||||||
|
if (!pixel.fakei){pixel.fakei = 0}
|
||||||
if (pixel.cooldown < 1){
|
if (pixel.cooldown < 1){
|
||||||
for (var i = 0; i < adjacentCoords.length; i++) {
|
for (var i = 0; i < adjacentCoords.length; i++) {
|
||||||
var coord = squareCoords[i];
|
var coord = squareCoords[i];
|
||||||
|
|
@ -3132,34 +3194,21 @@ elements.specific_piston_ray_emitter = {
|
||||||
var y = pixel.y+coord[1];
|
var y = pixel.y+coord[1];
|
||||||
if (!isEmpty(x,y, true)){
|
if (!isEmpty(x,y, true)){
|
||||||
if (pixelMap[x][y].charge && (pixelMap[x][y].element == "wire" || pixelMap[x][y].element == "insulated_wire")){
|
if (pixelMap[x][y].charge && (pixelMap[x][y].element == "wire" || pixelMap[x][y].element == "insulated_wire")){
|
||||||
|
pixel.repeatAmounts = pixel.pistonRepeat
|
||||||
|
pixel.fakei = i
|
||||||
for (let r = 0; r < pixel.pistonDistance; r++){
|
for (let r = 0; r < pixel.pistonDistance; r++){
|
||||||
pixel.cooldown = pixel.pistonCooldown
|
pistonEmit(pixel, i);
|
||||||
var dir = [0-squareCoords[i][0], 0-squareCoords[i][1]]
|
}
|
||||||
var startx = pixel.x+(dir[0]*(pixel.pistonStart+1))
|
pixel.repeatAmounts--
|
||||||
var starty = pixel.y+(dir[1]*(pixel.pistonStart+1))
|
|
||||||
var magnitude = pixel.pistonEnd
|
|
||||||
var endx = startx+(magnitude*dir[0])
|
|
||||||
var endy = starty+(magnitude*dir[1])
|
|
||||||
// console.log("Direction seems to be " + dir)
|
|
||||||
var jcoords
|
|
||||||
if (pixel.pullOrPush == 1){jcoords = lineCoords(startx, starty, endx, endy, 1)}
|
|
||||||
else {jcoords = lineCoords(endx, endy, startx, starty, 1)}
|
|
||||||
|
|
||||||
// console.log(startx + " is the starting x, " + starty + " is the starting y, " + endx + " is the ending x, " + endy + " is the ending y. Result is " + jcoords)
|
|
||||||
let pCoord = jcoords[0]
|
|
||||||
for (var j = 0; j < jcoords.length; j++) {
|
|
||||||
var lcoord = jcoords[j];
|
|
||||||
var lx = lcoord[0];
|
|
||||||
var ly = lcoord[1];
|
|
||||||
if (!isEmpty(lx, ly, true)){
|
|
||||||
tryMove(pixelMap[lx][ly], pCoord[0], pCoord[1], null, true)
|
|
||||||
}
|
|
||||||
pCoord[0] = lx;
|
|
||||||
pCoord[1] = ly;
|
|
||||||
}}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}} else {pixel.cooldown -= 1}
|
}} else {pixel.cooldown --}
|
||||||
|
if (pixel.rcooldown < 1 && pixel.repeatAmounts > 0){
|
||||||
|
for (let r = 0; r < pixel.pistonDistance; r++){
|
||||||
|
pistonEmit(pixel, pixel.fakei);
|
||||||
|
}
|
||||||
|
pixel.repeatAmounts--
|
||||||
|
} else {pixel.rcooldown --}
|
||||||
},
|
},
|
||||||
insulate: true,
|
insulate: true,
|
||||||
}
|
}
|
||||||
|
|
@ -3610,4 +3659,61 @@ elements.copycat_filler = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
top left: canvasCoord(x), canvasCoord(y)
|
||||||
|
top right: canvasCoord(x)+pixelSize, canvasCoord(y)
|
||||||
|
bottom left: canvasCoord(x), canvasCoord(y)+pixelSize
|
||||||
|
bottom right: canvasCoord(x)+pixelSize, canvasCoord(y)+pixelSize
|
||||||
|
*/
|
||||||
|
adjacentSidesToCanvas = function(x, y, px, py){
|
||||||
|
if (x == 0 && y == -1){
|
||||||
|
return [canvasCoord(px)+(0.5*pixelSize), canvasCoord(py)]
|
||||||
|
}
|
||||||
|
else if (x == 0 && y == 1){
|
||||||
|
return [canvasCoord(px)+(0.5*pixelSize), canvasCoord(py)+pixelSize]
|
||||||
|
}
|
||||||
|
else if (x == -1 && y == 0){
|
||||||
|
return [canvasCoord(px), canvasCoord(py)+(0.5*pixelSize)]
|
||||||
|
}
|
||||||
|
else if (x == 1 && y == 0){
|
||||||
|
return [canvasCoord(px)+pixelSize, canvasCoord(py)+(0.5*pixelSize)]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
drawRectangle = function(ctx, color, x, y, width, height, xoffset, yoffset){
|
||||||
|
ctx.fillStyle = color;
|
||||||
|
ctx.fillRect(canvasCoord(x+xoffset), canvasCoord(y+yoffset), pixelSize*width, pixelSize*height)
|
||||||
|
}
|
||||||
|
elements.thin_pixel = {
|
||||||
|
color: "#747474",
|
||||||
|
behavior: behaviors.WALL,
|
||||||
|
category: "special",
|
||||||
|
renderer: function(pixel, ctx){
|
||||||
|
let differentAdjacent = [];
|
||||||
|
for (let i = 0; i < adjacentCoords.length; i++) {
|
||||||
|
let x = adjacentCoords[i][0] + pixel.x;
|
||||||
|
let y = adjacentCoords[i][1] + pixel.y;
|
||||||
|
if (!isEmpty(x, y, true) && pixelMap[x][y].element == "thin_pixel") {
|
||||||
|
differentAdjacent.push(adjacentCoords[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ctx.globalAlpha = 1
|
||||||
|
differentAdjacent.forEach(adj => {
|
||||||
|
let canvasadjacentCoords = adjacentSidesToCanvas(adj[0], adj[1], pixel.x, pixel.y);
|
||||||
|
// if (!canvasadjacentCoords){
|
||||||
|
// console.log(adj)
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//console.log(canvasadjacentCoords);
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(canvasCoord(pixel.x)+(0.5*pixelSize), canvasCoord(pixel.y)+(0.5*pixelSize));
|
||||||
|
ctx.lineTo(canvasadjacentCoords[0], canvasadjacentCoords[1]);
|
||||||
|
ctx.strokeStyle = pixel.color;
|
||||||
|
if (pixelSize*0.24>=2){ctx.lineWidth = pixelSize*0.24}else{ctx.lineWidth = 2}
|
||||||
|
ctx.stroke();
|
||||||
|
//console.log("line")
|
||||||
|
});
|
||||||
|
ctx.fillStyle = pixel.color;
|
||||||
|
ctx.fillRect(canvasCoord(pixel.x+0.38), canvasCoord(pixel.y+0.38), pixelSize*0.24, pixelSize*0.24);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -141,10 +141,10 @@ renderEachPixel(function(pixel, ctx) {
|
||||||
}
|
}
|
||||||
differentAdjacent.forEach(adj => {
|
differentAdjacent.forEach(adj => {
|
||||||
let canvasadjacentCoords = adjacentToCanvas(adj[0], adj[1], pixel.x, pixel.y);
|
let canvasadjacentCoords = adjacentToCanvas(adj[0], adj[1], pixel.x, pixel.y);
|
||||||
if (!canvasadjacentCoords){
|
// if (!canvasadjacentCoords){
|
||||||
console.log(adj)
|
// console.log(adj)
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
//console.log(canvasadjacentCoords);
|
//console.log(canvasadjacentCoords);
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.moveTo(canvasadjacentCoords[0][0], canvasadjacentCoords[0][1]);
|
ctx.moveTo(canvasadjacentCoords[0][0], canvasadjacentCoords[0][1]);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue