class Player { constructor(position) { this.position = position; this.rays = []; this.distances = []; this.fov = 90; this.angle = 0; } show() { fill(100); noStroke(); ellipse(this.position.x, this.position.y, 10); } update() { const sight = sightSlider.value() * 10; const fov = fovSlider.value(); const rotationSpeed = rotationSpeedSlider.value(); const velocity = velocitySlider.value(); if (keyIsDown(LEFT_ARROW)) { this.angle -= rotationSpeed; } if (keyIsDown(RIGHT_ARROW)) { this.angle += rotationSpeed; } if (keyIsDown(UP_ARROW)) { this.position = angleToVector(this.position.x, this.position.y, this.angle, velocity); } if (keyIsDown(DOWN_ARROW)) { this.position = angleToVector(this.position.x, this.position.y, this.angle, -velocity); } this.rays = []; for (let i = 0 - floor(fov / 2); i < floor(fov / 2); i=i+0.5) { this.rays.push(new Ray(this.position.x, this.position.y, radians(i + this.angle), sight)); } for (let r of this.rays) { for (let w of walls) { r.cast(w); } r.show(); } this.distances = []; for(let i = 0; i