Available on: c64 c128 c64reu msx1 coleco sg1000 sc3000
See also: SPRITE MSPRITE

CSPRITE

This statement allows you to define a composite sprite. Composite sprites are those sprites that are rendered by means of an overlay of hardware sprites. The definition corresponds to the transfer of graphic information from the graphic resource to the memory space of the machine's hardware. In practice, it is the moment in which the sprite is defined graphically, to be displayed.

The function accepts the name of a graphic resource, among those previously loaded. This must correspond to a single image: therefore it can be an image or a frame of an ATLAS or a SEQUENCE. The system, in a completely automatic way, will convert the resource into graphic data compatible with the sprite format, decoding each color component with a separate sprite.

The command accepts a series of parameters, which can be added after the name of the graphic resource. The EXPAND VERTICAL parameter allows you to double the vertical dimensions, making each pixel occupy two or more vertical pixels. On the other hand, the COMPRESS VERTICAL command allows you to restore the original dimensions. The EXPAND HORIZONTAL parameter allows you to double the vertical dimensions, making each pixel occupy two or more vertical pixels. On the other hand, the COMPRESS HORIZONTAL command allows you to restore the original dimensions. Finally, it is possible to indicate one of the colors in the palette as "transparent", and therefore that it does not need to generate a hardware sprite. This can be useful where the graphic resource does not use the color black, which is the standard color to characterize the background. Due to the isomorphic nature of the language, not all flags are usable, or have an effect, on all targets that support sprites.

The function provides additional syntax, valid for redefining a sprite already defined. The purpose of such syntax is to modify the graphic information inherent to a sprite already defined previously, thus being able to dynamically replace the appearance of the sprite. In this case, it is necessary to provide a reference to the previously defined sprite (previous), and ensure that the graphic characteristics (such as the number of colors) are identical.

SYNTAX

 = CSPRITE ( name flags )
 = CSPRITE ( name, previous flags )


Legend
  • id : identifier
  • type : datatype
  • v : value
  • "..." : string
  • [...] : optional

EXAMPLE

 spaceshift = CSPRITE( LOAD IMAGE( "spaceship.png" ) IGNORE COLOR GREEN )
 alien = CSPRITE( LOAD IMAGE( "alien1.png" ) )
 alien = CSPRITE( LOAD IMAGE( "alien2.png" ), alien )


ABBREVIATION: Csp

Join BASIC 10Liner Contest with ugBASIC!

An interesting competition is held at the beginning of each year: the BASIC 10Liner Contest. It is possible to use ugBASIC to participate in the next "BASIC10Liner" competition, in the following categories:

  • PUR-120 - A game in 10 lines of max 120 characters (w/abbrev.)
  • EXTREME-256 - A game in 10 lines of max 256 characters (w/abbrev.)
  • SCHAU - Any program in 10 lines of max 256 characters (w/abbrev.)
In order to reduce space you can use this abbreviation for this instruction:

CSPRITE ↔ Csp

Any problem?

If you have found a problem with this keyword, if you think there is a bug or, more simply, you would like it to be improved, open an issue for this example on GitHub.
Thank you!

open an issue BACK TO KEYWORDS