import java.awt.*; public class example1 extends table { double x, y, dx = 8, dy = 16; int w, p; public void initTable() { w = getTableSize(); p = getPuckSize(); x = w/3; y = w/2; } public void drawTable(Graphics g) { x += dx; y += dy; // GRAVITY dy += 1; boolean flash = false; double xx = x - w/2; double yy = y - w/2; double rr = xx * xx + yy * yy; // REFLECTION if (rr > w*w/4) { flash = true; double dd = dx * xx + dy * yy; dx -= 2 * dd * xx / rr; dy -= 2 * dd * yy / rr; x += dx; y += dy; } // FLASH ON IMPACT g.setColor(flash ? Color.red : Color.blue); int r = flash ? 20 : 10; g.fillOval((int)x - r, (int)y - r, r+r, r+r); } public boolean onPickup(int i) { return true; } public boolean onDrop(int i) { return true; } }