Skip to content
This repository was archived by the owner on Jan 26, 2022. It is now read-only.

Displaying sprites

Peter Tillema edited this page Dec 1, 2018 · 2 revisions

There are a couple commands available in ICE that are used to display sprites, but for these examples, we will stick to the standard command, Sprite_NoClip( (det(59 in the program editor). The syntax for Sprite_NoClip( is:

det(59,PTR,X,Y)

PTR should be the pointer that was returned from DefineSprite( (see the previous section), in our case the variable A. X and Y are the coordinates where ICE will put the sprite. Here is an example program to draw a mini apple sprite to the screen:

[i]OUTPUT
DefineSprite(4,4,"FF25E8FFE8E8E0E8E8E000E0FFE8E0FF")→A
det(0
det(59,A,20,50
Pause
det(1

Once you compile and run that program, you'll get a blank screen with a small apple near the top left corner. Hit enter to exit the program. Notice how the example program uses det(0 and det(1. This is because det(0 is used to set up the graphics canvas to allow for the use of any of the graphics functions, and then det(1 closes the graphics canvas and sets it up for TI-OS, which is what you want to do when your program ends, because it returns to TI-OS. As you can see, drawing sprites is relatively easy and only requires a bit of effort when making and converting the sprites themselves. You can have up to about 64K bytes worth of sprites in your ICE program, so it's likely you won't need to worry about using too many sprites. Just remember that they do take space in your program.

As for the other sprite commands available in ICE, they work quite similarly and are covered in more detail later. The similar command Sprite( draws a clipped sprite to the screen, using the same syntax as Sprite_NoClip. If you want to display a transparent sprite, add the following line to the convpng.ini file:

#TransparentColor : <red>, <green>, <blue>, (<alpha>)

Where <red>, <green>, <blue>, and <alpha> are the RGBA values of a the color that will be treated as transparent. Then display the sprite with one of the transparent sprite commands, such as TransparentSprite( or TransparentSprite_NoClip( (they both use the same exact syntax as the Sprite_NoClip( command we just covered, but they are used for sprites with transparency instead).

Clone this wiki locally