This commit is contained in:
赵鑫 2022-12-11 02:57:46 +08:00
parent c9bbf29b9d
commit 3c1b2dae42

View File

@ -10,19 +10,10 @@ function setup() {
} }
function draw() { function draw() {
巡游小车();
// 追逐鼠标(); // 追逐鼠标();
// 逃避鼠标(); // 逃避鼠标();
// 小车追逐(); // 巡游小车();
} 小车追逐();
function 巡游小车() {
background(64);
vehicle1.wander();
vehicle1.move();
vehicle1.turn();
vehicle1.drawPath();
vehicle1.show();
} }
function 追逐鼠标() { function 追逐鼠标() {
@ -43,12 +34,21 @@ function 逃避鼠标() {
vehicle1.show(); vehicle1.show();
} }
function 巡游小车() {
background(64);
vehicle1.wander();
vehicle1.move();
vehicle1.turn();
vehicle1.drawPath();
vehicle1.show();
}
function 小车追逐() { function 小车追逐() {
background(64); background(64);
vehicle1.seek(vehicle2); vehicle1.seek(vehicle2, 20);
vehicle2.move(); vehicle2.move();
vehicle1.move(); vehicle1.move();
vehicle2.turn(); if (vehicle2.turn()) vehicle2.velocity = randomVector(random(2, 5));
vehicle1.turn(); vehicle1.turn();
vehicle1.drawPath(); vehicle1.drawPath();
vehicle2.show(); vehicle2.show();
@ -150,6 +150,7 @@ class Vehicle {
} }
this.position.x = x; this.position.x = x;
this.position.y = y; this.position.y = y;
return edgeCrossed;
} }
// bounce() { // bounce() {