import java.applet.Applet; import java.awt.event.*; import java.awt.*; import javax.swing.*; import java.awt.Graphics; import java.util.Random; public class Main extends Applet implements ActionListener{ int randomarvud[]=new int[500],lumehelbedy[]=new int[500]; int randomlooja,lumehelbearv=1; Random randomGenerator = new Random(); Image img;// = Toolkit.getDefaultToolkit().getImage("lumi.png"); Image img2;// = Toolkit.getDefaultToolkit().getImage("reaalipoiss.jpg"); Timer t=new Timer(35, this); Timer f=new Timer(1000, this); Image offScreenBuffer; //Jätab Vana pildi ette, et tõkkamist ei teki public void update(Graphics g) { Graphics gr; if (offScreenBuffer==null || (! (offScreenBuffer.getWidth(this) == this.size().width && offScreenBuffer.getHeight(this) == this.size().height))) { offScreenBuffer = this.createImage(size().width, size().height); } gr = offScreenBuffer.getGraphics(); paint(gr); g.drawImage(offScreenBuffer, 0, 0, this); } public Main(){ //alustab aega, uuendusaeg t.start(); } public void paint(Graphics g){ if(img==null){img=getImage(getCodeBase(), "lumi.png");} if(img2==null){img2=getImage(getCodeBase(), "reaalipoiss.jpg");} g.drawImage(img2, 0, 0, this); randomlooja=randomGenerator.nextInt(40); if(randomlooja==4){ randomarvud[lumehelbearv]=randomGenerator.nextInt(580); lumehelbearv++; } for(int a=1;a