I am trying to get my circle to move so I can keep devolping my small applet game for school, but for some reason Its not moving and I 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();
try {
Thread.sleep(17);
} catch (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){
i = 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
}
}