This seems to have the same property I've seen in quite a few other HTML5 games: the arrow keys get used for movement but also still get interpreted by the browser to scroll the page. Both seem important: I usually don't want anything to break the arrow keys for scrolling, but on the other hand for something like this I don't really want the page to move around as I play. (Of course, for something like this perhaps the page just needs to become small enough to not need scrolling, which would fix the problem, but the general issue still applies.)
Which is why you restrict it by A) the list of known keys (the values are already in an array in the same file), and if you're feeling nice B) after clicking inside the container the game lives in.
All of which is mind-numbingly easy, but far below 50% of "HTML5" games I've played have done so.
This brings up a good point. The controls are even set swapped compared to gamepads, so using the wrong hand isn't comfortable. Old computer games did use the pc arrows of course. But now since this is a remake of the classic, it should at least be hand aware :)
Now that I think about it, it's really weird. I play FPSes at times, and WASD feels natural, but WASD+JKL for, say, Sega emulation feels wrong compared to ↑←↓→+ASD(/ZXC, for you crazy Japanese-targeted-game fans).
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.
Infinite Mario is actually a rather useful piece of code for all sorts of games research. It's a very good "simplest non-trivial example". The code itself is decently clean, OOP code, which a lot of open-source games, even those written in Java, are not.
Is there anything like this for lua? It might be just the thing to help me finally learn the language (I have an inexplicable dearth of problems to work on in lua)...
Try looking through some of the resources for the Corona game engine (http://www.anscamobile.com/resources/). The SDK compiles Lua source into iOS and Android. I've just started looking at it myself -- it's the first time I have seen Lua code -- and it looks extremely clean.
I don't mean to sound cocky, but I don't get why people are still impressed by simple game demos in javascript. I've been working on a full Metroid-like game (some very old screenshots here http://ektomarch.com/games/) that'll have ~100 rooms, ~40 enemy designs, and a full plot for a year now and I've been doing it at a glacial pace, yet it's still nearing completion. How is it that seemingly nobody has made any real games in HTML5/javascript yet? We've had over a year of nothing but basic demos.
I think its partially that people are impressed by simple things when completed, more than complex things in the works. Looks like you have a cool game, but it will get the attention it deserves when its complete more than beforehand.
I don't think the GP was complaining about lack of attention given to his game, more wondering why nobody else has yet released a full game when he's almost done and not going particularly fast.
"Over a year"? Given that the canvas element was introduced in 2004, I suppose this is accurate.
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."
For Ubuntu (and probably most of the other distros) theres a keyboard layout switcher. I'm sure there's something similar for windows and almost every browser. You can use those extensions to rapidly switch to qwerty layout when needed.
Of course, but why should I need to? Most "real" games let me remap the controls however I like. Is there a technical limitation of html5 that prevents that or is just that nobody bothers to implement it?
Personally, it usually doesn't cross my mind to remap the keys when I make simple games, because I'm so busy thinking about all the logic to actually make the game work. If the game is particularly simple, it's not worth my time to make a settings page anyway.
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 :\
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:
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 :|
It's always disappointing when people's cool demos have obfuscated/minified JS source. It destroys the readability and hackability of the code, and it means that if you find bugs (like I did in this demo) you can't trivially fix them either.
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...)
The three starting lives are actually plenty, I stopped playing out of bordem not game over. By the time I stopped I was sitting at 12 lives and I think I died 3 or 4 times in the process.
The original[1] was made by the Minecraft guy. Like most of his projects, the levels are randomly generated. The levels themselves end, but there is no end to the actual game. It just keeps generating new levels.