
Making a cross-platform mobile game in Reason/OCaml - jaredly
https://jaredforsyth.com/2018/01/13/making-a-cross-platform-mobile-game-in-reason-ocaml/
======
c-bayprogrammer
The game, Gravitron, looks very similar to an old Ludum Dare entry called
Graviton:

[http://sam.draknek.org/projects/gravity](http://sam.draknek.org/projects/gravity)

(timelapse development video:
[https://www.youtube.com/watch?v=3tQ00R69rF8](https://www.youtube.com/watch?v=3tQ00R69rF8))

It's a really cool game concept, even cooler being written in OCaml! :)

~~~
nerdponx
Not only is this game a total blast to play, but it's also one of the only
games that I think is best played on a trackpad instead of with a mouse.

However if I were the creator of this game, I'd be pretty pissed at the one in
the OP. One was obviously inspired by the other.

~~~
jaredly
Convergent evolution :) I made the version version of Gravitron in 2006

------
faitswulff
/u/jaredly, thanks for posting, this is really exciting! I've been reading
about Reason here and there, and I've always wanted to write a simple game.

At the app/game level, is there any platform-specific code? Or is it all in
src? And to clarify, the big news here is cutting down on the yak-shaving with
the cross-compilers and build systems right? Does it enforce any conventions
on the code? Did you use any frameworks to create the game itself?

~~~
jaredly
In the game, the only place I check the platform is to see how big I should
make the screen (like 3 lines). Everything else is shared! The big news here
is that you can use a single codebase (and a nice advanced language like
ocaml), and deploy to 4 platforms. The framework I'm using is called
"reprocessing", which is a ~port of the "processing" language to OCaml,
targetting OpenGL. It abstracts out the different platforms.

~~~
k__
I guess the Linux port wouldn't be a big thing, but what about Windows?

~~~
drdiablo
We are actively working on it. Linux's well on its way and is much easier than
windows. We're open to PRs ;)

We consolidated web and native desktop in one repo
[https://github.com/bsansouci/reasongl](https://github.com/bsansouci/reasongl).
iOS and android are still out because we're still figuring how everything
should fit together to be useful.

------
niilohlin
Very cool. Hot reloading in iOS would be extreamly useful. I remember that I
used a plugin that was called injectionforxcode but it was not working very
well.

~~~
xfer
There is no hot reloading in the toolchain, but the compiler is very fast. I
am not sure what you mean by xcode plugin, this is a js application, Reason is
syntax for ocaml using bucklescript backend.

~~~
thangngoc89
This is both a native (as in binary) and js application. It compiles down to
binary and uses OpenGL for native targets and WebGL for the web

------
nivertech
Can somebody compare Reason to Elm and PureScript?

~~~
drdiablo
I don't know if you've read this [https://reasonml.github.io/docs/en/what-and-
why.html#why-oca...](https://reasonml.github.io/docs/en/what-and-why.html#why-
ocaml-as-the-backing-language-why-not-my-favorite-language) :)

------
beesmum
Does it only work on desktop browsers?

~~~
beesmum
By which I mean does the version that's compiled for browsers not work on
mobile browsers? I noticed the Gravitron game loads on mobile but the layout
is broken. Is that just a case of not being optimized to work for mobile
browers? Or is there a limitation in the frameworks that prevents it from
working in mobile browsers?

~~~
kbenson
I'm not sure the answer, but since it's for sale on android and ios, I imagine
there's not a lot of incentive for the author to make it work on mobile
browsers if it's easily done.

