orbitalimpact / opal-phaser

A fast and free Opal wrapper for the Phaser framework to develop browser-based games in Ruby!
http://opalphaser.com/
101 stars 9 forks source link

So many APIs missing #18

Open taw opened 8 years ago

taw commented 8 years ago

Hi there.

Once upon a time me and @ant0 wrote a bunch of fun minigames and demos with phaser, but since we didn't want to get in JS mess we used coffeescript for it - https://github.com/taw/phaser-minigames

Once I found opal and opal-phaser the obvious idea was to continue that in ruby instead - https://github.com/taw/phaser-opal-minigames

Unfortunately I keep running into missing APIs a lot. For now I'm just monkeypatching them one at a time [ https://github.com/taw/phaser-opal-minigames/blob/master/app/common.rb ], but it would be nice to do it more systematically and do some proper PRs.

So a few questions:

  # This is fairly verbose
  def x=(x)
    `#@native.x = x`
  end
  # This even more so
  def initialize(_x = 0, _y = 0)
    if `typeof(#{_x})` == "object"
      super(_x)
    else
      @native = `new Phaser.Point(#{_x}, #{_y})`
      super(@native)
    end
  end

Either way, I'll probably make some PRs once I stop running into new issues.

ylluminarious commented 8 years ago

@taw Hi,

As you've probably seen from the log, there hasn't been activity in a while. The reasons being that we (i.e., the core contributors) have been busy with "real work" and I myself have been in school for about 10 months now and have thus been scarcely able to do anything in the realm of software development for extended periods of time (the only times where I actually did do software development were when I was supposed to be doing homework, which led to more headaches and less time in the long-run). I just started summer break a few days ago, and opal-phaser is pretty high on my todo list so I will hopefully be cranking out some commits sooner than later. I.e., I will start working on making opal-phaser APIs more complete again.

Also, for the aforementioned reasons, you are correct in assuming that we're working on an older version of Opal simply because nobody has bothered to bump it yet. That is another thing which I'm hoping to rectify in the very near future; I (or someone else) will have to test newer versions of Opal with opal-phaser and see how well it works out since there have been no breaking changes AFAIK, but I could be wrong. Additionally I agree that attribute writers and constructors are weird. I'm not quite sure what to do about attribute writers since assignments are really just methods in Ruby, unlike in JavaScript (at least as far as I understand JavaScript), so those help Ruby-ize things. The constructors were put in place because some methods require specialized support to work in Ruby and cannot be copied right out of the box from their JavaScript counterparts. I'm very hopeful, though, that the new .JS syntax which was introduced in Opal 0.9.0 will significantly mitigate these issues in a very direct way. The docs about it are here, under "Calling JavaScript Methods": http://opalrb.org/docs/guides/master/compiled_ruby.html.

Concerning snake_case vs camelCase, we've been using snake_case so far because it is more Ruby-like, but I wouldn't be opposed to supporting both. I don't think it's very important for documentation since @zcassini has done docs with snake_case AFAIK (on his opal-phaser fork which I also haven't gotten around to merging yet 😔).

Lastly, regarding testing, we have a few specs so far and have opal-rspec included in the dependencies, but I haven't gotten around to doing serious testing yet mostly because I don't much like testing and have been trying to put it off for as long as possible :P

PRs are certainly welcome and I will probably be merging @zcassini's fork which adds significant documentation sometime in the next week or so, as well as some other changes mentioned above.

taw commented 8 years ago

@ylluminarious Well, I PRed opal dependency bump to 0.9.2+ as there's no point developing against old version. It would be nice if you could test and merge that sometime soon.

I could just extract:

from my project into a pull requests, but I'm only testing it on opal 0.9.2.

ylluminarious commented 8 years ago

@taw Yes, I saw your PR on opal-pixi. I'm going to try and test it out today or tomorrow and see if it has broken anything. Your other PRs sound fine too.

taw commented 8 years ago

Yeah, these are https://github.com/orbitalimpact/opal-pixi/pull/2 and https://github.com/zcassini/opal-phaser/pull/1

ylluminarious commented 8 years ago

@taw In case you haven't noticed, I've gone ahead and merged that PR on opal-pixi as well as your commits on @zcassini's fork. I've also merged some changes that @zcassini made for the docs and so forth, and I'm going to add on to those as well as fix any potential bugs introduced by your and his changes.

Sorry for the delay, btw; it's been a rather hectic time for me over the past few months.