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

This POKE starts the X numbering over again from 0 at the 256th position (Example: POKE V+16,PEEK(V+16)OR 1 and POKE V,1 must be included to place sprite 0 at the 257th pixel across the screen.) To get back to the left side X positions you have to TURN OFF the control setting by typing POKE V+16,PEEK(V+16)AND 254.

POSITIONING MULTIPLE SPRITES ON THE SCREEN

Here's a program which defines THREE DIFFERENT SPRITES (0, 1 and 2) in different colors and places them in different positions on the screen:

 10 PRINT"{CLEAR}":V=53248:FORS=832TO895:POKES,255:NEXT
 20 FORM=2040TO2042:POKEM,13:NEXT
 30 POKEV+21,7
 40 POKEV+39,1:POKEV+40,7:POKEV+41,8
 50 POKEV,24:POKEV+1,50
 60 POKEV+2,12:POKEV+3,229
 70 POKEV+4,255:POKEV+5,50

For convenience, all 3 sprites have been defined as solid squares, getting their data from the same place. The important lesson here is how the 3 sprites are positioned. The white sprite 0 is at the top lefthand corner. The yellow sprite 1 is at the bottom lefthand corner but HALF the sprite is OFF THE SCREEN (remember, 24 is the leftmost X position in the viewing area... an X position less than 24 puts all or part of the sprite off the screen and we used an X position 12 here which put the sprite halfway off the screen). Finally, the orange sprite 2 is at the RIGHT X LIMIT (position 255)... but what if you want to display a sprite in the area to the RIGHT of X position 255?

DISPLAYING A SPRITE BEYOND THE 255TH X-POSITION

Displaying a sprite beyond the 255th X position requires a special POKE which SETS the most significant bit of the X position and starts over at the 256th pixel position across the screen. Here's how it works...

First, you POKE V+16 with the number for the sprite you're using (check the "RIGHT X" row in the X-Y chart... we'll use sprite 0). Now we assign an X position, keeping in mind that the X counter starts over from 0 at the 256th position on the screen. Change line 50 to read as follows:

   50 POKE V+16,1:POKE V,24:POKE V+1,75

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