Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / Scene or GameState system Tutorial?
- By hima Date 2008-11-10 08:55
Could somebody please show me how should I write a scene or gamestate system in Gosu? I try having a variable $scene that will store and object such as Scene_Title , Scene_Menu, and in the main loop then I just call $scene.update

But it doesn't seems to work with rendering font since got this error when I try to draw in the scene class

" in `draw': While creating a bitmap, the following error occured: Not enough storage is available to process this command.

    (RuntimeError?)

"

The scene classes are in different .rb file by the way.

Any help or tutorials are appreciate. Thank you in advance!
- By jlnr (dev) Date 2008-11-10 10:16
Thanks for re-posting this here! That sounds like a very interesting message. Is it possible that there is a never-ending recursion in a constructor or so that creates more and more bitmaps? Anyway, it's beyond me why bitmap resources would run out before OpenGL resources do.

Can you attach a complete example? I'll add one of my "state system" files too later :)
- By hima Date 2008-11-10 12:38 Edited 2008-11-10 12:41
You're welcome! I think this question will be good for other beginners like me, and since we have forum which is much easier to read'n search, might as well post it here. :D

Anyway, this is weird. I was playing around a bit and then the error's gone. I even tried undo and turning it back to before I fix it, the error still gone :(  Weird.  In any case, here's the file so you can see my code. I haven't done anything except if you press Enter on the first scene, then it change to the second scene. And press ESC on the second scene will terminate the window.
Attachment: TestGosu.rar (0B)
- By ramenudle Date 2008-11-11 04:18
On an unrelated note, are you hima from CreationAsylum? :>
- By hima Date 2008-11-11 15:15
Yup. It's me hima ! :)
- By jlnr (dev) Date 2008-11-14 23:20 Edited 2009-02-02 11:35
I wanted to post a minimal system too, but I think I'll refer to the system I used here: http://www.libgosu.org/cgi-bin/mwf/topic_show.pl?tid=5 (see the MainWIndow class, the AbstractScreen class and implementations of it like GameScreen or TitleScreen)

It's actually pretty minimalistic. Sometimes I store the current states/screens/scenes in a stack instead of a single variable so I can have a dialog screen that shows the underlying game. But I still haven't settled on a perfect design though :( But I hope my source is easy to follow too!
- By hima Date 2008-11-22 15:48
Thank you jlnr!  It's good to see different approach on this same concept. :)  
- By ramenudle Date 2009-01-22 03:09
Yay, adbots.
- By jlnr (dev) Date 2009-01-22 08:39
Still few enough to be able to delete them manually. I would like to keep the board open to unregistered users though. Maybe I can find a hard captcha or so...
- By HybridMind Date 2009-01-22 13:50
don't know how easy it is to mod this forum but I've had great luck implementing invisible captchas. They aren't even really captchas but implement this concept:

http://danbenjamin.com/enkoder/form

The above link will have other links to implementing custom stuff-- I just use their form to generate my field/key data and then plug it into the templates and backend logic to make sure there is a match. The quick story on how it works is that rather than mess around getting users to enter hard to read texts (we are just evolving better OCR!) or making humans do simply math (has anyone thought that bots can't do math? ;)   ) why not just make sure there is a javascript engine running?  Its a very simple and brilliant concept that I've found blocks almost 100% of spam bots.  It works by including a hidden form field that needs to be decoded via browser javascript.  Only really drawback in practice is that users have to have javascript running but you can always have the backend kick back a message that tells them that when they submit the form.  They can enable it and then disable it if they are really security conscious.  Anyway, most people need javascript these days it would seem. 
- By ramenudle Date 2009-02-04 20:33
Oh wow.
- By jlnr (dev) Date 2009-02-05 17:08
Now if I knew why the adbots like this topic so much… :)

*goes look at captcha lib requirements*
- By ? Date 2009-02-05 17:38
Yay for reCAPTCHA!
- By ramenudle Date 2009-02-05 21:38
I heard a theory on another board that bots tend to post in the second forum because the first is usually reserved for news posts...so, top thread + second forum is my guess
Up Topic Gosu / Gosu Exchange / Scene or GameState system Tutorial?

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill