Hi, I jus want to ask why is it that the pacman will move but it will get larger when it is painted..also is that the proper way to draw?.
here is the code
import javax.swing.*;
import java.awt.*;
public class Mypacman extends JFrame implements Runnable{
int x;
public Mypacman(){
setVisible(true);
setSize(400,400);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setTitle("Pacman");
setBackground(Color.black);
}
public void paint(Graphics g)
{
g.setColor(Color.RED);
g.fillArc(x,100,60,60,30,300);
Thread t=new Thread(this);
try
{
t.sleep(100);
}
catch(Exception e){}
t.start();
}
public void run(){
if(x<500)
{
x++;
}
repaint();
}
public static void main(String[]args){
new Mypacman();
}
}