This commit is contained in:
赵鑫 2022-12-11 03:27:17 +08:00
parent 2784cac35b
commit 4f9153ba8e

View File

@ -12,8 +12,8 @@ function setup() {
function draw() { function draw() {
// 追逐鼠标(); // 追逐鼠标();
// 逃避鼠标(); // 逃避鼠标();
// 巡游小车(); 巡游小车();
小车追逐(); // 小车追逐();
} }
function 追逐鼠标() { function 追逐鼠标() {
@ -119,9 +119,9 @@ class Vehicle {
const y = offset * sin(PI / 2 + this.heading); const y = offset * sin(PI / 2 + this.heading);
target.add(x, y); target.add(x, y);
// noStroke(); noStroke();
// fill("#F063A4"); fill("#F063A4");
// circle(target.x, target.y, 5); circle(target.x, target.y, 5);
const steering = target.sub(this.position); const steering = target.sub(this.position);
this.acceleration.add(steering); this.acceleration.add(steering);
@ -179,7 +179,7 @@ class Vehicle {
noFill(); noFill();
stroke(50); stroke(50);
strokeWeight(1); strokeWeight(1);
if (this.path.length >= 1024) this.path.shift(); if (this.path.length >= 10240) this.path.shift();
beginShape(); beginShape();
this.path.forEach((v) => { this.path.forEach((v) => {
if (!v) { if (!v) {