Skip to content
Kyuchumimo edited this page Mar 18, 2022 · 8 revisions

spr

🧩 This function depends on numpy library.
🖻 This function depends on tilesets provided in assets/map filepath.
🖻 This function depends on spritesheets provided in assets/spr filepath.

spr id x y [colorkey=-1] [scale=1] [flip=0] [rotate=0] [w=1 h=1]

Parameters

  • id : index of the sprite (0..511)
  • x, y : screen coordinates of top left corner of sprite.
  • colorkey : index of the color in the sprite that will be used as transparent color. Use -1 if you want an opaque sprite.
  • scale : scale factor applied to sprite.
  • flip : flip the sprite vertically or horizontally or both.
  • rotate : rotate the sprite by 0, 90, 180 or 270 degrees.
  • w : width of composite sprite
  • h : height of composite sprite

Description

Draws the sprite number index at the x and y coordinate.

You can specify a colorkey in the palette which will be used as the transparent color or use a value of -1 for an opaque sprite.

The sprite can be scaled up by a desired factor. For example, a scale factor of 2 means an 8x8 pixel sprite is drawn to a 16x16 area of the screen.

You can flip the sprite where:

  • 0 = No Flip
  • 1 = Flip horizontally
  • 2 = Flip vertically
  • 3 = Flip both vertically and horizontally

When you rotate the sprite, it's rotated clockwise in 90° steps:

  • 0 = No rotation
  • 1 = 90° rotation
  • 2 = 180° rotation
  • 3 = 270° rotation

You can draw a composite sprite (consisting of a rectangular region of sprites from the sprite sheet) by specifying the w and h parameters (which default to 1).

Clone this wiki locally