Not logged inGosu Forums
Forum back to Help Search Register Login
Up Topic Gosu / Extending Gosu / Embedding Images in Gosu Programs
- - By aboutruby Date 2010-09-30 01:22
It's not always convenient to distribute data files with your programs, so I've come up with a little hack to embed them in the program itself.  It's not great, but it works.

This code is just a hack to work for PNG files, but it could work for any file.  When you want to use the file, all it does is decode from base64 and write to a temp file.  I wrote this specifically so people could people could post complete programs in text form on pastebins and forums (like this one!).  Oh, and there's a Rakefile there that will encode your files and automatically insert them into your script.
Parent - - By AmIMeYet Date 2010-10-01 14:34
Yeah, embedding images in ruby files is fun.  Not practical, but fun just the same.

Nice Gosu tutorials btw!
Parent - - By aboutruby Date 2010-10-01 21:23
I realize it's not practical for most uses, but I wrote this code specifically for my tutorials.  It's much handier to have a single example file people can download or even copy and paste, rather than a zip file.  It's just easier to keep things self-contained.

As for the tutorials, there's more to come.  If anyone has any feedback, or suggestions for further articles, I'm open to anything.  Or even guest articles, if you feel like writing anything yourself.
Parent - - By jlnr (dev) Date 2010-10-11 13:06
Just putting this here because I saw some thing flying by on my bouncer. If you have both a state system for menus, as well as the R['image.png'] class you may check out Chingu which has the same two features, the latter being called Image[...] there.

I like how you can apparently use these two parts of Chingu without being forced to use other parts like GameObject. Might be worth mentioning because the point of Chingu was to reduce the parallel implementations of these two things everywhere. :)
Parent - By aboutruby Date 2010-10-12 05:22
I knew about Chingu, and was "inspired" by it.  In other words, I looked at the example code and the bits that I needed, I duplicated.  It was a toss up between fully investigating Chingu and writing my own, but the parts I needed were so simple, it was just easier to do it myself.  I'm still looking at it for the future though.  As for the code duplication, these two parts are so simple, it's hardly an issue in this case.
Up Topic Gosu / Extending Gosu / Embedding Images in Gosu Programs

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill