Archived

This topic is now archived and is closed to further replies.

mc3712

[java] Drawing in Java games.

Recommended Posts

I''m (trying to) build an object-oriented 2D game. How should I do the painting? I made my own Canvas class, and deal with the painting and drawing in there. But would it be good to make my objects paint themselves(so that I pass Graphics context to them) or to "pass them" to Canvas class, and make some kind of paint-methods there. Are Thanks in advance.

Share this post


Link to post
Share on other sites
If you have the objects paint themselves, all you have is a single method call for each object and only one parameter is passed. If you have your canvas draw each object, then the canvas would have to call at least one method per object(to get x and y coordinates). It would also have to have the correct picture to draw. Plus if you introduce new objects, then your canvas may have to be changed to account for those. It would probably be better to have the objects draw themselves.

---
Make it work.
Make it fast.

"Commmmpuuuuterrrr.." --Scotty Star Trek IV:The Voyage Home

Share this post


Link to post
Share on other sites