Not logged inGosu Forums
Forum back to Help Search Register Login
Up Topic Gosu / Gosu Exchange / Pry: a useful tool for game development
- - By banister Date 2010-12-08 15:54
I wrote a little tool called [Pry]( to help me in my game development.

It effectively opens up an IRB session on an object, letting you play with your runtime state, examine or modify it, and then, on typing 'exit' return you to your game.

Useful for debugging or implementing a quake-style console for your game.

Install the gem: gem install pry

require it: require 'pry'

And try putting this somewhere in your update method:

    Pry.into(self) if button_down?(Gosu::KbP)

Read the documentation here:
Parent - By ippa Date 2010-12-08 16:29
Very cool stuff, hopefully I'll have a good reason to play with this soon in a game.
Parent - By erisdiscord Date 2010-12-08 17:15
Wow! I wish for this sort of thing fairly often, and now you've gone and done it. Thanks, good sir. :)
Parent - - By banister Date 2010-12-17 09:22
Improved Pry, and changed the API.


Notable changes:
* Removed into() method (just use start())
* Added show_method command  (retrieves sourcecode of a method)
* Added ls/cd commands (somehow they feel natural even though they're out of place)
Parent - By AmIMeYet Date 2010-12-17 19:35
But Pry.into() is so syntactically delicious!

No really, this looks quite nice. Should give it a try soon.
Parent - - By banister Date 2010-12-21 11:29 Edited 2010-12-21 11:58
For some reason i didn't think of this before, but you can actually use Pry for hotswapping code:

Say you ask yourself: "lol i wonder what it would be like if i increased firing rate slightly, or if gravity was 3x as strong lmao?"

Process goes like this:

Start game, play for a while ---> Update code in editor, save changes --> enter a Pry session (i have it bound to keypress 'p') --> type load "my_updated_file.rb" --> exit pry (type 'exit')

Game then continues with the modifications applied. No restart necessary.
Parent - By RunnerPack Date 2010-12-21 13:03
That is a very cool feature! I've been doing this for well over a year with SketchUp's Ruby console, and I also never made the connection :P
Parent - By AmIMeYet Date 2010-12-21 15:37
WTF, I actually just thought of hotswapping *today*.. ..and I just gave up on my google search, only to find this. Awesome.
Parent - By banister Date 2011-05-14 05:32
Screencast showing the use of pry in game development:
Up Topic Gosu / Gosu Exchange / Pry: a useful tool for game development

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill