Помогите тупому ребенку, скажите что в программе не так, пожааа...луйста
package duk5;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JButton;
import java.awt.image.ImageObserver;
import java.lang.Math.*;
/**
* Animated gif with a transparent background.
*/
public class DukeAnim extends AnimatingSurface implements ImageObserver, KeyListener {
private static Image agif, polochka, fon;
private static int aw, ah, cw;
private int x, i;
private float n;
public int z, z2;
private JButton b;
short y[] = new short [5];
short x2[] = new short [5];
public DukeAnim() {
setBackground(Color.WHITE);
fon = getImage("fon2.gif");
agif = getImage("duke.running.gif");
polochka = getImage("polochka.gif");
aw = agif.getWidth(this);
ah = agif.getHeight(this);
cw = fon.getHeight(this);
dontThread = true;
}
public void reset(int w, int h) {
b = ((Panel) getParent()).tools.startStopB;
for (n=0; n<=5; n++)
{x2
= (short) (Math.random() * 500);
y = (short) (Math.random() * 400);
}
}
public void step(int w, int h) { }
public void render (int w, int h, Graphics2D g2) {
g2.drawImage(fon, 0, 0, this);
z=150;
addKeyListener(new KeyListener() {
public void actionPerformed(ActionEvent ae){
z=150;
}
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
z+=20;
repaint();}
if (e.getKeyCode() == KeyEvent.VK_LEFT) {
z-=20;
repaint();}
}
public void keyTyped(KeyEvent arg0) {
throw new UnsupportedOperationException("Not supported yet.");
}
public void keyReleased(KeyEvent arg0) {
throw new UnsupportedOperationException("Not supported yet.");
}
});
for (i=0; i<=4; i++) {
for (n=1; n<100; n+=0.5) {
if (z<=x2*n+50 && z>=x2*n-50) {
if (2*x>=y*n-70)
{ x+=5;
g2.drawImage(agif, z,(int) (y*n - 70 - x), this);
z=-200;
}
}
}
}
x+=5;
g2.drawImage(agif, z, x, this);
y[0] = 500;
y[1] = 1200;
y[2] = 1300;
y[3] = 1500;
y[4] = 1000;
x2[1] = 10;
x2[2] = 50;
x2[3] = (short) (w / 3);
x2[4] = 100;
for (n=1; n<100; n+=0.5) {
g2.drawImage(polochka,(int) (x2[0] * n),(int) (y[0] * n - x), this);
g2.drawImage(polochka, (int) (x2[1]* n), (int) (y[1]*n -x), this);
g2.drawImage(polochka, (int) (x2[2]* n), (int) (y[2]*n -x), this);
g2.drawImage(polochka, (int) (x2[3]* n), (int) (y[3]*n -x), this);
g2.drawImage(polochka, (int) (x2[4]* n), (int) (y[4]*n -x), this);
}
}
public boolean imageUpdate(Image img, int infoflags,
int x, int y, int width, int height)
{
/* if (b.isSelected() && (infoflags & FRAMEBITS) != 0)
repaint();*/
if (b.isSelected() && (infoflags & FRAMEBITS) != 0)
repaint();
return isShowing();
}
public static void main(String s[]) {
createDemoFrame(new DukeAnim());
}
public void keyTyped(KeyEvent arg0) {
throw new UnsupportedOperationException("Not supported yet.");
}
public void keyPressed(KeyEvent arg0) {
throw new UnsupportedOperationException("Not supported yet.");
}
public void keyReleased(KeyEvent arg0) {
throw new UnsupportedOperationException("Not supported yet.");
}
}