You're losing the object context when you pass setInterval()
a reference to the "render" method that way.
setInterval(function() { game.getGameContainer().render(); }, 16);
There's no intrinsic relationship between a function and an object that refers to it via a property value. By using an anonymous function, you can ensure that the "container" object will be the value of this
inside "render".
You could also do this with the .bind()
method of the Function prototype:
setInterval(game.getGameContainer().render.bind(game.getGameContainer()), 16);
but that seems a little ugly in this case.