Skip to content

Commit

Permalink
adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
SomewhatMay committed Nov 1, 2024
1 parent 4dea5d8 commit 1a6b748
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/scenes/game/world-decoration/grass-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class GrassContainer {
private scene: Scene,
private worldGroup: Physics.Arcade.StaticGroup
) {
this.populateGrass(100);
this.populateGrass(800);
this.scene.textures
.get("grass")
.setFilter(Phaser.Textures.FilterMode.NEAREST);
Expand Down
8 changes: 6 additions & 2 deletions src/scenes/game/world-decoration/tree-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { GrassContainer } from "./grass-container";

export class TreeContainer {
static treeScale = 8;
static scaleVariation = 3; // deviation from treeScale (subtraction or addition)
static treeCount = 4; // number of tree textures labeled as "tree{n}"

constructor(
Expand All @@ -22,7 +23,10 @@ export class TreeContainer {
createTree(x: number) {
const tree = this.scene.add
.image(0, 0, "tree" + Math.floor(Math.random() * TreeContainer.treeCount))
.setScale(TreeContainer.treeScale)
.setScale(
TreeContainer.treeScale +
(Math.random() - 0.5) * TreeContainer.scaleVariation
)
.setOrigin(0, 1);

tree.setPosition(
Expand All @@ -33,7 +37,7 @@ export class TreeContainer {
}

populateTrees(width: number) {
for (let i = -1; i < width - 1; i += Math.random() * 2) {
for (let i = -1; i < width - 1; i += 0.25 + Math.random() * 1.5) {
this.createTree(i);
}
}
Expand Down

0 comments on commit 1a6b748

Please sign in to comment.