Files
sunny9898/task8/_ref/noc-examples-processing-master/chp06_agents/StayWithinCircle/StayWithinCircle.pde
louiscklaw 5637fbf94f update,
2025-02-01 02:07:58 +08:00

42 lines
622 B
Plaintext

// The Nature of Code
// Daniel Shiffman
// http://natureofcode.com
// Stay Within Circle
// "Made-up" Steering behavior to stay within walls
Vehicle v;
boolean debug = true;
PVector circleposition;
float circleRadius;
void setup() {
size(640, 360);
v = new Vehicle(width/2, height/4);
circleposition = new PVector(width/2,height/2);
circleRadius = height/2-25;
}
void draw() {
background(255);
if (debug) {
stroke(175);
noFill();
ellipse(circleposition.x,circleposition.y, circleRadius*2,circleRadius*2);
}
v.boundaries();
v.run();
}
void mousePressed() {
debug = !debug;
}