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


For those of you having trouble with graphics, this section has been designed as a more elementary tutorial approach to sprites.


There are at least three different BASIC programming techniques which let you create graphic images and cartoon animations on the Commodore 64. You can use the computer's built-in graphics character set (see Page 376). You can program your own characters (see Page 108) or... best of all... you can use the computer's built-in "sprite graphics. To illustrate how easy it is, here's one of the shortest spritemaking programs you can write in BASIC:

 20 POKE2040,13
 30 FORS=832TO832+62:POKES,255:NEXT
 40 V=53248
 50 POKEV+21,1
 60 POKEV+39,1
 70 POKEV,24
 80 POKEV+1,100

This program includes the key "ingredients" you need to create any sprite. The POKE numbers come from the SPRITEMAKING CHART on Page 176. This program defines the first sprite... sprite 0... as a solid white square on the screen. Here's a line-by-line explanation of the program:

LINE 10 clears the screen.

LINE 20 sets the "sprite pointer" to where the Commodore 64 will read its sprite data from. Sprite 0 is set at 2040, sprite 1 at 2041, sprite 2 at 2042, and so on up to sprite 7 at 2047. You can set all 8 sprite pointers to 13 by using this line in place of line 20:

   20 FOR SP=2040TO2047:POKE SP,13:NEXT SP

LINE 30 puts the first sprite (sprite 0) into 63 bytes of the Commodore 64's RAM memory starting at location 832 (each sprite requires 63 bytes

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