Hi, everyone! It's my first post here, so I'm sorry if I make some mistake. Also, english isn't my first language, so... yeah.
As the post subject says, I have a problem with Gosu::Window. I just started a new game a few days ago, and I've been able to evade most obstacles, but not this one.
The problem is this: after an apparently random amount of seconds, the windows closes itself. Interestingly, the program doesn't finish. The 'show' loop continues, as I have to CTRL + C in the console to actually end the program, which ends in "Interrupt".
Is this a known issue? Maybe I just hit a corner case. I've tried several Ruby-oriented game frameworks before and, honestly, I like Gosu the most. I don't want to have to change it.
I use Windows 10, Ruby 2.3.3 and the most recent version of Gosu. Here's the main part of the code; the window (other classes manage different things; if this piece of code isn't enough, I'll post more).
class Main < Gosu::Window
def initialize(scale_factor = 2, res_chosen = false)
super 320*scale_factor, 240*scale_factor
self.caption = "Game"
@res_chosen = res_chosen
@res_chosen ? @scene = Title.new : @scene = ResChoice.new
if !$scale_factor.nil? && !@res_chosen
@scene = new_scene
Main.new.show if __FILE__ == $0
$main = Main.new($scale_factor, true)
$main.show if __FILE__ == $0
Sorry if I missed something. I've been using Ruby for years but I still a pretty noob programmer, haha. Thanks in advance!
I have noticed two things. The first thing would be the two loops you create at the end of the main script. You only need call one of them! The latter would be the strange condition you set in the update method that should close the game window. Why don't you try solving the issue by removing it?
Window.show calls at the end of the file are a little odd but shouldn't be the issue, because the second window will only be created and shown after the first window's
show method returns (because it was closed).
Code looks good, but I don't know what Title and ResChoice do. I would suggest isolating the issue by commenting out parts of the source code to see at which point the problem goes away.
Gosu also swallows some exceptions and re-raises them later. If there's a bug in this part of Gosu, it can happen that exceptions just disappear altogether (this has happened before) :/
Thank you both! I know it may seem weird, but that's because I'm trying to create a way to make some kind of GUI for the player to change the screen size and toggle fullscreen.
I've been playing around, trying to figure out what might be wrong, and I've concluded the 'double window' HAS to do with the problem. If I stay long enough on the first spawned window, even if I smash the keys around to see if I can trigger something, nothing happens. However, the window closes ONLY if the one opened is the second. Sometimes even without me having to do anything; just wait.
So, being that I don't have the abilities to fix that just yet, and that I don't feel this is an easy problem to solve, I decided to eliminate that part of the code altogether. I'm considering include a little external program to manage the settings. Like those old 'setup.exe' from some games that helped you with the game settings, as I believe it's impossible to do from Gosu itself for the moment (unless I use Gosu itself as the external program... I may try that).
Just for information: Title is the class that manages the title screen, and ResChoice manages the screen size selection menu, which goes before the title.
Anyway, sorry for the inconvenience. I hope the next time I post something is the finished game, haha. I'm sure you'll like it!
FYI, some recent Gosu version fixed window size handling, so you can easily switch fullscreen mode, and probably resolution, in-game with no need for some additional windows.
That sounds interesting, at least to try. How do I do that? I mean, as far as I know, to set the window size and fullscreen mode you HAVE to do it from the
initialize method in
All this time I thought they were read-only...
Well, thank you a lot!
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill