From 19fe85e1fc50daeb11a437a9ea1799261d2e9b3e Mon Sep 17 00:00:00 2001 From: JH159753 Date: Sun, 30 Oct 2022 23:50:38 -0700 Subject: [PATCH] Delete Boid10308162985695495767.autosave --- Boid10308162985695495767.autosave | 99 ------------------------------- 1 file changed, 99 deletions(-) delete mode 100644 Boid10308162985695495767.autosave diff --git a/Boid10308162985695495767.autosave b/Boid10308162985695495767.autosave deleted file mode 100644 index f3b2a3b..0000000 --- a/Boid10308162985695495767.autosave +++ /dev/null @@ -1,99 +0,0 @@ -/// In this file, you will have to implement seek and waypoint-following -/// The relevant locations are marked with "TODO" - -class Crumb -{ - PVector position; - Crumb(PVector position) - { - this.position = position; - } - void draw() - { - fill(255); - noStroke(); - circle(this.position.x, this.position.y, CRUMB_SIZE); - } -} - -class Boid -{ - Crumb[] crumbs = {}; - int last_crumb; - float acceleration; - float rotational_acceleration; - KinematicMovement kinematic; - PVector target; - - Boid(PVector position, float heading, float max_speed, float max_rotational_speed, float acceleration, float rotational_acceleration) - { - this.kinematic = new KinematicMovement(position, heading, max_speed, max_rotational_speed); - this.last_crumb = millis(); - this.acceleration = acceleration; - this.rotational_acceleration = rotational_acceleration; - } - - void update(float dt) - { - if (target != null) - { - // TODO: Implement seek here - print(kinematic.getHeading()); - - } - - // place crumbs, do not change - if (LEAVE_CRUMBS && (millis() - this.last_crumb > CRUMB_INTERVAL)) - { - this.last_crumb = millis(); - this.crumbs = (Crumb[])append(this.crumbs, new Crumb(this.kinematic.position)); - if (this.crumbs.length > MAX_CRUMBS) - this.crumbs = (Crumb[])subset(this.crumbs, 1); - } - - // do not change - this.kinematic.update(dt); - - draw(); - } - - void draw() - { - for (Crumb c : this.crumbs) - { - c.draw(); - } - - fill(255); - noStroke(); - float x = kinematic.position.x; - float y = kinematic.position.y; - float r = kinematic.heading; - circle(x, y, BOID_SIZE); - // front - float xp = x + BOID_SIZE*cos(r); - float yp = y + BOID_SIZE*sin(r); - - // left - float x1p = x - (BOID_SIZE/2)*sin(r); - float y1p = y + (BOID_SIZE/2)*cos(r); - - // right - float x2p = x + (BOID_SIZE/2)*sin(r); - float y2p = y - (BOID_SIZE/2)*cos(r); - triangle(xp, yp, x1p, y1p, x2p, y2p); - } - - void seek(PVector target) - { - this.target = target; - - } - - void follow(ArrayList waypoints) - { - // TODO: change to follow *all* waypoints - this.target = waypoints.get(0); - - } -}