Circle not moving Java applet -
Circle not moving Java applet -
i trying circle move can maintain devolping little applet game school, reason not moving , can not figure out why.
public class startingponit extends applet implements runnable{ int x = 0; int y = 0; int dx = 1; int dy = 1; int radis = 20; private image i; private graphics doubleg; @override public void init() { setsize(800,600); } @override public void start() { thread thread = new thread(this); thread.start(); // thread info; } @override public void run() { x =+ dx; y =+ dy; //thread info while (true){ repaint(); seek { thread.sleep(17); } grab (interruptedexception ex) { logger.getlogger(startingponit.class.getname()).log(level.severe, null, ex); } } } @override public void stop() { } public void destory() { } @override public void update(graphics g) { if(i == null){ = createimage(this.getsize().width,getsize().height); //double bbuffering doubleg = i.getgraphics(); } doubleg.setcolor(getbackground()); doubleg.fillrect(0,0, this.getsize().width,this.getsize().height); doubleg.setcolor(getforeground()); paint(doubleg); g.drawimage(i, 0, 0, this); } @override public void paint(graphics g) { g.setcolor(color.black); g.filloval(x-radis, y-radis, radis*2, radis*2); //size of object } }
you aren't updating x , y in loop
//thread info while (true){ repaint(); x += dx; y += dy; //rest same } java applet awt
Comments
Post a Comment