There should be a better way to refer to 'Ocaml to Javascript' code than js_of_caml, maybe ocamlscript? ;)
Anyway, would be nice to hear the author experience using js_of_caml.
EDIT: Is the canvas api the future of web apps? I mean if someone can write such an interactive web app with no 'javascript library of the month' makes you think of all these JS libs doing the same thing over and over, or is Ocaml such a nice language that makes working with the browser much nicer?
I think naming it this way makes a lot of sense, since OCaml has a lot of <target-type>_of_<source-type> functions, so it is a pretty clever nod to OCamls conventions.
jsoo certainly takes some getting used to, especially when it comes to actually having to care about the return types of things. Online documentation is painfully sparse and the ocaml type checker was vague at times, so there was quite a bit of trial and error. It does help that all the library bindings are parallel to their javascript counterparts.
Pattern matching with Ocaml is definitely a plus :P, but I definitely felt that working with Ocaml was substantially more challenging. Especially since none of us had prior experience in game development, much less functional game development, the code we produced was riddled with mutability. It would've helped to look at established design patterns first.
I personally found the jsoo documentation almost unusable (same with Ocsigen). OCaml still has a pretty serious shortage of up-to-date, descriptive documentation, especially outside the Jane Street Core bubble.
I'm really excited to see this project because it's the first jsoo program I've seen with a logical structure and a considerable amount of logic implemented in OCaml that ties into JS.
I'm not sure if it's the fact I'm using a different computer and keyboard to play this than I normally do, but the left/right control seems to be somehow "off". I keep falling in the holes and crashing into enemies.
I have no idea how to word what I mean. Is anyone else experiencing this too?
Also, I can move beyond the beginning of the level. :P
I don't think "simple and use a single set of rules" describes the control code for any shipping (action) game. At least none I've worked on. They're all complex piles of special cases and hacks in an effort to make the movement 'feel' right (which works, but is disheartening at first, until you start to expect it).
You count the time since the last update, wait for the time to accumulate over the update threshold, run the update loop with a fixed time-slice enough times to match whole number of frames. Let the carry over perpetuate to the next frame.
At 144hz with a fixed time-slice set for 60hz, you'd have one update on the 2nd, 4th, 7th, 9th, 12th, 14th, etc. frames.
It's a W3C recommendation that it runs at the native refresh rate of the monitor. I made a pen not too long ago for comparing different types update loops for different browsers. http://codepen.io/SeanMcBeth/pen/MaMjbZ
I tried to stick to statically allocated values, but there is clearly some sort of GC happening in Firefox. Chrome is stable, but Internet Explorer is extremely noisy.
It's a nice proof of concept, though I think the random level generator thing needs a lot of work here. The best you get seems like a random assortment of objects with no rhyme or reason to them, the worst pretty much kills you right away by putting an enemy next to the start position.
Movement definitely feels a bit off, although not the worst I've ever seen in a Mario fan game, not by a long shot.
It is impressive the code compiles down to 128K of js! Makes me rethink using haxe for this sort of thing. Interestingly I think haxe is written in ocaml.
The nice thing about haxe is it has cross platform tooling and libraries for games. The language itself is a little weird and seems homegrown but it works.
Hopefully some of this demo can get rolled into some kind of cross platform game library! I would love to write games in ocaml that target mobile/desktop and web (via js).
Nintendo tends to sue people using the Mario name or any likeness of the character. This is an interesting project, but you are going to get a DMCA pretty quickly.
Nintendo is actually known for not being a PITA to fans who derive their IP, as long as it has no adult nuances. Even then, I've yet to see a DMCA from them.
35 comments
[ 155 ms ] story [ 1630 ms ] threadAnyway, would be nice to hear the author experience using js_of_caml.
EDIT: Is the canvas api the future of web apps? I mean if someone can write such an interactive web app with no 'javascript library of the month' makes you think of all these JS libs doing the same thing over and over, or is Ocaml such a nice language that makes working with the browser much nicer?
I think naming it this way makes a lot of sense, since OCaml has a lot of <target-type>_of_<source-type> functions, so it is a pretty clever nod to OCamls conventions.
Pattern matching with Ocaml is definitely a plus :P, but I definitely felt that working with Ocaml was substantially more challenging. Especially since none of us had prior experience in game development, much less functional game development, the code we produced was riddled with mutability. It would've helped to look at established design patterns first.
I'm really excited to see this project because it's the first jsoo program I've seen with a logical structure and a considerable amount of logic implemented in OCaml that ties into JS.
I have no idea how to word what I mean. Is anyone else experiencing this too?
Also, I can move beyond the beginning of the level. :P
https://info.sonicretro.org/Sonic_Physics_Guide
It's fairly hack free in the abstract. But reality is often a little different, based on the quirks of your collision detection.
At 144hz with a fixed time-slice set for 60hz, you'd have one update on the 2nd, 4th, 7th, 9th, 12th, 14th, etc. frames.
I tried to stick to statically allocated values, but there is clearly some sort of GC happening in Firefox. Chrome is stable, but Internet Explorer is extremely noisy.
The textbooks are "OCaml from the very beginning" and "More OCaml: Algorithms, Methods & Diversions"
#ocaml on irc.freenode.net might be of help for adequate suggestions.
The Functional Approach to Programming (Cousineau)
Movement definitely feels a bit off, although not the worst I've ever seen in a Mario fan game, not by a long shot.
The nice thing about haxe is it has cross platform tooling and libraries for games. The language itself is a little weird and seems homegrown but it works.
Hopefully some of this demo can get rolled into some kind of cross platform game library! I would love to write games in ocaml that target mobile/desktop and web (via js).