9 ms·
Show HN: A WebAssembly game demo
- rossisred 9y agoHello, I have also been taking notes while building this here: http://www.rossis.red/wasm.html http://www.rossis.red/wasm.html I'm happy to answer your questions about it.
- mysterydip 9y agoThanks for sharing, I'll have to digest all of it. How has your experience on the app stores been? Have you seen the conversions you were expecting? How do you plan to continue the freemium model in its web form?
- rossisred 9y agoI plan to keep the web version as a demo for now. It contains the first 4 levels of the game, and after you beat the 4th level it will ask if you'd like to continue to the various stores (App Store if you're on iOS, Play if you're on Android, else Steam). My experience on the stores has been good, people who play the game seem to enjoy it. The hard part has been discovery :)
- Retr0spectrum 9y agoJust a heads up, I find the font+background colour combination on that page very hard to read.
- kowdermeister 9y agoI second that claret / green combo is a no go, I thought page was broken.
- rossisred 9y agoSorry, I got a bit carried away on the colors. I've made a few quick style tweaks that hopefully make it easier to read.
- markdog12 9y agoReally cool project. Just tried on my Moto E 2nd gen with Chrome and it was smooth as butter. Are you storing images as svg inside the wasm blob? Seems like you're not batching draw calls? Was the Dart app not fast enough?
- rossisred 9y agoThe 2D elements (menu buttons, background trees, etc...) enter the game's editor as SVG, where they get converted to an intermediate vector format that is optimized to be loaded and rendered fast. That intermediate format is what's inside the wasm blob. Regarding draw calls, I could definitely batch more than I do. But the game is rarely draw-call-bound so I haven't had a reason to optimize that part of the graphics pipeline. Dart is still used in the game's editor, which has been stable for a couple of years now. For the production engine, C++ just makes too much sense. It is what made this WebAssembly demo possible :)
- binji 9y agoVery nice write-up, thanks! BTW, I also ran into issues with ScriptProcessorNode when generating audio, and ended up using `createBufferSource` with a scheduled playback time. I wrote a little about it here: https://binji.github.io/2017/02/28/binjgb-on-the-web-part-2.html https://binji.github.io/2017/02/28/binjgb-on-the-web-part-2....
- rossisred 9y agoThanks for sharing! Your article is what I was looking for and didn't find when I was working on the audio :) That is an interesting approach which I will definitely try.
- valuearb 9y agoWhy doesn't it load in Safari or Chrome for Mac?
- rossisred 9y agoIt should work in Chrome 57 or higher or in Firefox 52+. Support in Safari is not yet released as far as I am aware.
- valuearb 9y agoI have Chrome 58. Wasn't working yesterday, works today. Also, your page now says "Sorry your browser does not support WebAssembly" in Safari, yesterday it didn't.
- zengid 9y agoYour game is amazing! I'm particularly intrigued by the 3D-ness of the sprites and how smooth all of the animation is. Can you suggest any resources for learning more about the process of making similar content (without giving away your secret sauce, of course)?
- rossisred 9y agoThanks! The characters are regular 3D models. The 2D elements are where the game differs from a lot of other games. If you use vector graphics the size of your assets will decrease dramatically, and your game will be resolution independent. Regarding animation, this is a good resource to get started: http://robertpenner.com/easing/ http://robertpenner.com/easing/
- swah 9y agoIts very crazy how well this runs compared to the Js games we tried... why is that?
- rossisred 9y agoThat is a difficult question to answer as there are many factors involved, not just the choice of language. JavaScript can be really fast, but WebAssembly may provide more predictable performance and faster loading times. The project website is a good resource to learn about the differences: http://webassembly.org http://webassembly.org
- sova 9y agoYou're a king
- ninjakeyboard 9y agoNice work! Looks really good.
- shurcooL 9y agoWow, that is a really well polished, completed, and neat little game. Makes for a great WebAssembly demo given how quickly it loads and how much value you get out of it. It runs and looks fantastic at 2560x1600 fullscreen too (on a laptop made in 2011).
- floor__ 9y agoAwesome demo, I was surprised how smooth it was.
- DarkTree 9y agoSeems to load and run faster than most webpages. Really cool and a promising example of WebAssembly
- Retr0spectrum 9y agoDefinitely a well made game, but I don't think it would really fit with the Steam store. It looks like it's doing well on the play store however: https://play.google.com/store/apps/details?id=rocks.funkykarts https://play.google.com/store/apps/details?id=rocks.funkykar...
- rossisred 9y agoThe game is popular on the Chrome Web Store, and ~30% of those users are on Windows. Chrome Apps will stop working on Windows later this year, and Steam seems like a good place for them to transition. A full blown web version is another possibility.
- Retr0spectrum 9y agoWhat engine/tools was this made with?
- rossisred 9y agoThe game has its own custom engine and tools. The engine is in C++ and is small which made WebAssembly a great fit.
- z3t4 9y agoThe game looks good. But I'm a bit skeptical of web-assembly after the flash era, where games did all kind of nasty stuff. I know "it's just javascript" but I feel unease having a binary blob of code running on my machine, at least with "javascript" you can view the source code. I do have JavaScript disabled by default btw. I also know that png images are also binary blobs, yet I allowed them, even though there have been exploits, but I feel that png rendering is more hardened, and can do far less, then web-assembly.
- swolchok 9y ago> at least with "javascript" you can view the source code minified and/or optimized JavaScript is generally not human-readable. Try view source on some major websites.
- z3t4 9y agoThey minify the JS because 1% reduction in file size will save them thousands of dollars in bandwidth costs. Most web sites doesn't, even HN doesn't minify. Then there's those who obfuscate their code because they don't want their visitors to know what the code does. With JavaScript though you can, within the browser (no extra tools needed, just right click and inspect), beautify the code and set breakpoints etc.
- pjmlp 9y agoApparently FF nightly already has support to show WebAssembly, but it will be no different than looking at straight Assembly.
- opendomain 9y agoWeb Assembly is NOT javascript. It literally is assembly for the web. There are transpilers that converts higher level code (C#, Go, Python) to Web Assembly, but the end result is always byte code that is run by the browser. You may be confused with ASM.Js, which IS javascript. It is a very optimized version that uses a similar idea of a CPU instruction set (get register, add, branch on flag, push on stack, etc), but it still is interpreted. ASM.Js is very fast and also has some transpilers, but it is very different from Web Assembly. Web Assembly has the highest potential. High potential for speed, calculations, AND RISK. The threat model for Web Assembly has not been tested as well as Javascript.
- pjmlp 9y agoNice work, I enjoyed playing it.
- faitswulff 9y agoLooks great, and it's snappy! Is "Dartmobile" a reference to Dart the programming language? It's the same color scheme :p
- rossisred 9y agoYes it is :) Fun fact: the first prototype of the engine was built in Dart and later re-written in C++ for production.
- bombita 9y agoCan you share the prototype? I am excited for reading interesting Dart apps in the open.
- wutbrodo 9y agoBack when Dart first came out (I think 0.1), I built a gravity simulator in it. It was a shameless rip-off of http://www.nowykurier.com/toys/gravity/gravity.html http://www.nowykurier.com/toys/gravity/gravity.html, but it was just for me to get a little familiar with it. It was pretty dang great writing that project, and I'm beyond surprised that Dart didn't have more success in replacing JS. I unfortunately lost the source code at some point :( (this was before I got organized, got a GitHub, etc).
- simplify 9y agoVery nice. The levels are well-designed from a game design perspective, too.
- valuearb 9y agoI don't get it. I just see their home page with just a picture and links to app stores. Tried Chrome and Safari.
- shodan757 9y agoI just get "Sorry, but your browser does not yet support WebAssembly." I'm on Firefox/Linux. Other WASM demos work, so I'm pretty sure that's a bug. :)
- rossisred 9y agoThanks for the heads up, that is curious. I don't have access to a linux machine at the moment, but will investigate later. There should be some output from binaryen in the JavaScript console, does it report success?
- shodan757 9y agoSeems to be something with multiprocess (aka e10s) Firefox. I can't get webassembly to work anywhere now... I swear it worked before.
- artursapek 9y agoI get the same error, in Chrome 56.0.2924.87 on Ubuntu 16.04. Console: http://i.imgur.com/hVNCskv.png http://i.imgur.com/hVNCskv.png
- rossisred 9y agoWebAssembly support landed in Chrome 57 :)
- artursapek 9y agod'oh, thanks
- calcifer 9y agoFWIW, it works fine for me on Linux with Firefox 53.
- freekh 9y agoWorks flawlessly on my Firefox 53 (and Chrome) on (Arch) Linux.
- bobajeff 9y agoIt doesn't seem to load right in my Nexus 6 Android Chrome 58. Only the bottom left of the canvas is showing the game the rest is a lite blue box. Edit: however it displays correctly in Firefox 53.0.2 (Android) on the same phone.
- kristianp 9y agoIt works on my old Android 5 phone in Chrome 58. Amazing that it's supported so quickly at this stage of wasm development.
- Tistel 9y agovery nice. I like the wall jump mechanic.
- zokier 9y agoBackground music does not work for me (Fx/Win10). Devtools console says "Unsupported sample rate : 48000"
- rossisred 9y agoI wrote about this in my audio article [1]. Ideally, browsers will implement support for a configurable `sampleRate` in the `AudioContext` constructor. There is a tracking issue [2] for Chrome but I wasn't able to find one for Firefox. [1] : http://www.rossis.red/wasm.html#audio http://www.rossis.red/wasm.html#audio [2] : https://crbug.com/432248 https://crbug.com/432248
- dccoolgai 9y agoThis represents simultaneously everything that makes me hopeful about WASM - a really clean, fun and nice game that performs super well - and everything that makes me dread it. I was curious so I opened up https://www.funkykarts.rocks/demo.wasm https://www.funkykarts.rocks/demo.wasm and there's nothing there that I can really read and learn from. I'm not saying it isn't worth making the trade, but it seems like a fundamental change to a part of the web I really loved - the ability to read and learn from things you experience that are cool - that doesn't seem to be considered very much and it makes me a little sad to see its inexorable end spelled out. I think I'll soon miss the days where we all had to show each other our code on the web.
- shurcooL 9y agoDon't you still have that place, for example GitHub, where open source code lives in non-minified, non-obfuscated form, together with a README, an issue tracker, etc.? Why do you need to rely on the production binary to be human readable? Should web developers be forced to open source all their work, whether they want to or not, because of technical limitations of the web implementation? > I think I'll soon miss the days where we all had to show each other our code on the web. All of my code is open source, you're welcome to look at it. That's not changing because WebAssembly is coming out.
- nathcd 9y ago> Should web developers be forced to open source all their work, whether they want to or not Yes - that's how the web works (barring obfuscation/minificaction). And it's how wasm will work too: http://webassembly.org/docs/text-format/ http://webassembly.org/docs/text-format/.
- dccoolgai 9y ago"Should web developers be forced to open source all their work, whether they want to or not" Yes. If they want it to run on the Web. That's the way it currently is and that's the thing I'm saying I'll miss. You don't have to put any of your code on the Web, but when you do I can read it. I like that.
- deleted 9y ago[deleted]
- sofaofthedamned 9y agoThat is so smooth and beautiful, physics are great too. Nice!
- hashhar 9y agoThis looks amazing and is buttery smooth. Loads and runs faster than most webpages even. Takes even less than 10% of my CPU (i5-5200U). Really excited about what WebAssembly brings to the table. But sadly the WASM is an opaque format and I couldn't learn anything about the demo.
- baby 9y agoThis is amazing, and it runs soooo well. At the same time it makes me miss Flash. I know it's easy to hate on flash, it was kinda buggy/slow and it was also crazily insecure. But the web really got interesting with flash, people were creating games, animations, interactive websites. All the websites are pretty static/flat nowadays. Even if from a design point of view they might look "nicer", I liked the Flash era.
- inDigiNeous 9y agoDefinitely runs well. Silksmooth even on my older 2010 MacBook Pro with a recent Firefox on Os X. Would he happy to hear more on how they compiled from their custom engine to this webasm target.
- tarr11 9y agoYou can build some pretty cool games with libraries like phaser.io. Here's an example: http://www.gunfight.io/ http://www.gunfight.io/
- REEKAH 9y agoSpeaking of WebAssembly and games, has anyone tried building their Unity projects in WebGL and exporting in Web Assembly? I hear they have that feature in the latest 5.6 version
- irrlichthn 9y agoIt works nicely, your users have to download a ton of data, though. Long loading times. For nicer results, use something lightweight like CopperCube, or use a hand written lib like three.js.
- TheRoccoB 9y agoYes. It works well, although I paid for a fancier demo and exported it, and it crashed occasionally. They've done a pretty good job with compressing the assets too. Good weissman score.
- nafizh 9y agoOn my Linux Chrome with version 55 - it says, "Sorry, but your browser does not yet support WebAssembly."
- mrdoob2 9y agoYes, I think you need Chrome 57+.
- alexpw 9y agoMy mbp fans kicked into overdrive, reminding me that this is a browser game, but otherwise, I echo the sentiments that it loads fast and is really fun.
- fattire 9y agoIn related news, it looks like Unreal Engine just today came out with an update for "HTML5 Support for WebAssembly and WebGL 2". This seems huge as there are a lot of games written with the Unreal Engine I'd love to see come to the web. https://www.unrealengine.com/en-US/blog/unreal-engine-4-16-released https://www.unrealengine.com/en-US/blog/unreal-engine-4-16-r...
- Kiro 9y agoOT but how is the coin sound played without user input? Is it a WebAssembly thing enabling passive sound triggers?
- runarberg 9y agoIf I remember correctly iOS is the only platform were that limitation ever existed. https://stackoverflow.com/questions/12517000/no-sound-on-ios-6-web-audio-api https://stackoverflow.com/questions/12517000/no-sound-on-ios...
- Kiro 9y agoI get it on my web game on Android: Uncaught (in promise) DOMException: play() can only be initiated by a user gesture. It's triggered in the game loop where the user event has been added to a queue so it's not in the same call stack. The coins are picked up in the air etc so I have a hard time believing they are within the same call stack since it's long after the jump.
- lkurusa 9y agoInteresting, wish it was also written in traditional JavaScript, so the performance could be crosschecked. Thanks for the game, most enjoyable!
- hamdusa 9y agoVery nice game. Runs really smooth on my Firefox 53 Win10. I played just 2 levels and its an excellent one and really enjoyed playing it. I also checked the console, and found this that may be of interest to you: [WARNING] trying binaryen method: native-wasm demo.js:1:6927 [WARNING] asynchronously preparing wasm demo.js:1:6927 [WARNING] binaryen method succeeded. demo.js:1:6927 Unsupported sample rate : 48000 demo.js:1:1633