import java.applet.Applet; import java.awt.*; import java.awt.event.*; import java.util.Vector; public class Pildike3 extends Applet implements Runnable, KeyListener{ Image taust; Image pilt; Graphics piltg; Image putukas; int putukax=100, putukay=150; int putukalaius=30, putukakorgus=15; int putukasamm=4; int mustripikkus=160; int samm=3; int paus=50; int nihe=0; int aeg=0; int laius=300, korgus=300; boolean veel=false; public Pildike3(){ addKeyListener(this); requestFocus(); } public void paint(Graphics g){ koostaPilt(); g.drawImage(pilt, 0, 0, this); } public void update(Graphics g){ paint(g); } void koostaPilt(){ if(taust==null)taust=laePilt("rohetaust320x480.gif"); if(putukas==null)putukas=laePilt("sirelane.gif"); if(pilt==null){ pilt=createImage(laius, korgus); piltg=pilt.getGraphics(); } nihe=nihe+samm; aeg=aeg+samm; if(nihe>mustripikkus)nihe=nihe-mustripikkus; piltg.drawImage(taust, 0, nihe-mustripikkus, this); piltg.drawImage(putukas, putukax, putukay, this); } public void start(){ veel=true; new Thread(this).start(); } public void run(){ while(veel){ repaint(); try{Thread.sleep(paus); }catch(Exception e){} } } public void stop(){ veel=false; } public void keyPressed(KeyEvent e){ int kood=e.getKeyCode(); if((kood==KeyEvent.VK_LEFT) && (putukax>putukasamm))putukax-=putukasamm; if((kood==KeyEvent.VK_RIGHT) && (putukaxputukasamm)putukay-=putukasamm; if(kood==KeyEvent.VK_DOWN && putukay