Not logged inGosu Forums
Forum back to Help Search Register Login
Up Topic Gosu / Extending Gosu / Gosu Suggestion ( small ) - image errors
- By Maverick Date 2009-06-17 17:22
The title most likely didn't make since.


Anyway I have a suggestion for Gosu. This suggestion is actually what I did in my game engine and it was one of the features I liked. If the graphics module in the game engine could not load an image, when the programmer compiled and ran it, the game would lock up and might not find the problem. I hated that. It's one of those things I felt like was a waste of time. So as an alternative in my game engine, I had a built-in array of bytes that resembled  a white texture with an x in it. If the module could not load the image, that image was replaced with the "x" image according to the width and height. That way, if my location of an image was wrong, I could still play my game and find out without it locking up and not really knowing anything.

It's a small feature but I think others will like it as well.
- By jlnr (dev) Date 2009-06-17 17:51
I don't like it at a first glance, but prefer it when my code fails early. When I fail to load an image but don't show it to the user/me, I won't notice it until later. Also, the error message gives me the Ruby line number where I messed something up. Not too sure on this one :(
- By Maverick Date 2009-06-17 17:57
I'm not exactly sure what you are saying. Sorry. :[ Maybe I should clarify?
What most game engines do:

Start->LoadNonExistingImage->Crash->User's Like WTF?

This is what I'm getting at:

Start->LoadNonExistingImage->ImageOfABadGuyIsRedX->User's Like "Ok. I need to check the loading address of my image."

Ruby is kewl enough to point out the lie, but C++ might not be. It'll just close and you'll have no clue.
This is just a suggestion after all.
- By Quit Date 2009-06-17 18:27
You're welcome to catch the loading exception and tell the user the programmer has been drunk. Users should *not* be the one that debug your program. If they miss an image, it's mostly your fault (or the extractor, hello IzArc).
- By jlnr (dev) Date 2009-06-17 18:34
I just wrapped my whole game in a try..except block on Windows and use ShowMessage to display the error :)

I think what we can agree on is that Gosu should be smarter about its exception texts. If you run a C++ game outside of its debugger, you will not have a stack trace, and std::exception.what() only contains the lowest-level error such as "File not found", when it should really be "Image in file xxx not found".
- By Maverick Date 2009-06-17 18:40
Meh. It was a suggestion.
- By jlnr (dev) Date 2009-06-17 19:17
And I don't think it's completely silly, Gosu does something similar on Linux if sound doesn't work. It will still happily create fake Samples and Songs that do nothing instead of failing there. The downside that I've experienced is that it's hard to detect then if loading failed or not for the actual game.

Too bad you are not using Ruby, it would be easy to monkey-patch this onto Gosu by just wrapping the old initialize into a rescue block and then returning an error image via from_text for experimentation :)
Up Topic Gosu / Extending Gosu / Gosu Suggestion ( small ) - image errors

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill