News for hackers. Stuff that matters.
Re:MariOCaml: HTML5 Mario, written exclusively in OCaml by asimjalis on Sunday December 20, 2015 @08:38PM (#10769104)
You should put this link to the demo https://mahsu.github.io/mariocaml/ at the beginning of your README.md.
Re:MariOCaml: HTML5 Mario, written exclusively in OCaml by i336_ on Sunday December 20, 2015 @06:04PM (#10768681)
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

Re:MariOCaml: HTML5 Mario, written exclusively in OCaml by mahsu on Sunday December 20, 2015 @06:45PM (#10768809)
The movement is really hacky (https://github.com/mahsu/MariOCaml/blob/master/object.ml#L16...), whereas the actual game takes a more fine-tuned approach (http://s276.photobucket.com/user/jdaster64/media/smb3_physic...). It was tough to keep things simple and use a single set of rules without making everything too floaty or heavy.
Re:MariOCaml: HTML5 Mario, written exclusively in OCaml by yoklov on Sunday December 20, 2015 @07:32PM (#10768939)
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).
Re:MariOCaml: HTML5 Mario, written exclusively in OCaml by striking on Sunday December 20, 2015 @08:23PM (#10769070)
The Sonic Physics Guide is how I implemented my first (good) platformer physics.

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.

Re:MariOCaml: HTML5 Mario, written exclusively in OCaml by striking on Sunday December 20, 2015 @06:11PM (#10768701)
I agree. It's difficult to get platformer physics right the first few times around, though. It's deceptively difficult.
Re:MariOCaml: HTML5 Mario, written exclusively in OCaml by joshschreuder on Monday December 21, 2015 @01:00AM (#10769818)
I think Mario has more inertia here than in the actual Mario games, he seems to slide forwards rather than stop as quickly as I would expect.
Re:MariOCaml: HTML5 Mario, written exclusively in OCaml by TronPaul_ on Sunday December 20, 2015 @06:26PM (#10768759)
144hz monitor here. Pretty sure the game is tuned for 60fps and thus 144hz monitor is playing like turbo speed.
Re:MariOCaml: HTML5 Mario, written exclusively in OCaml by prezjordan on Sunday December 20, 2015 @06:35PM (#10768790)
Same :) requestAnimationFrame is a very short tick on 144hz monitors.
Re:MariOCaml: HTML5 Mario, written exclusively in OCaml by mahsu on Sunday December 20, 2015 @06:58PM (#10768851)
What would be the best way to throttle fps and ensure compatibility between different refresh rates?
Re:MariOCaml: HTML5 Mario, written exclusively in OCaml by moron4hire on Sunday December 20, 2015 @07:14PM (#10768884)
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.

Re:MariOCaml: HTML5 Mario, written exclusively in OCaml by TronPaul_ on Sunday December 20, 2015 @10:12PM (#10769363)
The best way is usually to not tie game state to frame ticks. See Bethesda's Creation Engine https://www.youtube.com/watch?v=Yuyp-S7FPNI for why that's a bad idea.
Re:MariOCaml: HTML5 Mario, written exclusively in OCaml by yoklov on Sunday December 20, 2015 @07:24PM (#10768915)
Does RAF really run at 144hz on those monitors? That's surprising... and means I probably need to fix some code before those get more common.
Re:MariOCaml: HTML5 Mario, written exclusively in OCaml by moron4hire on Sunday December 20, 2015 @07:32PM (#10768936)
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.

Re:MariOCaml: HTML5 Mario, written exclusively in OCaml by arh68 on Sunday December 20, 2015 @06:09PM (#10768692)
If you don't have the 3110 tool installed, you can call ocamlbuild directly just fine:

    ocamlbuild -use-ocamlfind -pkgs js_of_ocaml,js_of_ocaml.syntax -syntax camlp4o main.d.byte
Re:MariOCaml: HTML5 Mario, written exclusively in OCaml by robohamburger on Monday December 21, 2015 @02:53AM (#10770089)
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).

Re:MariOCaml: HTML5 Mario, written exclusively in OCaml by Scarbutt on Sunday December 20, 2015 @05:15PM (#10768503)
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?

Re:MariOCaml: HTML5 Mario, written exclusively in OCaml by LeonidasXIV on Sunday December 20, 2015 @05:20PM (#10768519)
I don't get your criticism, what is the problem?

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.

Re:MariOCaml: HTML5 Mario, written exclusively in OCaml by Scarbutt on Sunday December 20, 2015 @05:27PM (#10768548)
Oh didn't know that, thanks for clarifying, received my ocaml book last week but haven't started.
Re:MariOCaml: HTML5 Mario, written exclusively in OCaml by mahsu on Sunday December 20, 2015 @07:09PM (#10768873)
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.

Re:MariOCaml: HTML5 Mario, written exclusively in OCaml by djur on Sunday December 20, 2015 @10:07PM (#10769354)
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.

Re:MariOCaml: HTML5 Mario, written exclusively in OCaml by VeejayRampay on Sunday December 20, 2015 @05:24PM (#10768536)
js_of_ocaml is very Ocaml-idiomatic.
Re:MariOCaml: HTML5 Mario, written exclusively in OCaml by GreaterFool on Sunday December 20, 2015 @06:27PM (#10768762)
It is sometimes referred to as `jsoo` which confused me the first time I saw it without context ;)
Re:MariOCaml: HTML5 Mario, written exclusively in OCaml by DiabloD3 on Monday December 21, 2015 @04:58AM (#10770383)
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.
Re:MariOCaml: HTML5 Mario, written exclusively in OCaml by stelonix on Monday December 21, 2015 @05:34AM (#10770478)
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.
Re:MariOCaml: HTML5 Mario, written exclusively in OCaml by canttestthis on Monday December 21, 2015 @11:36PM (#10775851)
This is not true for their Pokemon IP. They have DMCA'd fansites and fan-made Pokemon MMOs aggressively in the past.
Re:MariOCaml: HTML5 Mario, written exclusively in OCaml by CM30 on Monday December 21, 2015 @02:45AM (#10770069)
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.

Re:MariOCaml: HTML5 Mario, written exclusively in OCaml by azakai on Sunday December 20, 2015 @05:21PM (#10768528)
No link to play the game?
Re:MariOCaml: HTML5 Mario, written exclusively in OCaml by nononoxd on Sunday December 20, 2015 @05:54PM (#10768648)
Re:MariOCaml: HTML5 Mario, written exclusively in OCaml by azakai on Sunday December 20, 2015 @06:01PM (#10768671)
thanks!
Re:MariOCaml: HTML5 Mario, written exclusively in OCaml by agumonkey on Sunday December 20, 2015 @06:52PM (#10768831)
Pretty smooth, even on my old laptop. Kudos.
Re:MariOCaml: HTML5 Mario, written exclusively in OCaml by brunoc on Sunday December 20, 2015 @07:40PM (#10768957)
I'm just about to start a course that uses OCaml for teaching. Any book or website recommendations?

The textbooks are "OCaml from the very beginning" and "More OCaml: Algorithms, Methods & Diversions"

Re:MariOCaml: HTML5 Mario, written exclusively in OCaml by ericssmith on Sunday December 20, 2015 @08:07PM (#10769023)
Real World OCaml https://realworldocaml.org

The Functional Approach to Programming (Cousineau)

Re:MariOCaml: HTML5 Mario, written exclusively in OCaml by titanix2 on Monday December 21, 2015 @03:18AM (#10770157)
I didn't try it but given the labs and research interests of the teachers who made it, it is probably good: https://www.france-universite-numerique-mooc.fr/courses/pari...
Re:MariOCaml: HTML5 Mario, written exclusively in OCaml by agumonkey on Sunday December 20, 2015 @07:55PM (#10768989)
which univ ?

#ocaml on irc.freenode.net might be of help for adequate suggestions.