Better sprite painting methodology?

hi…

here my original sprite painting method:

public void paint(Graphics g)
{
g.setclip(x, y, width, height);
g.drawImage(image, x, y, Graphics.TOP |
Graphics.LEFT);
g.setclip(0, 0, getWidth(), getHeight());
}

i found out this method is bad cause it ‘clip’ your image on the screen… so once the image is painted it forever stuck at cliped position on the screen…

Thanks

wait… what kind of painting you want to do? and this is just an image not a sprite.

if you think painting using sprite is asier pls study this tutorial because evrything that you should know about sprites are here

search for “IBM introduction to sprites” (you must register first though) but it is the simplest tutorial i know.

if you still want to stick with your painting method this is the pseudocode:

  1. paint the background
  2. clip the image
  3. draw the image
  4. unset the clipping

if you want to draw another (part of) image
5. clip gain
4. paint image
5. unset the clipping
and so forth…

so… clipping cosumes much hard coding but compared to sprites, clipping saves much memory heap… but i think sprites are sleaner to use. ;D