Show HN: Coffee2D – A simple HTML5 game engine
github.comAs someone who played around with building Isomorphic games in HTML5, well done. The API is fairly clean, and the examples are solid (although the examples link in the README is broken).
Quick question though, as someone who might use / submit a pull request to this project...
Why coffeescript over ES6? As someone who used to use coffeescript for everything, and has since switched to ES6/7, I see coffeescript heading out the door. Not to mention that compilation to ES5 gets quite convoluted with coffeescript, which could lead to performance issues / weird bugs that force you to drop into raw ES5 anyways.
Awesome project, great work!
In regards to Coffeescript over ES6, I still turn to CF for these:
1) postfix conditionals 2) list comprehensions (will probably be in ES7) 3) the .litcoffee format 4) use of -> or => for defining functions unbound/bound to `this` 5) python-escue whitespace (i love it) 6) array slicing (some_array[3 .. 8]) 7) regular expresions defined on several lines (expanded for readability) 8) friendly "item in some_array" that translates to .indexOf() condition 9) @value becomes this.value 10) The existential operator? is awesome. 11) () -> a = 1 b = 2 return { a, b } # becomes: { a: a, b: b }
There are others... I very much enjoy the syntax coffeescript has for its for loops. for value in some_array for value, key in some_array for key of some_object for key, value of some_object for own key of some_object for own key, value of some_object # for-of uses Object.hasOwnProperty()
Coffeescript just needs a for loop form that works with iterators, then I will be happier. I can write in Coffeescript and distribute both that and the compiled JS, no problem. This feels comfortable to me. I hope was ES6 becomes common that Coffeescript's class syntax will "fall through" to the same ES6 way underneath.
You can get ES7+ with babel. http://babeljs.io/docs/usage/experimental/
Sounds interesting. Is there a demo somewhere so that we can see it in action?
Yep, you can clone the repo or just download the examples folder and open the index.html from each example.
Yup, got it. Was just wondering if there was a hosted example somewhere. But maybe I'm the only person who is that lazy?
Either way, looks great so far. CoffeeScript is still my fave.
Just remembered I actually do have a hosted example -> http://gamehack.herokuapp.com/. This was a game I did for a hackathon with an earlier version of the engine. It also uses websockets. You need to open the game in two different tabs to play(open them in Chrome, for some reason inputs are not working in Firefox)
I think your best bet is to download and run the files in the examples folder.