|
Core Dump - Work In Progress
Episode 55January 27, 1998 : Aiming Bullets (part II)
In a previous entry I talked about aiming bullets. Read the exciting conclusion!Weird angles and 8x8 pixel movement limitation So we had this problem. Although the aiming was precise, the movement looked silly when the bullets have to move "slowly", e.g. 1 block distance per frame. The bullets seemed to "jump" all over the place, caused by those blasted 8x8 block scrolling routines! Now there seems no way to have the bullets move over smaller distances, because that would defy the 8x8 block mechanism. But there is a way to overcome this. I will show what I mean with an example of a @-sign. Let's say these 8x8 blocks are available, and assume that the @-sign can be drawn in 4x4 pixels: +--+ +--+ +--+ +--+ |@ | | @| | | | | | | | | |@ | | @| +--+ +--+ +--+ +--+Now I will construct an animation sequence of this @ moving to the right: 1. +--+ |@ | | | +--+ 2. +--+ | @| | | +--+ 3. +--+ |@ | | | +--+ 4. +--+ | @| | | +--+ 5. etc....If you examine the sequence, you will find that from frame 1->2, and from 3->4, the X-coordinate of our block does not change. In these frame switches, another block is displayed, giving the illusion that our @-sign has moved four pixels... but the block has not moved. On the other hand, on frame 2->3, and 4->5,... the X-coordinate is increased by one, and the @-sign is shifted back four pixels within the block, again creating the illusion of 4-pixel movement. Exacly the same can be done for vertical movement. Thus, by using more animation frames, the illusion of four-pixel movement can be created in what is really an eight-pixel unit scroller. In Practice?? In practice I use another coordinate specifier EX2/EY2 for the bullets, like this: Name Range Description --------------------------------------------------------------------- EX 0-255 X-coordinate in block (8 pixel) units EY 0-255 Y-coordinate in block (8 pixel) units EX2 0-255 X-offset in 1/256 block units EY2 0-255 Y-offset in 1/256 block units ---------------------------------------------------------------------Increasing the X-coordinate with four pixels amounts to: ld a,(EX2) add a,128 ld (EX2),a ret nc inc (EX) retThat takes care of the movement of the block itself. Now another routine, which determines the picture displayed, uses bit 7 (the highest one) of EX2 and EY2 to determine the location of the @-sign within the block. Anyhow, that makes our bullet (or @-sign, whatever you prefer) move in 4 pixel units! And believe me, it now looks a whole lot better than it did before! Too serious? For the other readers, who aren't interested in the techncal blabla: your time will come, don't fear. But this has to be done sometimes, and I think other people appreciate this.
|