A course for the Dragon 32 · Chapters 0 to 15
It doesn’t really move. Like in a cartoon, you draw a picture, wait a moment, erase it, and draw it again one step further on. When this happens fast enough, the eye sees movement.
That is exactly what we already have: a loop (Chapter 9), a waiting loop (Chapter 9), and a finger Y that moves.
The block sets off from the left edge of row 8, and drives right until the wall. CMPY #$051F asks “have you reached the last square in the row?”, and if so, BEQ KEY stops there.
Try the three versions. Without the wait the block “jumps” to the end, because the whole drive takes less than a thousandth of a second. And without erasing, the block leaves a trail behind it: all the pictures stay on the screen.
The same idea, only instead of waiting for the clock, we wait for a key. On every press: erase, move by the arrow, and draw. Press the arrows under the screen (or on your own keyboard).
Now the ball doesn’t stop at the wall: it turns round. For that we keep the direction in drawer B: 1 = right, -1 = left. LEAY B,Y moves finger Y by whatever is in B. At the right wall we put -1 in B, and at the left wall 1.
And the program stops when you press a key: it asks the keyboard once on every lap, and doesn’t wait. If nothing was pressed, it keeps running. If something was, RTS: back to DREAM.
$FF. When B is used as a distance (B,Y), the processor reads numbers from $80 upwards as negative numbers: $FF = -1, $DF = -33. That is lamp 128 from Chapter 8, again.A ball bouncing between four walls needs two directions: left-right, and up-down too. In the folder there is a program like that, “BALL — bouncing ball”, which already runs on our Dragon machine. It uses a few tools we haven’t learned yet, like putting a drawer aside for a moment. We’ll learn that in the next chapter.
In the movement puzzles we also check the time: if everything is over in less than a second on the Dragon, the eye won’t see movement, and it doesn’t count.
A hobbyist tribute project, not affiliated with or endorsed by Dragon Data. The course, drawings and text are our own. Every program in the course was checked on the site's Dragon machine (XRoar running the BASIC we wrote).