coronavirus-simulator

Coronavirus spread simulator
git clone http://git.hanabi.in/repos/coronavirus-simulator.git
Log | Files | Refs | LICENSE

person.js (518B)


      1 class Person {
      2   constructor() {
      3     this.x = 10 + Math.random() * (w - 10);
      4     this.y = 10 + Math.random() * (h - 10);
      5     this.velocity = {};
      6     this.velocity.x = Math.random() * 5;
      7     this.velocity.y = Math.random() * 5;
      8   }
      9   show() {
     10     if (this.x < 10.2 || this.x > w - 10.2) this.velocity.x = -this.velocity.x;
     11     if (this.y < 10.2 || this.y > h - 10.2) this.velocity.y = -this.velocity.y;
     12     this.x = this.x + this.velocity.x;
     13     this.y = this.y + this.velocity.y;
     14     circle(this.x, this.y, 10);
     15   }
     16 }