Skip to content

Commit

Permalink
fix: random peole gen
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicschweizer committed May 12, 2023
1 parent 92b2e42 commit 194a482
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
1 change: 0 additions & 1 deletion prototype-1/index.html
Expand Up @@ -12,7 +12,6 @@
integrity="sha256-WBkoXOwTeyKclOHuWtc+i2uENFpDZ9YPdf5Hf+D7ewM="
crossorigin=""
></script>
<script type="module" src="buildings.js"></script>
<script defer type="module" src="main.js"></script>
<link rel="stylesheet" href="styles.css" />
<body>
Expand Down
17 changes: 6 additions & 11 deletions prototype-1/main.js
@@ -1,4 +1,4 @@
import { BUILDINGS } from "./buildings";
import { BUILDINGS } from "./buildings.js";
const oldPerson = "https://svgsilh.com/svg/1800224.svg";
const child = "https://svgsilh.com/svg/44050.svg";
// VARIABLES
Expand Down Expand Up @@ -55,12 +55,11 @@ setTimeout(() => {
// PHASE T + One Hour
setTimeout(() => {
polygon1 = L.polygon(oneHourPolygon).addTo(map);
createRandomPeople(100, rathaus).forEach((p) => {
console.log(p);
createRandomPeople(2000, rathaus).forEach((p) => {
var myIcon = L.icon({
iconUrl: child,
iconSize: [50, 50],
iconAnchor: [22, 94],
iconUrl: p.age > 50 ? oldPerson : child,
iconSize: [25, 25],
iconAnchor: [0, 0],
popupAnchor: [-3, -76],
shadowSize: [68, 95],
shadowAnchor: [22, 94],
Expand Down Expand Up @@ -88,7 +87,7 @@ const createRandomInt = (max) => {
return Math.random() * max;
};
const getRandomBuilding = () => {
return BUILDINGS()[Math.floor(Math.random * BUILDINGS.length)];
return BUILDINGS[Math.floor(Math.random() * BUILDINGS.length)];
};
/**
*
Expand All @@ -99,10 +98,6 @@ const createRandomPeople = (noPeople, center) => {
console.log(noPeople, center);
const peopleArray = [];
while (peopleArray.length < noPeople) {
const position = [
center[0] + (Math.random() - 0.5) * 0.003,
center[1] + (Math.random() - 0.5) * 0.003,
];
peopleArray.push({
age: createRandomInt(100),
position: getRandomBuilding(),
Expand Down

0 comments on commit 194a482

Please sign in to comment.