[Prev] [Next] [Contents] [Commodore] [New] [Search] [Home]

Here's a line which moves the sprite BACK AND FORTH:

   50 POKE V+5,100:FOR X=24TO255:POKE V+4,X:NEXT:POKE V+16,4:
      FOR X=0TO65: POKE V+4,X: NEXT X
   55 FOR X=65TO0 STEP-1:POKE V+4,X:NEXT:POKE V+16,0: FOR
      X=255TO24 STEP-1: POKE V+4,X:NEXT
   60 GOTO 50

Do you see how these programs work? This program is the same as the previous one, except when it reaches the end of the right side of the screen, it REVERSES ITSELF and goes back in the other direction. That is what the STEP-1 accomplishes... it tells the program to POKE the sprite into X values from 65 to 0 on the right side of the screen, then from 255 to 0 on the left side of the screen, STEPping backwards minus-1 position at a time.

VERTICAL SCROLLING

This type of sprite movement is called "scrolling." To scroll your sprite up or down in the Y position, you only have to use ONE LINE. ERASE LINES 50 and 55 by typing the line numbers by themselves and hitting <RETURN> like this:

   50 <RETURN>
   60 <RETURN>
Now enter LINE 50 again as follows:
   50 POKE V+4,24:FOR Y=0TO255:POKE V+5,Y:NEXT

THE DANCING MOUSE-A SPRITE PROGRAM EXAMPLE

Sometimes the techniques described in a programmer's reference manual are difficult to understand, so we've put together a fun sprite program called "Michael's Dancing Mouse." This program uses three different sprites in a cute animation with sound effects-and to help you understand how it works we've included an explanation of EACH COMMAND so you can see exactly how the program is constructed:


[Prev] [Next] [Contents] [Commodore] [New] [Search] [Home]
This page has been created by Sami Rautiainen.
Read the small print. Last updated May 12, 2002.