added mass

This commit is contained in:
nora 2021-06-17 10:27:36 +02:00
parent 1888dca4e8
commit 10ca04b98e
5 changed files with 19 additions and 66 deletions

View file

@ -7,11 +7,13 @@ const particles: Particle[] = [];
export function particlesInit() {
const chargeToMass = [0.1, 1, 10];
for (let i = 0; i < 200; i++) {
const charge = Math.random() < 0.3 ? 0 : Math.random() < 0.5 ? 1 : -1;
particles.push(new Particle(new Vector(
Math.random() * (CANVAS_WIDTH - 100) + 50,
Math.random() * (CANVAS_HEIGHT - 100) + 50
), Math.random() < 0.3 ? 0 : Math.random() < 0.6 ? -1 : 1));
), charge, chargeToMass[charge - 1]));
}
}