Plr  

Posted by Kedawung Agency in

import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
public class peluru {
public JButton button1 = new JButton("peluru");
private int jalan_x;
private int jalan_y;
public Timer Datetime;
private boolean status_menang;
private JFrame xframe;

public int getX()
{
return jalan_x;
}
public int getY()
{
return jalan_y;
}
public void setX(int x)
{
jalan_x = x;
}
public void setY(int y)
{
jalan_y = y;
}
public void setButton(boolean status)
{
button1.setVisible(status);
Datetime.start();
}
public peluru() {
}


public peluru(int jlx,int jly,JFrame s) {
jalan_x=jlx;
jalan_y=jly;
xframe = s;


status_menang=false;
s.add(button1);
button1.setVisible(true);
button1.setBounds(jalan_x,jalan_y,5,5);

Datetime= new Timer(50,tembak);
Datetime.start();
}

private ActionListener tembak = new ActionListener()
{
public void actionPerformed(ActionEvent e)
{ //Target Mondar mandir
button1.setBounds(jalan_x,jalan_y,5,5);
if (jalan_y <=0)
{
button1.setVisible(false);
Datetime.stop();
}else
{ jalan_y-=10;
}
}
};


}

This entry was posted on Rabu, 19 Mei 2010 at 03.31 and is filed under . You can follow any responses to this entry through the comments feed .

0 komentar

Posting Komentar