.rb: 2: in 'read': No such file or directory @ rb_sysopen - GameSettings.json (Errno :: ENOENT)
I'm trying to make a game in ruby
using gosu
, and to be able to change the name of the game without having to change all the variables related to name in my code and other things, I decided to use .json
. Here is the script code ruby
:
require 'gosu'
require 'json'
data_hash = JSON.parse(File.read('GameSettings.json'))
largura = 360
altura = 360
class GameWindow < Gosu::Window
def initialize(width , height , fullscreen = false)
super
self.caption = data_hash['name']
@message = Gosu::Image.from_text(self, data_hash['Author'], Gosu.default_font_name,30)
end
def draw
@message.draw(10,10,0)
end
end
window = GameWindow.new(largura, altura, false)
window.show
and GameSettings.json:
{
"name" : "Heart Afeathered",
"Author" : "Davi Martins Guedes",
"Nacionality" : "Brazil"
}
And when I run that message I put it in the title.