This commit is contained in:
nora 2021-06-17 14:03:36 +02:00
parent 10ca04b98e
commit add4166030
11 changed files with 157 additions and 14 deletions

View file

@ -5,15 +5,14 @@ import {CANVAS_HEIGHT, CANVAS_WIDTH} from "../App";
const particles: Particle[] = [];
export function particlesInit() {
export function initParticles() {
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
), charge, chargeToMass[charge - 1]));
), charge, chargeToMass[charge + 1]));
}
}