class Bee { float x, y; // Position float px, py; // Previous position float vx, vy; // Velocity float gx, gy; // Gravity float friction; // Friction Bee() { reset(); } void reset() { x = 0; y = 0; px = 0; py = 0; vx = 0; vy = 0; gx = 0; gy = 0; friction = 1; } void set_pos(float x, float y) { this.x = x; this.y = y; } void set_vel(float vel, float dir) { float[] c = xy_comps(vel, dir); vx = c[0]; vy = c[1]; } void set_grav(float vel, float dir) { float[] c = xy_comps(vel, dir); gx = c[0]; gy = c[1]; } void step() { // Previous position px = x; py = y; // Gravity vx += gx; vy += gy; // Friction vx *= friction; vy *= friction; // Position x += vx; y += vy; } void draw() { line(px, py, x, y); } void display() { step(); draw(); } }