Sprites / SpritesB Library: Difference between revisions

From Arduboy Wiki
Jump to navigation Jump to search
(Created page with " What are Sprites? Sprites are a computer graphic which can be rendered and moved on screen as a single unit.  In older systems such as the Commodore 64 and Atari, the sprite was rendered by hardware as an overlay to the normal screen image.  As the sprite is an overlay, it can be moved around without it affecting the background image.   The Arduboy library has support for sprites but due to the lack of a powerful graphics processor handles them differently.  W...")
 
No edit summary
Line 4: Line 4:
Sprites are a computer graphic which can be rendered and moved on screen as a single unit.  In older systems such as the Commodore 64 and Atari, the sprite was rendered by hardware as an overlay to the normal screen image.  As the sprite is an overlay, it can be moved around without it affecting the background image.
Sprites are a computer graphic which can be rendered and moved on screen as a single unit.  In older systems such as the Commodore 64 and Atari, the sprite was rendered by hardware as an overlay to the normal screen image.  As the sprite is an overlay, it can be moved around without it affecting the background image.


 
The Arduboy library has support for sprites but due to the lack of a powerful graphics processor handles them differently.  When rendering a sprite, the image is mapped into a single display buffer that may already have a background image drawn on it.  If you move the sprite you need to regenerate the background from its old position.


The Arduboy library has support for sprites but due to the lack of a powerful graphics processor handles them differently.  When rendering a sprite, the image is mapped into a single display buffer that may already have a background image drawn on itIf you move the sprite you need to regenerate the background from its old position.
The Arduboy library also provides some nice masking utilities that allow you to render a sprite over a background and have it take that background into accountThe drawing functions include:


 
drawOverwrite()
drawErase()
drawExternalMask()
drawPlusMask()
drawSefMasked()


The Arduboy library also provides some nice masking utilities that allow you to render a sprite over a background and have it take that background into account.  The drawing functions include:
But what do they each do?  Consider the following image and mask:
 
 
 
·       drawOverwrite()
 
·       drawErase()
 
·       drawExternalMask()
 
·       drawPlusMask()
 
·       drawSefMasked()
 
 
 
But what do they each do?  Consider the following image and mask:

Revision as of 03:05, 11 August 2024

What are Sprites?

Sprites are a computer graphic which can be rendered and moved on screen as a single unit.  In older systems such as the Commodore 64 and Atari, the sprite was rendered by hardware as an overlay to the normal screen image.  As the sprite is an overlay, it can be moved around without it affecting the background image.

The Arduboy library has support for sprites but due to the lack of a powerful graphics processor handles them differently.  When rendering a sprite, the image is mapped into a single display buffer that may already have a background image drawn on it.  If you move the sprite you need to regenerate the background from its old position.

The Arduboy library also provides some nice masking utilities that allow you to render a sprite over a background and have it take that background into account.  The drawing functions include:

drawOverwrite() drawErase() drawExternalMask() drawPlusMask() drawSefMasked()

But what do they each do?  Consider the following image and mask: