i am create animation in japplet and i want to know if iam using paint method and draphics2d the right way.
public void paint(Graphics g)
{
super.paint(g);
Graphics2D g2d = (Graphics2D) g;
g2d.fillRect(x, y, width, height); //player
}/** end of paint method ***/
another question i had was in run method. i set up thread to do animations. let me know if there is a beater way to do this.
/*** run method ***/
public void run()
{
while(true) //main game loop
{
//move image here
x += dx;
if(x+width >= getWidth())
{
x -= dx;
}
repaint();
try{
Thread.sleep(17);
}
catch(InterruptedException e){
e.printStackTrace();
}
}//end of while loop
}/*** end of run method ***/
reason iam asking for a better way bc this code does move the Rect() but it is flicking.