Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / Instant reloading of images during development
- - By jlnr (dev) Date 2015-09-03 21:57
I'm really enjoying this bit of code right now, and thought I'd share it. It uses terrible Ruby monkey-patching to reload all images when the user presses R. (I'm require-ing this file after my class Window < Gosu::Window has been defined, adjust the class name accordingly...)

https://github.com/jlnr/monstris/blob/master/src/debug/image_reloading.rb

It doesn't override Image.load_tiles and is generally shaky, but isn't it fun what you can do in a few lines of evil Ruby :)
Parent - - By jlnr (dev) Date 2015-09-03 22:03
Of course, that is just a harmless toy in comparison to this tool: https://github.com/flgr/again

Now to check if it still works with Ruby 2.0...
Parent - - By BlueScope Date 2015-09-10 23:36
I have to say that sounds pretty awesome, and I tried to test it, however I get the following error:

/var/lib/gems/2.1.0/gems/again-1.1.4/lib/again/patches/listen.rb:4:in `<top (required)>': Adapter is not a class (TypeError)

I find myself again completely out of ideas, but if someone knows a fix for this, maybe they can share it :) Sure sounds like a useful developing tool.

That's actually true for the image snippet as well, just that personally, I'd have much more application for a code counterpart. Thanks for sharing/linking the both of them, anyhow!
Parent - By jlnr (dev) Date 2015-09-11 10:49
I ran into the same issue, and chatted about it with flgr. The trick is that again only works with the listen 1.x gem, not 2.x or 3.x. So you can either uninstall all versions of listen, and then gem install listen -v 1.3.1, or you can specify the version through your Gemfile:

gem 'again', require: false
gem 'listen', '= 1.3.1', require: false


I think it works now. If it doesn't pick up changes to your files, *I think* you can also force it to reload a file like so:

Again.instance.send(:reload, Again.instance.send(:resolve_library, "#{File.dirname __FILE__}/src/model/piece.rb"))

I guess that's a bit of a vague response, but last time I had to stop coding after the first "proof of concept" reload worked :/ (Ruby 2.0, OS X)
Up Topic Gosu / Gosu Exchange / Instant reloading of images during development

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill