Jack Franz wrote:edit: In case it's suggested to put these in the main class, that's unfortunately going to be difficult without using static variables
Unless you define them in the method itself. Most of the time,
main() methods are simply used as "launchers", so they should contain only as much code as is needed to initialize required stuff and then pass it off to an
instance (possibly of the class
containing main()), which then does everything else. One very basic technique is described in the
MainIsAPain page; although it's mainly meant for greenhorns to get them out of the habit of ploughing all their code into
main(). You still might find it worth a read.
Making a Renderer object belong to the Game or Screen class doesn't make much sense to me, as there doesn't seem to really be a 'has-a' relationship between them; it's more of a 'uses-a'...
But couldn't you say the same thing about a program and a database? And yet these days they're generally established via a
DataSource (javax.sql.DataSource) object, rather than a static
DriverManager definition.
This idea of a factory object that returns an
interface is used quite a lot for these kinds of "heavyweight" objects that tend to only be initialized once and then used a lot, but
forcing it via a static class, or a singleton, tends to cause more problems than it solves.
For one thing, if you come up with (or find) a better "Renderer" in the future, it allows you to plug it in with the minimum of effort.
HIH
Winston