feat: Increase tree and flower sizes for better visibility
This commit is contained in:
parent
d8e868aad8
commit
0788b3067d
53
script.js
53
script.js
@ -611,8 +611,8 @@ function updateFlower(x, y) {
|
|||||||
metadata.age++;
|
metadata.age++;
|
||||||
setMetadata(x, y, metadata);
|
setMetadata(x, y, metadata);
|
||||||
|
|
||||||
// Flowers can grow taller up to a limit
|
// Flowers can grow taller up to a limit (2x bigger)
|
||||||
if (metadata.age % 300 === 0 && metadata.height < 4 && getPixel(x, y - 1) === EMPTY) {
|
if (metadata.age % 300 === 0 && metadata.height < 8 && getPixel(x, y - 1) === EMPTY) {
|
||||||
// If this is the top of the flower, make it a stem and put a new flower on top
|
// If this is the top of the flower, make it a stem and put a new flower on top
|
||||||
setPixel(x, y - 1, FLOWER);
|
setPixel(x, y - 1, FLOWER);
|
||||||
setMetadata(x, y - 1, {
|
setMetadata(x, y - 1, {
|
||||||
@ -675,8 +675,8 @@ function growTree(x, y) {
|
|||||||
// Replace the seed with the trunk
|
// Replace the seed with the trunk
|
||||||
setPixel(x, y, WOOD);
|
setPixel(x, y, WOOD);
|
||||||
|
|
||||||
// Determine tree height (5-8 blocks)
|
// Determine tree height (50-80 blocks, 10x bigger)
|
||||||
const treeHeight = 5 + Math.floor(Math.random() * 4);
|
const treeHeight = 50 + Math.floor(Math.random() * 31);
|
||||||
|
|
||||||
// Grow the trunk upward
|
// Grow the trunk upward
|
||||||
for (let i = 1; i < treeHeight; i++) {
|
for (let i = 1; i < treeHeight; i++) {
|
||||||
@ -687,8 +687,45 @@ function growTree(x, y) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add leaves at the top
|
// Add leaves at the top (10x bigger radius)
|
||||||
addLeaves(x, y - treeHeight + 1, 2 + Math.floor(Math.random() * 2));
|
addLeaves(x, y - treeHeight + 1, 20 + Math.floor(Math.random() * 10));
|
||||||
|
|
||||||
|
// Add some branches
|
||||||
|
addBranches(x, y, treeHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
function addBranches(x, y, treeHeight) {
|
||||||
|
// Add 2-4 branches at different heights
|
||||||
|
const numBranches = 2 + Math.floor(Math.random() * 3);
|
||||||
|
|
||||||
|
for (let i = 0; i < numBranches; i++) {
|
||||||
|
// Position branch at different heights along the trunk
|
||||||
|
const branchY = y - Math.floor(treeHeight * (0.3 + 0.4 * i / numBranches));
|
||||||
|
|
||||||
|
// Choose left or right direction
|
||||||
|
const direction = Math.random() > 0.5 ? 1 : -1;
|
||||||
|
|
||||||
|
// Branch length (10-15 blocks)
|
||||||
|
const branchLength = 10 + Math.floor(Math.random() * 6);
|
||||||
|
|
||||||
|
// Create the branch
|
||||||
|
for (let j = 1; j <= branchLength; j++) {
|
||||||
|
// Branch goes out horizontally with some upward angle
|
||||||
|
const branchX = x + (j * direction);
|
||||||
|
const upwardAngle = Math.floor(j * 0.3);
|
||||||
|
|
||||||
|
if (getPixel(branchX, branchY - upwardAngle) === EMPTY) {
|
||||||
|
setPixel(branchX, branchY - upwardAngle, WOOD);
|
||||||
|
} else {
|
||||||
|
break; // Stop if we hit something
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add small leaf clusters at the end of branches
|
||||||
|
if (j === branchLength) {
|
||||||
|
addLeaves(branchX, branchY - upwardAngle, 8 + Math.floor(Math.random() * 4));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function addLeaves(x, y, radius) {
|
function addLeaves(x, y, radius) {
|
||||||
@ -702,7 +739,9 @@ function addLeaves(x, y, radius) {
|
|||||||
const distance = Math.sqrt(dx*dx + dy*dy);
|
const distance = Math.sqrt(dx*dx + dy*dy);
|
||||||
if (distance <= radius) {
|
if (distance <= radius) {
|
||||||
// Random chance to place a leaf based on distance from center
|
// Random chance to place a leaf based on distance from center
|
||||||
if (Math.random() < (1 - distance/radius/1.2)) {
|
// More dense leaves for larger trees
|
||||||
|
const density = radius > 10 ? 0.8 : 0.6;
|
||||||
|
if (Math.random() < (1 - distance/radius/density)) {
|
||||||
if (getPixel(x + dx, y + dy) === EMPTY) {
|
if (getPixel(x + dx, y + dy) === EMPTY) {
|
||||||
setPixel(x + dx, y + dy, LEAF);
|
setPixel(x + dx, y + dy, LEAF);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user