Skip to content

Sprites

CPU edited this page Feb 4, 2021 · 10 revisions

RGE hardware handles 16 sprites.

A sprite is a rectangular image that is independent of the bitmap and the tiles.
It can be rendered at any layer of the screen but before the background.

Sprites size is between 8 and 64 pixels wide and 8 and 64 pixels tall.
Sprites can use the full colors, including alpha. (256 actual colors.)

Sprite

Defines a sprite.
Sprite(<number>, <width>, <height>, <memory address> [, <filterOnOff>])
This will define the sprite with the specified number with the given width and height, using the memory at the specified location (ram or rom.)
If filterOnOff evaluates to 0 no filter will be used, if it evaluated to anything than 0 then a bilinear filter will be used.

Sprite(<number>, <width>, <height>, <memory address> [, <filterOnOff>])
This will define the sprite, using the memory at the specified location (ram or rom.) The first two bytes of the memory should contain the width and height for the sprite, then the actual color data will start just after.
If filterOnOff evaluates to 0 no filter will be used, if it evaluated to anything than 0 then a bilinear filter will be used.

The sprite number can be between 0 and 15 (included.)
The size (vertical or horizontal) has to be between 8 and 32 pixels.
The memory is one byte per pixel, from top left to bottom right, one line at time.
The byte value is the color value (see Colors for more info) and the alpha is used in this case.

Spen - Sprite Enable

You can enable and disable sprites using the SPen command.\n SPen(<number>, <expression>)
If the expression is 0 the sprite will be disabled, if it is not zero then it will be enabled.

SPos - Sprite Position

SPos(<number>, <x>, <y> [, <enable>])
The SPos statement will set the sprite position.
The sprite will be positioned in the specified x and y coordinated. (Top-left of the screen is 0,0)
It is possible to position sprites outside the screen, spos(0, -10, 12) is a valid position.
The top-left of the sprite will be in the specified position.

The enable parameter is optional, and - if specified - it is used to enable or disable the sprite (0 disable, not zero enable.)

SRot - Sprite Rotate and Flip

Sets the sprite rotation and flipping.
The rotation is only at multiples of 90 degrees: SRot(<number>, <rotation>, <flip>)
The parameter rotation is an integer number with values between 0 and 3 included.

  • 0 = up
  • 1 = right
  • 2 = down
  • 3 = left

flip is considered a boolean expression, if it is not zero, the sprite is flipped.

Rotation Sprite Flipped
0 U UF
1 R RF
2 D DF
3 L LF

Original sprite is: Original

If the rotation number is below or above the range 0 - 3 the modulo of 4 will be used.

STint - Sprite Color Tint

STint(<number>, <color>)
Filter the colors of the sprite. Warning, it is like Unity colors applied to sprites, it is not "colorizing" it is "filtering by color".
If you have a sprite that is all white and you Tint it with blue, the result will be blue.
If the sprite is red and you filter with blue, the result is black.

Only the colors component of the tint are preserved in the sprite original colors.

SScale - Sprite Scale

Scale the sprite up to 8 times in the two directions.
SScale(<number>, <scalex>, <scaley>)\

The values for the scale can be between 1 and 8.

SPri - Sprite Priority

Defines the priority of the spite. Lower numbers mean the sprite will be in front of tiles and other sprites with higher number. SPri(<number>, <order>)\

The values for the order can be from -1 (in front of everything) up to 12 that is beyond everything. Check the section [link]

Destroy

When you define a sprite with the sprite command, a texture will be allocated from the sprite and filled with the memory you specified.
Because they are not real hardware sprites, if you change the memory behind the sprite will not change.
To update the sprite definition, you need to destroy the previous allocated texture.

Destroy(<memory address>)
Will free again the sprite texture to be re-processed by a new Sprite command.

Warning This does nothing if the memory is from Rom. Only Ram memory can be changed and the sprite may need to be re-created.

Defining sprites from Rom

Editing sprites with Development tool

Clone this wiki locally