static final int ATTRACT = 0; static final int REPEL = 1; static final int FUNNL = 2; static final int FUNNR = 3; static final int BOARD = 4; class Type { int t; Type(int _t) { t = _t; } } class Player { Attractor attr; FunnelRight funr; FunnelLeft funl; SpringBoard spbd; int type, pNum; Player(int pn, Type t) { pNum = pn; setType(t); } void setType(Type t) { type = t.t; int x = 100 + pNum*150; int y = height/2; switch (type) { case ATTRACT: attr = new Attractor(phys.makeParticle(3, x, y, 0), 5, color(126, 99, 99, 128)); break; case REPEL: attr = new Attractor(phys.makeParticle(3, x, y, 0), 5, color(359, 84, 93, 128)); break; case FUNNL: funl = new FunnelLeft(x, y, random(50, 100)); break; case FUNNR: funr = new FunnelRight(x, y, random(50, 100)); break; case BOARD: spbd = new SpringBoard(x, y, random(100, 150), random(-PI/4, PI/4)); break; } } void move(int d) { switch (type) { case ATTRACT: attr.move(d); break; case REPEL: attr.move(d); break; case FUNNL: funl.move(d); break; case FUNNR: funr.move(d); break; case BOARD: spbd.move(d); break; } } void collide(Pebble p) { switch (type) { case ATTRACT: attr.collide(p); break; case REPEL: attr.collide(p); break; case FUNNL: funl.collide(p); break; case FUNNR: funr.collide(p); break; case BOARD: spbd.collide(p); break; } } void render() { switch (type) { case ATTRACT: attr.render(); break; case REPEL: attr.render(); break; case FUNNL: funl.render(); break; case FUNNR: funr.render(); break; case BOARD: spbd.render(); break; } } }