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
Live ordinary life in an extraordinary way. Details embedded in this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
|