Skip to content

Commit

Permalink
Create private renderers
Browse files Browse the repository at this point in the history
  • Loading branch information
hasnainroopawalla committed Aug 14, 2023
1 parent 490fd1b commit e26a448
Showing 1 changed file with 25 additions and 15 deletions.
40 changes: 25 additions & 15 deletions src/world.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,18 @@ export class World {
}
}

private renderPheromones() {
for (let i = 0; i < this.pheromones.length; i++) {
const pheromone = this.pheromones[i];
if (pheromone.shouldBeDestroyed()) {
this.pheromones.splice(i, 1);
}
pheromone.render();
pheromone.evaporate();
private renderAnts() {
for (let i = 0; i < this.ants.length; i++) {
const ant = this.ants[i];
ant.update();
ant.render();
}
}

private renderColonies() {
for (let i = 0; i < this.colonies.length; i++) {
const colonies = this.colonies[i];
colonies.render();
}
}

Expand All @@ -86,15 +90,21 @@ export class World {
}
}

private renderPheromones() {
for (let i = 0; i < this.pheromones.length; i++) {
const pheromone = this.pheromones[i];
if (pheromone.shouldBeDestroyed()) {
this.pheromones.splice(i, 1);
}
pheromone.render();
pheromone.evaporate();
}
}

public render() {
p5i.background(config.world.background);
this.colonies.map((colony) => {
colony.render();
});
this.ants.map((ant) => {
ant.update();
ant.render();
});
this.renderAnts();
this.renderColonies();
this.renderFoodItems();
this.renderPheromones();
}
Expand Down

0 comments on commit e26a448

Please sign in to comment.