ball is moving but it leaving blue background wherever it is moving..
you give x,y initial values of (say) 10,100
then you start a timer to change x and/or y
and at the same time call panel.repaint()
which will 'repaint' the ball at its new location.
Michael Dunn wrote:x(100) + width(200) = 300
x + half-width = ?
but if i m trying for this:
g.setColor(Color.GREEN);
g.drawRect(300, 200, 150, 250);
g.setColor(Color.RED);
g.drawLine(425, 275, 425, 275);
now it's not in center...
it might be if you swap the 150,250
g.drawRect(300, 200, 150, 250);
g.drawRect(300, 200, 250, 150);
g.drawLine(375, 325, 375, 325); //this is not in center
He was giving me directions and I was powerless to resist. I cannot resist this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|