while (true)
loop and introduce a new method tick
that handles a single step in the while
loop, so that show
becomes a simple while tick; end
.show
, but keep the Gosu::Window
running by calling tick
regularly from Tk (a timer?). Do you feel like doing a little research work? I can push a beta gem.
--pre
version of Gosu that has Window#tick
as described above. Seems to work fine from a quick test, but I haven't integrated it with any libraries, only called tick
in a while
loop. It is still possible that Gosu's tick
eats OS events that Tk is waiting for, or the other way around.w = Gosu::Window.new(...)
loop { break if not w.tick }
.update
method? I thought it only had the full .mainloop
. Do we even need Window#tick
then? I've just created a TkRoot in a Window
constructor and called .update
on it from Window#update
, and then just called window.show
. The result seems to be the same as in your gist - a tiny Tk window alongside a working Gosu::Window
.
#update
should be good enough for internal tools like level editors, though? That's actually good to know!
root.after(1000, step(window, root))
? You need to pass the step
as a proc/lambda, or it will be evaluated immediately.after
even accept two arguments? Mysteries of Ruby/Tk... :))window = GameWindow.new
root = TkRoot.new { title "ex1" }
TkLabel.new(root) { text "hello world"; pack { padx 15; pady 15; side "left"; }; }
step = proc { window.tick; root.after(16, &step) }
step.call # start Gosu::Window#tick timer loop
root.mainloop
Window#tick
in the final Gosu 0.10.2, but mark it is experimental in the docs. Thanks for testing, and for nudging me to refactor Gosu a little more.
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill