Yes please, I’d like a game

Ever since we bought a Nintendo DS, my son has been keen on writing a game for it. As a means of getting into writing such games, I set myself a target of writing something simple which would:
  1. Demonstrate some sprites and how to move them around
  2. Demonstrate tile backgrounds
  3. Display text in the lower DS pane
  4. Enable state to be saved

I’ve now achieved that goal. It’s taken a while as I found it hard to find good tutorials on writing DS code on the internet. There are many partial tutorials and lots of full blown games, but very little in between. The attached example consists of bits of code taken from the devKitPro examples and elsewhere. We display three rotating squares with the middle square (in the initial position and z-order) under the control of the direction keys. A counter value is displayed in the lower window. Pressing "A" saves the counter to the (R4) memory card and pressing "B" restores the saved value.

The code works on top of the devKitPro development environment that can be downloaded here. To build it, take the code from here, unzip it and in the msys window type make. This will produce the files CTPlay2.nds (the game) and ctplay.txt (the file storing the state) which need to be transferred onto an R4 card’s micro SD card which is the only thing I have tried it on for real. During development I tested on the DeSmuMe simulator, though the saving doesn’t work on the version of the simulator that I have, though it does work on the full DS.

Total cost to play with this kind of thing is just 25 UK pounds for the R4 chip and some micro SD cards. Now I just need to improve my C programming skills and get a clone version of PacMan written.



This entry was posted in Computers and Internet. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s