added cucurbit pattern

This commit is contained in:
Orchid 2026-01-21 09:56:58 -06:00
parent 63b6bddd69
commit cee0dd6bc5
1 changed files with 177 additions and 126 deletions

View File

@ -2,60 +2,6 @@
*Version 2.2.1
*/
let plants;
dependOn("orchidslibrary.js", ()=>{
class growInterval {
constructor(seedPixel, pattern, basePos, c = 0.025, dieAfter = undefined, fruit = undefined, elems = undefined){
let currentLength = 0;
let chance = c;
let pos = basePos;
let interval = setInterval(()=>{
if(currentLength == pattern.length || seedPixel == undefined){
clearInterval(interval);
} else {
let x = pos[0]+pattern[currentLength][0], y = pos[1]+pattern[currentLength][1];
if(Math.random()<chance && isEmpty(x,y) && !outOfBounds(x,y) && !paused){
let elem = (elems != undefined && elems[currentLength] != undefined) ? elems[currentLength] : (elems != undefined) ? elems[0] : "fruit_leaves";
createPixel((elem == "flower") ? "fruit_leaves" : elem, x, y);
pixelMap[x][y].noBloom = (elem == "flower") ? false : true;
pixelMap[x][y].blooming = (elem == "flower");
pixelMap[x][y].fruit = fruit;
if(elem == "fruit_leaves"){
pixelMap[x][y].dieAfter = dieAfter;
}
currentLength++;
} else if (!isEmpty(x,y) && !outOfBounds(x,y)){
if(eLists.SOIL.includes(pixelMap[x][y].element)){
deletePixel(x,y);
let elem = (elems != undefined && elems[currentLength] != undefined) ? elems[currentLength] : (elems != undefined) ? elems[0] : "fruit_leaves";
createPixel((elem == "flower") ? "fruit_leaves" : elem, x, y);
pixelMap[x][y].noBloom = (elem == "flower") ? false : true;
pixelMap[x][y].blooming = (elem == "flower");
pixelMap[x][y].fruit = fruit;
if(elem == "fruit_leaves"){
pixelMap[x][y].dieAfter = dieAfter;
}
}
currentLength++;
}
}
}, 1000/tps);
this.interval = interval;
}
}
let flowerExclude = ["pineapple"];
let vineGrow = ["wood", "rock_wall", "straw", "wall", "ewall", "bush_cane", "bush_base", "fruit_branch"];
plants = {
tree: [],
vine: ["grape", "tomato"],
bush: [],
other: ["pineapple", "watermelon", "banana", "onion"],
includes: function(target){
for(item in this){
if(this[item] && Array.isArray(this[item]) && this[item].includes(target)){return true;}
}
return false;
}
}
let growthPatterns = {
pineapple1: [[-1,-1],[-2,-2],[1,-1],[2,-2],[0,-1],[0,-2],[0,-3],[0,-4],[0,-5],[0,-6],[-1,-6],[1,-6],[-1,-5],[1,-5],[-1,-4],[1,-4],[-1,-3],[1,-3],[0,-7],[-1,-8],[1,-8]],
pineapple2: [[[-1,-1],[1,-1]],[[-2,-2],[2,-2]], [0,-1],[0,-2],[0,-3],[0,-4],[0,-5],[0,-6],[[-1,-6],[1,-6]],[[-1,-5],[1,-5]],[[-1,-4],[1,-4]],[[-1,-3],[1,-3]],[[-1,-2],[1,-2]],[0,-7],[-1,-8],[1,-8]],
@ -124,6 +70,19 @@ dependOn("orchidslibrary.js", ()=>{
}
return res;
},
cucurbit: function(r, dir, min, max){
let w = Math.round(Math.random()*(max-min))+min;
let h = Math.round(w*r);
let res = [];
let pos = [0,0];
for(let i = 0; i < w; i++){
for(let ii = 0; ii < h/2; ii++){
res.push([i, ii]);
res.push([i, ii*-1]);
}
}
return res;
}
};
let growthElems = {
pineapple1: ["fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","flower","flower","flower","flower","flower","flower","flower","flower","flower","flower","flower","flower","fruit_leaves","fruit_leaves","fruit_leaves"],
@ -141,7 +100,94 @@ dependOn("orchidslibrary.js", ()=>{
"palm_5-2":["fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","flower","flower","flower","fruit_leaves","flower","flower","flower","flower","flower","flower","flower","flower","flower","flower","flower","flower","flower","flower","flower","flower","flower","flower","flower","flower","flower"],
"coconut_5-1": ["fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","flower","flower","flower","flower","flower","flower","flower","flower","flower","flower","flower","flower","flower","flower","fruit_leaves"],
"coconut_5-2": ["fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","fruit_leaves","flower","flower","flower","flower","flower","flower","flower","flower","flower","flower","flower","flower","flower","flower","flower","flower","flower","flower","flower","flower","flower","flower","flower","flower","flower"],
cucurbit: ["fruit_leaves"],
}
class growInterval {
constructor(seedPixel, pattern, basePos, c = 0.025, dieAfter = undefined, fruit = undefined, elems = undefined){
let currentLength = 0;
let chance = c;
let pos = basePos;
let interval = setInterval(()=>{
if(currentLength == pattern.length || seedPixel == undefined){
clearInterval(interval);
} else {
if(is2d(pattern[currentLength])){
for(let coords of pattern[currentLength]){
let x = pos[0]+coords[0], y = pos[1]+coords[1];
if(Math.random()<chance && isEmpty(x,y) && !outOfBounds(x,y) && !paused){
let elem = (elems != undefined && elems[currentLength] != undefined) ? elems[currentLength] : (elems != undefined) ? elems[0] : "fruit_leaves";
createPixel((elem == "flower") ? "fruit_leaves" : elem, x, y);
pixelMap[x][y].noBloom = (elem == "flower") ? false : true;
pixelMap[x][y].blooming = (elem == "flower");
pixelMap[x][y].fruit = fruit;
if(elem == "fruit_leaves"){
pixelMap[x][y].dieAfter = dieAfter;
}
currentLength++;
} else if (!isEmpty(x,y) && !outOfBounds(x,y)){
if(eLists.SOIL.includes(pixelMap[x][y].element)){
deletePixel(x,y);
let elem = (elems != undefined && elems[currentLength] != undefined) ? elems[currentLength] : (elems != undefined) ? elems[0] : "fruit_leaves";
createPixel((elem == "flower") ? "fruit_leaves" : elem, x, y);
pixelMap[x][y].noBloom = (elem == "flower") ? false : true;
pixelMap[x][y].blooming = (elem == "flower");
pixelMap[x][y].fruit = fruit;
if(elem == "fruit_leaves"){
pixelMap[x][y].dieAfter = dieAfter;
}
}
currentLength++;
}
}
} else {
let x = pos[0]+pattern[currentLength][0], y = pos[1]+pattern[currentLength][1];
if(Math.random()<chance && isEmpty(x,y) && !outOfBounds(x,y) && !paused){
let elem = (elems != undefined && elems[currentLength] != undefined) ? elems[currentLength] : (elems != undefined) ? elems[0] : "fruit_leaves";
createPixel((elem == "flower") ? "fruit_leaves" : elem, x, y);
pixelMap[x][y].noBloom = (elem == "flower") ? false : true;
pixelMap[x][y].blooming = (elem == "flower");
pixelMap[x][y].fruit = fruit;
if(elem == "fruit_leaves"){
pixelMap[x][y].dieAfter = dieAfter;
}
currentLength++;
} else if (!isEmpty(x,y) && !outOfBounds(x,y)){
if(eLists.SOIL.includes(pixelMap[x][y].element)){
deletePixel(x,y);
let elem = (elems != undefined && elems[currentLength] != undefined) ? elems[currentLength] : (elems != undefined) ? elems[0] : "fruit_leaves";
createPixel((elem == "flower") ? "fruit_leaves" : elem, x, y);
pixelMap[x][y].noBloom = (elem == "flower") ? false : true;
pixelMap[x][y].blooming = (elem == "flower");
pixelMap[x][y].fruit = fruit;
if(elem == "fruit_leaves"){
pixelMap[x][y].dieAfter = dieAfter;
}
}
currentLength++;
}
}
}
}, 1000/tps);
this.interval = interval;
}
}
dependOn("orchidslibrary.js", ()=>{
let flowerExclude = ["pineapple"];
let vineGrow = ["wood", "rock_wall", "straw", "wall", "ewall", "bush_cane", "bush_base", "fruit_branch"];
plants = {
tree: [],
vine: ["grape", "tomato"],
bush: [],
other: ["pineapple", "watermelon", "banana", "onion"],
includes: function(target){
for(item in this){
if(this[item] && Array.isArray(this[item]) && this[item].includes(target)){return true;}
}
return false;
}
}
let ethyleneChance = {
tomato: 0.000055,
orange: 0.000005,
@ -591,6 +637,11 @@ dependOn("orchidslibrary.js", ()=>{
if(pixel.fruit){
if(pixel.fruit == "random"){
changePixel(pixel, fruits[Math.floor(Math.random() * fruits.length)]);
}
if (pixel.pattern && pixel.growthPattern == false) {
pixel.blooming = false;
pixel.growthPattern = true;
} else {
let c = (pixel.offspringColor) ? pixel.offspringColor : undefined;
changePixel(pixel, pixel.fruit);
@ -622,7 +673,7 @@ dependOn("orchidslibrary.js", ()=>{
}
}
}
} else if(pixel.growthStage < growthPatterns[pixel.pattern].length) {
} else if(pixel.growthStage < [pixel.pattern].length) {
let x = pixel.x+(value[0]*pixel.dir[0]), y = pixel.y+(value[1]*pixel.dir[1]);
if(isEmpty(x,y) && !outOfBounds(x,y)){
if(growthElems[pixel.pattern][pixel.growthStage] == "flower"){