Coding for your kid

February 26th, 2005 by Hen

Back when I was a wee youngster, we bought a BBC Basic model ‘B’, the draft-horse of the 80s British education system. As we all did, I learnt to program a bit etc etc. My dad also did some programming (with a bit of Fortran experience from the decade before I think) and wrote two applications for my sister and I.

The first was a mathematics quiz program. Simple stuff, but nicely laid out so it was more than just questions on the command line. The second was a graphics program that he ended up playing with more than we did and discovering the limits of his environment (his program listing got too large to load into memory).

So if nothing else, I want to write programs for my child(ren). The first game is called Pound and is wonderfully simple (so easy to code, or would be on a BBC model ‘B’). Each key that is hit on the keyboard translates to a sound (musical note) and a change to the screens colour. Baby sits and hits keyboard, learning that the keyboard leads to two repeatable events.

Musical notes are bizarrely complex in Java; you have to use the javax.sound.midi package to create them. A bit of googling put together the system needed, and sounds pretty good once you put in a bugfix for 1.3/1.4 JVMs as well. For the colours, I just change the background of a Canvas object; the tricky part with the colours is coming up with an exciting set of colour changes that won’t turn into an epileptic strobe effect.

My current algorithm is to treat the key’s ascii value as a streaming cipher. Key pressed equals the blue of the background’s rgb. The last backgrounds blue is the green, and the previous ones green is the red. This creates some nice colours, doesn’t strobe easily and encourages use of more than one part of the keyboard as it tends to grey quickly if the same key is hit repeatedly. Bad side is that the colour is not repeatable.

We tried Nathan out on it this morning, and it seemed to go well. It was near nap-time so he got tired quickly, and was wet, but he still wanted to hit the keyboard to make more noises so I think it was a success. Now if only there was a way to get the joy of seeing your child use a program you wrote into every coder/user relationship :)

2 Responses to “Coding for your kid”

  1. Ron Says:

    That’s funny, I wrote some games like this for my kid and so did a coworker of mine.

    One thing I wrote was: as you move the mouse around, it plays a song, with the tempo depending on your mousing. For the songs I wrote a parser for BASIC “PLAY” strings and scoured the web for .bas files. Good times

  2. steve Says:

    The similarity between a baby and most of my users is striking. Pretty colours seem to get them excited - although if they wet themselves they kept quiet. The fairly random striking of keys is pretty standard too. Also the tendency to howl when they get tired seems to be pretty ubiquitous. Perhaps the coder-user relationship is already there, you just need to think of your users as not-yet-1year olds.