This commit is contained in:
赵鑫 2022-12-11 03:28:12 +08:00
parent 4f9153ba8e
commit 528227586a

View File

@ -12,8 +12,8 @@ function setup() {
function draw() { function draw() {
// 追逐鼠标(); // 追逐鼠标();
// 逃避鼠标(); // 逃避鼠标();
巡游小车();
// 小车追逐(); // 小车追逐();
巡游小车();
} }
function 追逐鼠标() { function 追逐鼠标() {
@ -34,15 +34,6 @@ 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, 20); vehicle1.seek(vehicle2, 20);
@ -55,6 +46,15 @@ function 小车追逐() {
vehicle1.show(); vehicle1.show();
} }
function 巡游小车() {
background(64);
vehicle1.wander();
vehicle1.move();
vehicle1.turn();
vehicle1.drawPath();
vehicle1.show();
}
/** /**
* 返回可指定大小的随机二维向量 * 返回可指定大小的随机二维向量
* @param {number} magnitude 向量大小 * @param {number} magnitude 向量大小