3

I have played with some gosu tutorials to create a simple gosu game using my mac. I followed the instructions in https://www.libgosu.org/ruby.html

My question is: Can a gosu game be set up to run on a website using something like https://github.com/opal/opal-browser using a gem "opal"

Opal compiles the game.rb file but does not add gems. So I get an error, cannot find require file.

I want to set up an index.html page and run the game in a web browser with a button that runs bundle exec ruby game.rb instead of running the file from the console.

This question Ruby: Running Gosu game from a web browser may have asked the same thing but my question is around using Google Native Client tools to solve it.

Robert Jack Will
  • 10,333
  • 1
  • 21
  • 29
Laurie
  • 162
  • 1
  • 11
  • this is a good question, but it's worth showing what you've tried so far. – max pleaner Jan 15 '18 at 01:36
  • Here is what I have done so far. – Laurie Jan 15 '18 at 03:12
  • I built an app using ruby with the gosu gem. It runs on my mac from the terminal ruby game.rb and opens in a console on my mac. I downloaded and installed the SDK from https://developer.chrome.com/native-client/devguide/tutorial/tutorial-part1 and was able to run it and see it in http://localhost:5103/part1 I was also able to see the examples, by running make and make server – Laurie Jan 15 '18 at 03:34
  • Where I think I'm stuck the next steps in applying this to the game I created on my local computer. – Laurie Jan 15 '18 at 03:37
  • I put moved my game directory inside the same folder as the demo and have copied over a Makfile and modified TARGET = my_game, commented out CFLAGS = -Wall, and modified SOURCES = game.rb When I run MAKE, I get an error ... Unrecognized file type. I will work through the NACL docs and watch this https://www.youtube.com/watch?v=Y3YGIMZ6Sw4&t=102s – Laurie Jan 15 '18 at 17:23
  • I updated my question as I am now trying a gem opal. So far I have gotten it to work but it does not compile the gems. – Laurie Jan 16 '18 at 00:35
  • 1
    I think if you aren't able to find any links of people who have done it succesfully or a library, it would probably be quite difficult to get gosu working with Opal, unfortunately. I don't think Opal is quite advanced enough that you can just input any ruby code and output something browser-compatible. You would probably need to use only a subset of the Ruby API and go through the Gosu source to make it compatible, which would probably be a lot of work. – max pleaner Jan 16 '18 at 01:47
  • 2
    It probably isn't the answer you're looking for, but I would recommend re-writing your game in a different framework if you want to run it in the browser. Phaser, Unity, and Unreal are a couple reputable frameworks, with Phaser being the most similar to Gosu out of those three. – max pleaner Jan 16 '18 at 01:49
  • Thanks .. I am coming to that conclusion as well. I was learning with Gosu to help my Ruby skills and embedding was a nice to have. I plan on experimenting with Gosu at the Global Game Jam http://globalgamejam.org Those are helpful suggestions. – Laurie Jan 17 '18 at 00:10
  • I'm happy I was able to get a simple "hello world" file to work in both Opal and nacl and saw that adding the same game files which worked in Ruby did not work in Rails. It's all about experimenting. – Laurie Jan 17 '18 at 00:12
  • 1
    just saying, but would be great to see the gosu api reimplemented with opal-phaser :) – Elia Schito Feb 27 '18 at 23:41
  • That's awesome. I had not heard of opal-phaser. I had learned gosu but was only able to demo/play with it in the console. Will give that a try. – Laurie Mar 01 '18 at 20:41

0 Answers0