Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / Your best GOSU ruby snippetss
- By ippa Date 2009-08-09 23:07
What ruby snippets do you have that usually goes into that newly started game. Could be any usefull game-related class or method. Some cool effects maybe. A particle class.

I'm both curious but would also like to summon some good effects and stuff into a library for easy access. Credits will be given where due naturally if I do it :).

Started the discussion on IRC the other day (#gosu @ freenode) so we can have Julian kick off this thread:

<jlnr> class Module
<jlnr>   def const_missing sym
<jlnr>     require sym.to_s
<jlnr>     const_get sym
<jlnr>   end
<jlnr> end
<jlnr> Could be put in a method enable_autoloading ;)

and

<jlnr>   def draw_impressively text, x, y, z, factor = 1
<jlnr>     draw_rot text, x - 1.5, y, z, -5, factor, factor, 0xff000000
<jlnr>     draw_rot text, x + 1.5, y, z, -5, factor, factor, 0xff000000
<jlnr>     draw_rot text, x, y - 1.5, z, -5, factor, factor, 0xff000000
<jlnr>     draw_rot text, x, y + 1.5, z, -5, factor, factor, 0xff000000
<jlnr>     draw_rot text, x, y, z, -5, factor, factor
<jlnr>   end

I made this and used it for some smaller games I wrote:

http://pastie.org/pastes/450737

So, whatchu got?
- By ippa Date 2009-08-26 19:15 Edited 2009-08-26 19:27
So, this thread wasn't exactly overwealming with posts as I hoped :D.

I've started building some basic gfx helpers for Gosu in Chingu ( http://github.com/ippa/chingu/tree/master ).

So far I have
  * fill(color) - fills whole window with color
  * fill_rect(rect, color) - fills a given Rect with color
  * fill_gradient - gradient fills whole window or rect. hash-arguments as :from, :to, :rect, :thickness, :orientation

See example7.rb for demonstration of them all. Or just include http://github.com/ippa/chingu/blob/758b8c328c079ac58ce59764f22f3f068f2f1548/lib/chingu/gfx_helpers.rb in any of your Gosu or Chingu project. The only assumption it makes is that your global Gosu::Window (or Chingu::WIndow) instance is saved in $window.

Any other useful ideas what could go into such a gfx helper compilation? =)

*EDIT
I just realised that fill_gradient could be made Alot simpler by using the full power of draw_quads color-arguments :).. (I ported an old implementation I did for rubygame some year ago.)
- By lobo_tuerto Date 2009-09-01 20:08
I really liked the idea of this post, but I'm a newcomer to Gosu, so I don't really have any cool snippet that I could extract from my code yet.
But nice idea nonetheless. :)
Up Topic Gosu / Gosu Exchange / Your best GOSU ruby snippetss

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill