[java] Drawing in Java games.

Started by
0 comments, last by mc3712 22 years, 2 months ago
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.
Advertisement
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
"None of us learn in a vacuum; we all stand on the shoulders of giants such as Wirth and Knuth and thousands of others. Lend your shoulders to building the future!" - Michael Abrash[JavaGaming.org][The Java Tutorial][Slick][LWJGL][LWJGL Tutorials for NeHe][LWJGL Wiki][jMonkey Engine]

This topic is closed to new replies.

Advertisement