Posts

Showing posts with the label JavaScript

Writing an Android application in JavaScript and HTML5

Image
Happy Mother's Day everyone! This year I wrote an Android app for my wife for Mother's Day. How geeky is that? The reason I wrote it is that my wife's favorite Android application, Word Mix Lite, recently added annoying banner ads. While the sensible thing to do might have been to switch to another app, or perhaps upgrade to the paid version of Word Mix, I thought it might be interesting to see if I could write my own replacement. And as long as I was writing the app, I though I'd try writing it using JavaScript. Normally Android applications are written in Java, but it's also possible to write them in JavaScript, by using a shell application such as PhoneGap . Why use JavaScript instead of Java? Well, hack value mostly. On the plus side it's a fun to write! Another potential plus is that it is theoretically possible to run the same PhoneGap application on both Android and Apple. The drawback is that PhoneGap is not very popular yet, especially among Android dev...

Google AI Challenge 2010

Team Blue Iris (that's me!) placed 77th out of 708 in the Google AI Challenge 2010 contest. The contest was to design an AI for a Tron lightcycle game. My entry used the standard min/max approach, similar to many other entries. I guess that's why it performed similarly to so many other entries. :-) I didn't have any time to investigate better algorithms, due to other obligations. In addition to my own entry (which was in C++), I also created starter packs for JavaScript and Google's Go language. These starter packs enabled people to enter the contest using JavaScript or Go. In the end, 6 people entered using Go , and 4 people entered using JavaScript . I'm pleased to have helped people compete using these languages. I initially wanted to use JavaScript and/or Go myself, but the strict time limit of the contest strongly favored the fastest language, and that made me choose a C++ implementation. Practically speaking, there wasn't much advantage to using another ...

Two very good talks on ECMAScript 4, 5, and 6

Yahoo continues to be a source of excellent information on recent and future versions of JavaScript / ECMAScript. Here are two very good talks from November 2009 about the evolution of JavaScript from 2000 until now: Doug Crockford on ECMAScript 4 /5 Brendan Eich on ECMAScript 4 / 5 and Harmony

Brick Break - a Javascript Breakout clone

Image
This weekend I wrote a Javascript clone of the old Atari "Breakout" game. Thanks to the "Canvas" tag it was very easy to write, but I did run into a few problems: Javascript math is always floating point, so I had to use the "Math.floor" function to convert the results of a division to an integer. This was in the brick collision detection logic, where I am converting the ball's (x,y) coordinates to the bricks that the ball might be hitting. I was evaluating document.getElementById too early in the document lifecycle, before the corresponding elements existed. This took me a long time to diagnose -- I ended up just moving the getElementById calls to their run-time use, rather than trying to cache the results. Jack's Brick Break Breakout clone

Dandy in JavaScript

Image
This weekend I wrote a JavaScript version of my old Atari 800 game Dandy. Check it out: Web Dandy It was my first JavaScript application. It was about as easy as writing the Python version. I have only tested it in two browsers so far (Firefox 3.0 and Chrome), and only on one platform OSX. I have already run into differences between the two browsers: Firefox 3.0 for OSX seems to double-post keydown events. No sound or multiplayer yet. Oh, and I use the CANVAS tag, so I think older browsers (like IE 7) won't work.