update
This commit is contained in:
parent
c9bbf29b9d
commit
3c1b2dae42
27
vehicle.js
27
vehicle.js
@ -10,19 +10,10 @@ function setup() {
|
||||
}
|
||||
|
||||
function draw() {
|
||||
巡游小车();
|
||||
// 追逐鼠标();
|
||||
// 逃避鼠标();
|
||||
// 小车追逐();
|
||||
}
|
||||
|
||||
function 巡游小车() {
|
||||
background(64);
|
||||
vehicle1.wander();
|
||||
vehicle1.move();
|
||||
vehicle1.turn();
|
||||
vehicle1.drawPath();
|
||||
vehicle1.show();
|
||||
// 巡游小车();
|
||||
小车追逐();
|
||||
}
|
||||
|
||||
function 追逐鼠标() {
|
||||
@ -43,12 +34,21 @@ function 逃避鼠标() {
|
||||
vehicle1.show();
|
||||
}
|
||||
|
||||
function 巡游小车() {
|
||||
background(64);
|
||||
vehicle1.wander();
|
||||
vehicle1.move();
|
||||
vehicle1.turn();
|
||||
vehicle1.drawPath();
|
||||
vehicle1.show();
|
||||
}
|
||||
|
||||
function 小车追逐() {
|
||||
background(64);
|
||||
vehicle1.seek(vehicle2);
|
||||
vehicle1.seek(vehicle2, 20);
|
||||
vehicle2.move();
|
||||
vehicle1.move();
|
||||
vehicle2.turn();
|
||||
if (vehicle2.turn()) vehicle2.velocity = randomVector(random(2, 5));
|
||||
vehicle1.turn();
|
||||
vehicle1.drawPath();
|
||||
vehicle2.show();
|
||||
@ -150,6 +150,7 @@ class Vehicle {
|
||||
}
|
||||
this.position.x = x;
|
||||
this.position.y = y;
|
||||
return edgeCrossed;
|
||||
}
|
||||
|
||||
// bounce() {
|
||||
|
Loading…
Reference in New Issue
Block a user