import javax.microedition.lcdui.*; import java.util.*; import java.util.Random.*; import javax.microedition.rms.*; class Louend4 extends Canvas{ int x, y, sammx=0, sammy=0, ry=5, rx=6; int seenex=30; int seeney=30; double a=0.5; double b=1; int seeni=0; int seentearv=7; int lugeja=0; int lopp=0; Vector hoidla=new Vector(); Random juhuslik; boolean alla=false; boolean korjatud=true; int[] klikk={0, 0, 0, 0}; int milline=1; Timer t; Graphics graaf; Korvisisu korv; protected void paint(Graphics g){ g.setColor(255, 255, 255); g.fillRect(0, 0, getWidth(), getHeight()); g.setColor(0, 0, 0); g.fillArc(x-rx, y-ry, 2*rx, 2*ry, 0, 180); g.drawLine(x-rx-2, y, x+rx+2, y); g.drawArc(x-rx, y-ry, 2*rx, 2*ry, 0, -180);//pea g.drawLine(x, y+ry, x, y+(ry*2));//keha g.drawLine(x, y+ry, x-3, y+ry+2);//käsi1 g.drawLine(x, y+ry, x+3, y+ry+2);//käsi2 g.drawLine(x-3, y+ry+2, (int)(x-(6*a)), y+ry+8);//käsi1 g.drawLine(x+3, y+ry+2, (int)(x+(6*b)), y+ry+8);//käsi2 g.drawLine(x, y+(ry*2), x-2, y+(ry*4));//jalg g.drawLine(x, y+(ry*2), x+2, y+(ry*4));//jalg if(alla==false) { g.drawArc((int)(x+(3*b)), y+ry+8, 6, 6, 0, 180);//sang g.fillArc((int)(x+(3*b)), y+ry+8, 6, 6, 0, -180);//korv } else { g.drawArc((int)(x-(9*a)), y+ry+8, 6, 6, 0, 180);//sang g.fillArc((int)(x-(9*a)), y+ry+8, 6, 6, 0, -180);//korv g.drawLine(x-3, y+2, x-2, y+2);//silm1 g.drawLine(x+1, y+2, x+2, y+2);//silm2 } Enumeration e2=hoidla.elements(); lugeja=0; while(e2.hasMoreElements()) { Seen s2=(Seen)e2.nextElement(); if((x+8)>(s2.seenx-6) && (x-8)<(s2.seenx+10) && (y+20)>(s2.seeny-8) && (y-5)<(s2.seeny+8)) { korjatud=true; hoidla.removeElementAt(lugeja); korv.paneKorvi(s2.seenmilline); //lopp=korv.kysi(1); seeni--; seentearv++; g.setColor(255, 255, 255); g.fillRect(s2.seenx-6, s2.seeny-8, 16, 16); } lugeja++; } if(korjatud==true || seeni1 || klikk[1]>1) { sammy=0; } if(klikk[2]>1 || klikk[3]>1) { sammx=0; } if(alla==false) { a=0.5; b=1; } else { a=1; b=0.5; } } public void showNotify(){ x=getWidth()/2; y=getHeight()/2; t=new Timer(); korv=new Korvisisu(); TimerTask tt=new TimerTask(){ public void run(){ liigux(); liiguy(); } }; t.schedule(tt, 500, 100); //viivitus, intervall } public void hideNotify(){ t.cancel(); } void liigux() { if((sammx>0 && x+sammx+rx>getWidth()) || (sammx<0 && x+sammx-rx<0)) { sammx=0; } else { x+=sammx; repaint(); } } void liiguy() { if((sammy>0 && y+sammy+ry>getHeight()) || (sammy<0 && y+sammy-ry<0)) { sammy=0; } else { y+=sammy; repaint(); } } class Seen { int seenx, seeny, seenmilline; Seen(int usx, int usy, int usmilline) { seenx=usx; seeny=usy; seenmilline=usmilline; } } }