The Montoya Herald — ChristianMontoya.com
I've spent the past few days doing three things:
I'm here to talk about the last one I mentioned. I decided to get some practice with Javascript by making a web game, and I decided to port one of the games my lab partner & I programmed for our ECE 476 final project. Now I know the idea of making a game with Javascript & CSS sounds crazy, but I had a few good reasons for giving this a shot:
So I dove in. I made a game using jQuery with quite a bit of DOM manipulation and a few fade effects, as well as some Ajax requests talking to a PHP backend using a text file to store high scores. It was a big challenge at times but I was able to figure out most everything with the help of the jQuery site as well as php.net. Some things I discovered:
So putting it all together, my result is here: Tunnel. To explain, it's a very basic game where you use the mouse to move your ship left and right. As you play, the walls narrow until eventually you have about 2 widths of your ship to fly between. The game ends when you die, and your score gradually increases as long as you live. When you die, your score is checked against the top 10 and if you get a high score, you enter your name to put yourself on the list. It's not too complicated and you can check out the source to see everything that's going on at the front-end. I should mention, however, that this is my own work, so you can't steal it and put it on your own site. Plus, it has a couple bugs that I think are worth mentioning:
All that being said, the game works pretty well and I think it's a good example of what can be accomplished with Javascript & CSS. Feel free to have a look at it, learn from it, and get your own ideas. If you happen to use any of my code or ideas, please do give credit where credit is due. And I dare you to beat my high score
p.s.: Want to know what's cool about making a game with Javascript and CSS? It works even when images are disabled! Disable images in your browser and check out the game to see what I mean.
Sorry, comments for this entry are closed at this time.
Great work!
It works a lot faster on IE7 than in Firefox 2.0 on Windows XP (it's not the bug, it's just the Javascript handling)
Okay, I think 129's my best for tonight =)
Haha, nice!! I only got up to like 36 points. Oh well. Better luck next time!
yawn Good morning. You know, I think that the path stopped decreasing in size after 90 or so… theoretically, even the so-called "hacks" (i.e., the higher scores) are reachable using the same technique I'm currently using without cheating. I am using IE7 on Windows XP, and the game seems to be running smoothly.
"I dare you to beat my high score" — Done. Darn peer pressure…
Of course the path stops decreasing in size, otherwise there would be an upper limit to the score you could acheive.
Still, it seems like the path could decrease in size once more or so and still be playable.
kramtark: It could, but it would be incredibly hard… if you are playing the game at full speed (in IE, for example) then I think you might agree. Plus, not everyone is a pro like you… I could add multiple difficulty levels though… that sounds like an idea!
It's too fast on Chrome. Use a slower wait period . . . 2 ms is too short! No one needs 500 FPS on a game like this.
You are correct sir, I just tested it in Chrome and it is waaaay too fast. I'll fix it.
Not too bad. Regarding your first point and that most recently raised in the comments, you don't really need to buy Flash development software to compile a SWF–plus I imagine it would be easier to guarantee a consistent experience using a VM whose authors are working to ensure browser compatibility, versus a language where the implementation is solely up to the browser vendor. Then again, Flash is my livelihood, so I might be biased ;).
PS - How's life in the far (north)east?
PPS - I'm drunk.
Well, there is a way to ensure that Javascript FPS are the same in every browser, and I've tested and confirmed this method, but I haven't actually had a chance to post a demo of it. I'm too busy with other things these days. And… I don't try to beat Flash with Javascript like I used to.
NYC is a cool place. I'm always too busy though.