class ScoreDisplayer { private int totalScore; private Vector scores; ScoreDisplayer() { totalScore = 0; scores = new Vector(10, 5); } int total() { return totalScore; } void reset() { scores.clear(); totalScore = 0; } void addScore(int amt, float x, float y) { totalScore += amt; scores.add(new Score(amt, x, y)); } void display() { image(words[14], 500, 60, words[14].width/2, words[14].height/2); printNumber(totalScore, 890, 60, 0.5f, 0); for (int i = 0; i < scores.size(); i++) { Score tmp = (Score)scores.get(i); tmp.update(); tmp.render(); if ( tmp.isDone() ) scores.remove(i--); } } class Score { private float x, y, dx, dy, sc; private int amt, age; Score(int _amt, float _x, float _y) { amt = _amt; x = _x; y = _y; age = 0; dx = random(-1, 1); dy = random(-1, 1); sc = 0.1f; } boolean isDone() { return age > 50; } void update() { x += dx*2; y += dy*2; sc *= 1.03f; age++; } void render() { printNumber(amt, x, y, sc, age); } } }