Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Gosu question

Not sure if this forum is still alive, but here goes:

I just started using Gosu to make a side-scrolling shooter. I've got the scene system working since that's what I'm used to from RGSS, but something is bothering me. If the user manually closes the game window, it just closes it and leaves the console window open. I'm not sure if there will even be a console window when I export the final product, but is there anyway to detect if the user is closing the window manually (X button) and call $scene = nil?
 
I think you do it like
Code:
require 'stuff'

class Stuff

def some_stuff

end

end

 

w = Gosu::Window.new(640, 480)

w.show

w.show is a loop which lasts as long as the window is open so the code ($scene = nil) has to be put after that.
 
your Scene system shouldn't use a global variable :)
And I'll suggest you use chingu, ( a framework for gosu ) that makes life so much easier.
Among other incredible features, it has something called game_state which is basically the same as a scene :) but works much nicer .

instead of using "$scene = Scene_stuff.new " you call in your window:
push_game_state(Menu) for example
then in the Menu gamestate, you can have "switch_game_state(Map)" etc .. :)

it has a simple fade in/out transition system integrated, and you have methods like "setup" and finalize , to prepare/remove stuff when changing game_states.

gem install chingu :) to install it :) it's all ruby, so no worries.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top