reworded sprites modes. thanks marshal!
This commit is contained in:
parent
26c10b129c
commit
dd700b923f
|
@ -541,12 +541,20 @@ nice, isn't it?
|
|||
|
||||
we'll see now how to leverage the built-in support for "sprites" in the uxn screen device, in order to draw many pixels at once!
|
||||
|
||||
# drawing sprites
|
||||
|
||||
the varvara screen device allows us to use and draw tiles of 8x8 pixels, also called sprites.
|
||||
|
||||
there are two posible modes: 1bpp (1 bit per pixel), and 2bpp (2 bits per pixel).
|
||||
|
||||
1bpp tiles use two colors, and they are encoded using 8 bytes; using one bit per pixel means that we can only encode if that pixel is using one color, or the other.
|
||||
|
||||
2bpp tiles use four colors and they are encoded using 16 bytes; using two bits per pixel we can encode one color out of four.
|
||||
|
||||
we will be storing and accessing these tiles from the main memory.
|
||||
|
||||
# drawing 1bpp sprites
|
||||
|
||||
the varvara screen device allows us to use and draw tiles of 8x8 pixels (sprites), stored in the main memory.
|
||||
|
||||
these tiles can be either in a 1bpp (1 bit per pixel) format, 8 bytes in size, or in a 2bpp (2 bits per pixel) format, with a size of 16 bytes.
|
||||
|
||||
a 1bpp tile consists in a set of 8 bytes that encode the state of its 8x8 pixels.
|
||||
|
||||
each byte corresponds to a row of the tile, and each bit in a row corresponds to the state of a pixel from left to right: it can be either "on" (1) or "off" (0).
|
||||
|
@ -815,7 +823,9 @@ i invite you to try using these sprites instead to explore how to draw them flip
|
|||
|
||||
# drawing 2bpp sprites
|
||||
|
||||
in 2bpp sprites, each pixel can have one of four possible states.
|
||||
in 2bpp sprites each pixel can have one of four possible colors.
|
||||
|
||||
we can think that, in order to assign these colors, we will encode one out of four states in each of the pixels of the sprite.
|
||||
|
||||
each one of these states can be encoded with a combination of two bits. these states can be assigned different combination of the four system colors, by using appropriate values in the screen color byte.
|
||||
|
||||
|
|
Loading…
Reference in New Issue