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

Loading sprites

Peter Tillema edited this page Dec 1, 2018 · 1 revision

If you open the output file from the previous subsection, ice_gfx.txt, you will see a width, height, and long string of hexadecimals for each sprite you converted. These are the arguments that you need to give DefineSprite( to use the sprites in your ICE program. For each sprite, place a DefineSprite( token in your ICE program and copy the corresponding line of text into the token (this is why we recommend you use SourceCoder3, it makes it significantly easier to get the sprite data into your ICE program).

In order to use the sprites you've put into your program, you need to save the pointer that DefineSprite( returns, so store the result to a variable. Example:

DefineSprite(2,2,"00FFFF00")→A

This code creates a small 2 pixel wide, 2 pixel tall sprite, and stores the returned pointer into variable A. If we wanted to display this sprite to the screen at X-Y coordinates (20, 50), we would use:

det(57,A,20,50)

det(57 is the ICE command for Sprite(, which draws a clipped sprite to a given X,Y at the screen (or buffer). We can also define an 'empty' sprite, with random data in it, which can be used for creating a sprite from the screen (or buffer). To make an empty sprite, you simply define a sprite without data, like this:

DefineSprite(WIDTH,HEIGHT)

The example still returns a pointer to the empty sprite, which is required by commands that use sprites, like GetSprite( or FlipSpriteC(. Defining an empty sprite is useful for when you want to create a sprite from what's already on screen (or on buffer).

Clone this wiki locally