prepare column function for spoutoid generalization

This commit is contained in:
Laetitia (O-01-67) 2022-11-12 15:39:11 -05:00 committed by GitHub
parent e5a14b95eb
commit 25da755352
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 36 additions and 45 deletions

View File

@ -1,26 +1,34 @@
function highBloodColumn(xx,yy) { function placeDownwardColumn(element,xx,yy,creationChance) {
//console.log("from " + xx + "," + yy) var newElement = element;
if(!outOfBounds(xx,yy)) { if(Array.isArray(newElement)) {
for(i = yy; i < pixelMap[xx].length; i++) { newElement = newElement[Math.floor(Math.random() * newElement.length)];
if(isEmpty(xx,i,false)) { };
if(Math.random() < 0.5) { //console.log("from " + xx + "," + yy)
createPixel("blood",xx,i) if(!outOfBounds(xx,yy)) {
} for(i = yy; i < pixelMap[xx].length; i++) {
if(Math.random() < 0.3) { if(isEmpty(xx,i,false)) {
if(!isEmpty(xx,yy,true)) { if(Math.random() < creationChance) {
deletePixel(xx,yy) createPixel(element,xx,i)
} }
} } else if(!isEmpty(xx,i,true)) {
} else if(!isEmpty(xx,i,false) && !outOfBounds(xx,i)) { var newPixel = pixelMap[xx][i];
break; var newElement = newPixel.element;
} else if(!isEmpty(xx,i,false) && outOfBounds(xx,i)) { var newInfo = elements[newElement];
break; var newState = "solid";
} else { if(typeof(newInfo.state) !== "undefined") {
break; newState = newInfo.state
} };
} if(newState !== "solid") {
} continue;
} } else {
break;
};
} else if(outOfBounds(xx,i)) {
break;
};
};
};
};
//cliche' //cliche'
elements.blood_cloud = { elements.blood_cloud = {
@ -96,24 +104,7 @@ elements.heaviester_blood_cloud = {
], ],
tick: function(pixel) { tick: function(pixel) {
if(Math.random() < 0.01) { if(Math.random() < 0.01) {
for(i = pixel.y + 1; i < pixelMap[i].length; i++) { placeDownwardColumn("blood",pixel.x,pixel.y+1,0.5);
if(isEmpty(pixel.x,i,false)) {
if(Math.random() < 0.5) {
createPixel("blood",pixel.x,i)
}
if(Math.random() < 0.3) {
if(!isEmpty(pixel.x,pixel.y,true)) {
deletePixel(pixel.x,pixel.y)
}
}
} else if(!isEmpty(pixel.x,i,false) && !outOfBounds(pixel.x,i)) {
break;
} else if(!isEmpty(pixel.x,i,false) && outOfBounds(pixel.x,i)) {
break;
} else {
break;
}
}
} }
}, },
category:"gases", category:"gases",
@ -134,10 +125,10 @@ elements.heaviestest_blood_cloud = {
], ],
tick: function(pixel) { tick: function(pixel) {
if(Math.random() < 0.02) { if(Math.random() < 0.02) {
highBloodColumn(pixel.x-1,pixel.y + 1) for(j = -1; j <= 1; j++) {
highBloodColumn(pixel.x,pixel.y + 1) placeDownwardColumn("blood",pixel.x+j,pixel.y+1,0.5);
highBloodColumn(pixel.x+1,pixel.y + 1) };
} };
}, },
category:"gases", category:"gases",
temp: 30, temp: 30,