Sprite
Info
Dependencies:
- PermMem
Implementation:
 Sprite.d on GitHub
Sprite package implements functions for working with 2D sprites.
Initialization
Initialize with LeGo_Sprite flag.
Functions
Sprite_Create
Sprite_Create
Creates a sprite. The dimensions are in virtual coordinates.
- var int x
 X position of sprite (virtual)
- var int y
 Y position of sprite (virtual)
- var int width
 Width of sprite (virtual)
- var int height
 Height of sprite (virtual)
- var int color
 Color of sprite (in RGBA format)
- var string tex
 Name of the sprite texture
Return value
The function returns the handle of the created sprite.
Sprite_CreatePxl
Sprite_CreatePxl
Creates a sprite. The dimensions are in pixels.
- var int x
 X position of sprite (pixels)
- var int y
 Y position of sprite (pixels)
- var int width
 Width of sprite (pixels)
- var int height
 Height of sprite (pixels)
- var int color
 Color of sprite (in RGBA format)
- var string tex
 Name of the sprite texture
Return value
The function returns the handle of the created sprite.
Sprite_Render
Sprite_Render
Renders a sprite on a screen (must be visible first).
- var int h
 Handle of the sprite
Sprite_SetVisible
Sprite_SetVisible
Sets the visibility of a sprite.
- var int h
 Handle of the sprite
- var int visible
 Visibility flag (0 for invisible, 1 for visible)
Sprite_SetPrio
Sprite_SetPrio
Sets the priority of a sprite. The higher the priority, the closer the sprite is to the camera.
- var int h
 Handle of the sprite
- var int prio
 Priority of the sprite
Sprite_Scale
Sprite_Scale
Scales a sprite.
- var int h
 Handle of the sprite
- var int x
 X scale factor (as ikarus float)
- var int y
 Y scale factor (as ikarus float)
Sprite_SetWidth
Sprite_SetWidth
Sets the width of a sprite in virtual coordinates.
- var int h
 Handle of the sprite
- var int w
 Width of the sprite in virtual coordinates
Sprite_SetWidthPxl
Sprite_SetWidthPxl
Sets the width of a sprite in pixels.
- var int h
 Handle of the sprite
- var int w
 Width of the sprite in pixels
Sprite_SetHeight
Sprite_SetHeight
Sets the height of a sprite in virtual coordinates.
- var int h
 Handle of the sprite
- var int hg
 Height of the sprite in virtual coordinates
Sprite_SetHeightPxl
Sprite_SetHeightPxl
Sets the height of a sprite in pixels.
- var int h
 Handle of the sprite
- var int hg
 Height of the sprite in pixels
Sprite_SetDim
Sprite_SetDim
Sets the dimensions of a sprite in virtual coordinates.
- var int h
 Handle of the sprite
- var int w
 Width of the sprite in virtual coordinates
- var int hg
 Height of the sprite in virtual coordinates
Sprite_SetDimPxl
Sprite_SetDimPxl
Sets the dimensions of a sprite in pixels.
- var int h
 Handle of the sprite
- var int w
 Width of the sprite in pixels
- var int hg
 Height of the sprite in pixels
Sprite_SetPos
Sprite_SetPos
Sets the position of a sprite in virtual coordinates.
- var int h
 Handle of the sprite
- var int x
 X position of the sprite (virtual)
- var int y
 Y position of the sprite (virtual)
Sprite_SetPosPxl
Sprite_SetPosPxl
Sets the position of a sprite in pixels.
- var int h
 Handle of the sprite
- var int x
 X position of the sprite (pixels)
- var int y
 Y position of the sprite (pixels)
Sprite_SetPosPxlF
Sprite_SetPosPxlF
Sets the position of a sprite in pixels (floating point).
- var int h
 Handle of the sprite
- var int xf
 X position of the sprite (pixels but as a float)
- var int yf
 Y position of the sprite (pixels but as a float)
Sprite_SetColor
Sprite_SetColor
Sets the color of a sprite.
- var int h
 Handle of the sprite
- var int col
 Color of the sprite (in RGBA format)
Sprite_SetVertColor
Sprite_SetVertColor
Sets the color of a vertex in a sprite.
- var int h
 Handle of the sprite
- var int vert
 Index of the vertex (0-3)
- var int col
 Color of the vertex (in RGBA format)
Sprite_SetUV
Sprite_SetUV
Sets the UV coordinates of a sprite.
- var int h
 Handle of the sprite
- var int x0
 X coordinate of the top-left UV
- var int y0
 Y coordinate of the top-left UV
- var int x1
 X coordinate of the bottom-right UV
- var int y1
 Y coordinate of the bottom-right UV
Sprite_SetVertUV
Sprite_SetVertUV
Sets the UV coordinates of a vertex in a sprite.
- var int h
 Handle of the sprite
- var int vert
 Index of the vertex (0-3)
- var int x
 X coordinate of the UV
- var int y
 Y coordinate of the UV
Sprite_Rotate
Sprite_Rotate
Rotates a sprite by a given angle in degrees.
- var int h
 Handle of the sprite
- var int r
 Rotation angle in degrees
Sprite_RotateR
Sprite_RotateR
Rotates a sprite by a given angle in radians.
- var int h
 Handle of the sprite
- var int r
 Rotation angle in radians
Sprite_SetRotation
Sprite_SetRotation
Sets the rotation of a sprite in degrees.
- var int h
 Handle of the sprite
- var int r
 Rotation angle in degrees
Sprite_SetRotationR
Sprite_SetRotationR
Sets the rotation of a sprite in radians.
- var int h
 Handle of the sprite
- var int r
 Rotation angle in radians
Sprite_SetRotationSC
Sprite_SetRotationSC
Sets the rotation of a sprite using sine and cosine values.
- var int h
 Handle of the sprite
- var int sin
 Sine value of the rotation
- var int cos
 Cosine value of the rotation
Helper functions
SinCosApprox
SinCosApprox
Approximates sine and cosine values for a given angle. Keeps them in var int sinApprox var int cosApprox; variables.
- var int angle
 Angle in degrees