Jumat, 17 April 2009

Animasi java pesawat terbang

animasi pesawat terbang dengan nama Project3.java
yaitu :

import java.awt.*;
import java.applet.*;
public class Animasi extends Applet{
int mouseX,mouseY,clicks;
boolean mouseIn;
Image pic1, pic2, pic3;
public boolean mouseDown(Event evt,int x,int y){
clicks=clicks+20;
mouseX=x;
mouseY=y;
repaint ();
return true;
}
public boolean mouseEnter(Event evt,int x,int y){
mouseIn=true;
repaint();
return true;
}
public boolean mouseExit(Event evt,int x,int y){
mouseIn=false;
repaint();
return true;
}

public void init(){
pic1=getImage(getCodeBase(),"duke.running.gif");
pic2=getImage(getCodeBase(),"blkg.jpg");
pic3=getImage(getCodeBase(),"Pesawat.JPG");
}
public void paint (Graphics g){
g.drawImage(pic3, 10, 70 ,120, 50, this);
int x = 10;
int y = 500;
while (true) {
g.drawImage(pic3, x, y ,120, 50, this);
x += 3;
y -= 1;

try {
Thread.sleep(40);
}
catch (InterruptedException e) {
e.printStackTrace();
}
}
}


}

lebih lengkap download disini

Tidak ada komentar:

Posting Komentar