Infinite Mario in HTML5
mario.fromlifetodeath.com
mario.fromlifetodeath.com
I have a fix, if you're interested, in my top-level comment: http://news.ycombinator.com/item?id=2798835
Here's a pull request: https://github.com/robertkleffner/mariohtml5/pull/3 Feel free to comment / add.
All of which is mind-numbingly easy, but far below 50% of "HTML5" games I've played have done so.
Details and papers here: http://www.marioai.org
Video of last years winning entry at work here: http://www.youtube.com/watch?v=DlkMs4ZHHr8
It's pretty interesting, a lot of people wrote/are writing high falutin' machine learning algorithms, but they are consistently trounced by good old A* techniques.
For example, I modified Infinite Mario to become self-repairing: http://www.zenetproject.com/pages/lakitu
I agree, I am also mystified by how people are consistently impressed with game demos that say little more than "See, we can now do some of the things that Flash has been able to do for ten years, as long as you run the right browser."
And if you think about it, mario is usually played on a device where you only have a limited number of buttons. There's no reason to remap the keys if there's only 6 buttons to use.
It's a Tetris clone and very much a work in progress: Only "Standard" mode (and the controls menu) is implemented at all. There's also a simplistic AI and it saves your replays, but none of that is actually integrated into the game interface-wise yet :\
// in Enjine.KeyboardInput
Initialize: function() {
var self = this;
document.onkeydown = function(event) { self.KeyDownEvent(event); }
document.onkeyup = function(event) { self.KeyUpEvent(event); }
},
IsKeyDown: function(key) {
if (this.Pressed[key] != null)
return this.Pressed[key];
return false;
},
KeyDownEvent: function(event) {
this.Pressed[event.keyCode] = true;
},
KeyUpEvent: function(event) {
this.Pressed[event.keyCode] = false;
}
Sheesh. That's why it's jumping up and down when you use the arrow keys. All keyboard input is based on checking `IsKeyDown`, and nothing else. `event.preventDefault()` please. Why do people do this? .preventDefault() is missing in a huge amount of HTML5 demos that aren't full-screen; surely it's not that obscure.edit: seriously, that's all there is to it. Pop open the console / inspector in your browser of choice, and run this:
document.onkeyup = function(event) { Enjine.KeyboardInput.KeyUpEvent(event); event.preventDefault(); }
document.onkeydown = function(event) { Enjine.KeyboardInput.KeyDownEvent(event); event.preventDefault(); }
Viola. No more jumping. No more keyboard scrolling either, which is why you check if the cursor location / last-clicked location is within your canvas.edit2: that aside, very nice work. Smooth playing and so far no glitches, and highly readable code :)
edit3: if you're on IE, that code is `event.returnValue = false` btw. Yaaay, IE :|
For Chrome, there's the built-in de-obfuscator http://www.sitepoint.com/whats-new-in-google-chrome-12/
Crystal
Nope, it's actually open source.
I don't know why they even bothered un-white-spacing it. Doing so doesn't save much space, nor provide any kind of real obfuscation. At best it just makes it un-debuggable (hmm. seems like an oversight (that most debuggers also miss) that you can't set breakpoints inside a single line of code...)
Mario.MarioCharacter.Lives += 1024
Now the challenge is: how far can you get before the game locks up?"Receiving objects: 100% (113/113), 1.07 MiB | 164 KiB/s, done."
Just 1 MB. Further
ubuntu mariohtml5 $ du -k code Enjine/
364 code
68 Enjine/
roughly 400K of code
http://www.microsoft.com/appliedsciences/AntiGhostingExplain...
edit: I'm not sure about this, but I got the idea that it randomly generates the map/levels.
http://www.youtube.com/watch?v=T2OytHzZ72Y
My favorite part is when he misses the goalpost in his first pass and then goes back a second time and hits it.