By jlnr (dev)
Date 2011-01-31 09:34
Edited 2011-01-31 09:41
Well, yes and no. Internally, the graphics and audio contexts are global and independent from the window, so you can do stuff like that (complete program):
i = Image.new("Player.png")
puts i.width
Playing audio without a window is not as cute, sadly. You might have to call Song#update every now and then, something that Window does for you right now. The idea is not to have a global window, but to decouple things in general. Window#draw_quad will also be Gosu::draw_quad etc.
I don't think it matters a lot in game design, because at some point you have something like a "game" that owns the map and objects, be it the window, a Chingu state, or an abstract object. All game objects will want to access that, so you're back to having a global or passing stuff around.
But with Gosu 0.8, helper libraries are able to do "image = Image.new('my_helpful_overlay.png')" without support from the enclosing program (passing the window). Also, having just a simple constant "GOBLIN_IMAGE = Image.new('goblin.png')" is something that is not possible right now.
I didn't change the reference and examples right now, but Song and Sample don't need the window argument anymore as a first step.