// (c) 1998 Ekkehard Kraemer (ekraemer@pluto.camelot.de) import java.awt.*; /** * Sorry, not documented yet. *

* Source */ class Stats extends Canvas implements Runnable { Stats() { super(); resize(0,Images.ball.getHeight(null)*2); setBackground(Color.black); thread.start(); } public void run() { try { while (!stopNow) { synchronized(this) { if (addPoints>0) { int transfer=addPoints/8; if (transfer<1) transfer=1; if (transfer>addPoints) transfer=addPoints; points+=transfer; addPoints-=transfer; Graphics g=getGraphics(); g.setColor(Color.black); g.fillRect(10,5,10*ledtext.skip,100); drawPoints(g); g.dispose(); } else wait(); } Thread.sleep(50); } } catch (Exception e) { e.printStackTrace(System.err); } } synchronized public void paint(Graphics g) { super.paint(g); int w=size().width; int h=size().height; if (w!=width || h!=height) { width=w; height=h; repaint(); return; } drawBalls(g); drawPoints(g); drawBullets(g); } synchronized void drawBalls(Graphics g) { if (ballWidth<0) { ballWidth=Images.ball.getWidth(null); ballHeight=Images.ball.getHeight(null); if (ballHeight<=0) return; } for (int t=0; t no balls left { if (balls>0) { Graphics g=getGraphics(); g.setColor(Color.black); g.fillRect(width-ballWidth*(balls+1), ballY,ballWidth,ballHeight); g.dispose(); balls--; } return balls>0; } synchronized void incBalls() { Graphics g=getGraphics(); g.drawImage(Images.ball, width-ballWidth*(balls+2), ballY,null); g.dispose(); balls++; } synchronized void setBalls(int b) { balls=b; repaint(); } boolean noBallLeft() { return balls<1; } synchronized void addPoints(int p) { addPoints+=p; notifyAll(); } synchronized void addBullets() { bullets+=5; Graphics g=getGraphics(); drawBullets(g); g.dispose(); } synchronized boolean killBullet() { if (bullets>0) { bullets--; Graphics g=getGraphics(); drawBullets(g); g.dispose(); return true; } return false; } int width=-1,height=-1; int ballWidth=-1,ballHeight=-1,ballY=5; int balls=3; int points=0,addPoints=0; LEDText ledtext=new LEDText(); Thread thread=new Thread(this); boolean stopNow=false; int bullets=10,maxBullets=50; }