Hardware Reference
In-Depth Information
Figure 6-1:
he inished Pie
Man game.
Gather Your Resources
Before you start writing any code there are a number of resources you need to construct or to
gather. hese are the sound efects and the graphic sprites, or small images, of the playing
pieces. hese are known as sprites because early in computing history they were separate
entities with their own dedicated hardware memory that could be set to be displayed any-
where on the screen by simply setting an X and Y register. Nowadays they are always deined
in software and the display position controlled by what address in memory you transfer
them to, but the name has stuck. Getting these sprites “right” will greatly simplify the code
that is needed. First and foremost is the Pie Man himself. It is vital that the sprite used for
this be square and not rectangular. At irst I made a rectangular Pie Man, but I ran into all
sorts of problems with changing direction. he code that tested for the walls on a turn got
very complex, and even then it would occasionally fail, causing the Pie Man to walk through
a wall. he next thing to worry about is the actual size of the sprite; I settled on a size of 48
pixels square, which in turn governs the size between the walls. Finally, the maximum step
size was chosen to be 8, which is a compromise between the speed of the game and the
smoothness of the animation. here are a lot of things to calculate between each step, so
having it too small will result in a slow game. he step size also governs the thickness of the
walls that you need, but more on this when you look at the movement sections of the code.
 
Search WWH ::




Custom Search