Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Forum
Search
Topic Gosu::Window closes itself By ssmfd Date 2018-04-02 10:44
All this time I thought they were read-only...

Well, thank you a lot!
Topic Gosu::Window closes itself By ssmfd Date 2018-04-01 15:32
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 Window.
Topic Gosu::Window closes itself By ssmfd Date 2018-04-01 15:14
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!
Topic Gosu::Window closes itself By ssmfd Date 2018-03-31 19:59
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
   
  end
   
  def update
    @scene.update
    State.reset_all_keys
   
    if !$scale_factor.nil? && !@res_chosen
      close
    end
  end
   
  def draw
    @scene.draw
  end
 
  def scene
    @scene
  end
 
  def scene=(new_scene)
    @scene = new_scene
  end
 
  def button_down(id)
    case id
    when Gosu::KB_DOWN
      State.set_key_down(:down)
    when Gosu::KB_UP
      State.set_key_down(:up)
    when Gosu::KB_LEFT
      State.set_key_down(:left)
    when Gosu::KB_RIGHT
      State.set_key_down(:right)
    when Gosu::KB_RETURN
      State.set_key_down(:return)
    when Gosu::KB_LEFT_ALT
      State.set_key_down(:lalt)
    else
      super
    end
  end
 
  def button_up(id)
    case id
    when Gosu::KB_DOWN
      State.set_key_up(:down)
    when Gosu::KB_UP
      State.set_key_up(:up)
    when Gosu::KB_LEFT
      State.set_key_up(:left)
    when Gosu::KB_RIGHT
      State.set_key_up(:right)
    when Gosu::KB_RETURN
      State.set_key_up(:return)
    when Gosu::KB_LEFT_ALT
      State.set_key_up(:lalt)
    else
      super
    end
  end
 
end

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!

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill