I got a CodeBug about a month ago with the intent of cloning the game Simon. I quickly found out the device is severely limited, but very easy to use. This, of course, is the old "Ease of Use" vs "Flexibility" issue for any new device\language. In this case, it was my fault for not checking the capability before jumping in. Even though I wasn't able to create Simon, I was able to have lots of fun with the device. It is incredibly easy to use, but at times, incredibly annoying for advanced users. This is one instance where the device is targeted very well to its intended audience. That can't be stressed enough, they are doing an excellent job at meeting their target audience. My two year old son loves the device, he's always asking for the CodeBug. I can load in a simple name scrolling program and we can identify letters together.
To add to the code base for the device I created the basic interface to scroll across the screen with button presses. This is the classic Space Invaders scrolling spaceship type of code. With a random number generator I could add random ships attacking like a scrolling shooter. A screenshot of the code is below, but I also shared it under the name 'Moving Around'.
The code above makes sense if you invert the CodeBug so the buttons point downward. Pressing the B button moves the lit LED to the left and pressing the A button moves the lit LED to the right. The code wraps the lit LED around the edges. I had to practice with the pause time for the best response, which occurred at 200 ms. I also kept track of the old position so that the LED didn't flicker.
I'm not a fan of polling buttons; I prefer interrupts, but this is a limit of the environment provided. It would be nice if the inventors could include a random number generator that can generate a random number between two limits. For example, generate a random number between 0 and 4 which could be used to light a random LED on the screen.
Top Comments