/** Cube Monster by Eduardo Omine [2008-11-16] http://blog.omine.net/ */ class Vec2 { float x, y; Vec2() { set(0, 0); } Vec2(float x, float y) { set(x, y); } void set(float x, float y) { this.x = x; this.y = y; } void set(Vec2 v) { this.x = v.x; this.y = v.y; } void add(float x, float y) { this.x += x; this.y += y; } void add(Vec2 v) { this.x += v.x; this.y += v.y; } void mult(float f) { this.x *= f; this.y *= f; } void rand(float a, float b) { this.x = random(a, b); this.y = random(a, b); } void addRand(float a, float b) { this.x += random(a, b); this.y += random(a, b); } void bound(float ax, float ay, float bx, float by) { if(x < ax) x = ax; if(x > bx) x = bx; if(y < ay) y = ay; if(y > by) y = by; } }