Difference between revisions of "NML:Alternative sprites"

From GRFSpecs
Jump to navigationJump to search
m (moved NML:32bpp sprites to NML:Alternative sprites: also 8bpp zoom sprites feasible)
(adjust description somewhat towards current syntax)
Line 1: Line 1:
 
{{NMLNavBlocksyntax}}
 
{{NMLNavBlocksyntax}}
   
A <code style="color:darkgreen">alternative_sprites</code> block allows you to specify alternative 32bpp sprites that are drop-in replacements for some real sprites in your grf. The syntax is as follows:
+
A <code style="color:darkgreen">alternative_sprites</code> block allows you to specify alternative sprites (zoom levels and / or 32bpp) that are drop-in replacements for some real sprites in your grf. The syntax is as follows:
   
alternative_sprites(block_name, zoom_level[, filename]) {
+
alternative_sprites(block_name, zoom_level, type[, filename]) {
 
[[NML:Realsprites|list of realsprites]]
 
[[NML:Realsprites|list of realsprites]]
 
}
 
}
   
  +
block_name is the name of the replace/replace_new/fontglyph/spriteset-block for which you want to provide alternative sprites. zoom_level can be
block_name is the name of the replace/replace_new/fontglyph/spriteset-block for which you want to provide 32bpp sprites. zoom_level can be one of <code style="color:darkgreen">ZOOM_LEVEL_NORMAL, ZOOM_LEVEL_Z0, ZOOM_LEVEL_Z1 or ZOOM_LEVEL_Z2</code>. Please note that <code style="color:darkgreen">ZOOM_LEVEL_NORMAL</code> and <code style="color:darkgreen">ZOOM_LEVEL_Z2</code> are exactly the same, and that <code style="color:darkgreen">ZOOM_LEVEL_Z0</code> and <code style="color:darkgreen">ZOOM_LEVEL_Z1</code> are for the [http://wiki.openttd.org/32bpp_Extra_Zoom_Levels extra zoom project] only (3rd party project, not officially supported). Specifying a filename is optional, it's only useful if you have multiple sprites in the same file. If every sprite is in a separate file you'll have to specify the filename for each realsprite anyway, so you can leave it out of the alternative_sprites-block.
 
  +
{|
  +
!name !! tile size !! description
  +
|-
  +
|<code style="color:darkgreen">ZOOM_LEVEL_IN_4x</code> || 256 x 127 || 4x zoom in
  +
|-
  +
|<code style="color:darkgreen">ZOOM_LEVEL_IN_2x</code> || 128 x 63 || 2x zoom in
  +
|-
  +
|<code style="color:darkgreen">ZOOM_LEVEL_IN_1x</code> || 64 x 31 || normal tile size
  +
|-
  +
|<code style="color:darkgreen">ZOOM_LEVEL_OUT_2x</code> || 32 x 15 || 2x zoom out
  +
|-
  +
|<code style="color:darkgreen">ZOOM_LEVEL_OUT_4x</code> || 16 x 7 || 4x zoom out
  +
|-
  +
|<code style="color:darkgreen">ZOOM_LEVEL_OUT_8x</code> || 8 x 3 || 8x zoom out
  +
|}
   
  +
The type argument specifies which kind of sprite follows. This may be either <code style="color:darkgreen">BIT_DEPTH_8BPP</code> or <code style="color:darkgreen">BIT_DEPTH_32bpp</code>.
The compiler nmlc will then create a sprite folder that must be copied in the TTD data/sprite/<name_of_the_newgrf> folder.
 
  +
  +
Specifying a filename is optional, it's only useful if you have multiple sprites in the same file. If every sprite is in a separate file you'll have to specify the filename for each realsprite anyway, so you can leave it out of the alternative_sprites-block.
  +
  +
An example for an implementation
  +
// Foster Express tram
  +
spriteset(foster_express_set, "opengfx_generic_trams1.pcx") {
  +
[ 48,56, 8,18, -3,-10]
  +
[ 64,56, 20,19, -14, -5]
  +
[ 96,56, 28,15, -14, -8]
  +
[144,56, 20,19, -6, -7]
  +
[176,56, 8,18, -3,-10]
  +
[192,56, 20,19, -14, -9]
  +
[224,56, 28,15, -14, -8]
  +
[272,56, 20,19, -6, -7]
  +
}
  +
  +
alternative_sprites(foster_express_set, ZOOM_LEVEL_IN_2X, BIT_DEPTH_8BPP, "opengfx_generic_trams1.pcx") {
  +
[ 48,56, 8,18, -3,-10]
  +
[ 64,56, 20,19, -14, -5]
  +
[ 96,56, 28,15, -14, -8]
  +
[144,56, 20,19, -6, -7]
  +
[176,56, 8,18, -3,-10]
  +
[192,56, 20,19, -14, -9]
  +
[224,56, 28,15, -14, -8]
  +
[272,56, 20,19, -6, -7]
  +
}
  +
  +
alternative_sprites(foster_express_set, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP, "opengfx_generic_trams1.png") {
  +
[ 48,56, 8,18, -3,-10]
  +
[ 64,56, 20,19, -14, -5]
  +
[ 96,56, 28,15, -14, -8]
  +
[144,56, 20,19, -6, -7]
  +
[176,56, 8,18, -3,-10]
  +
[192,56, 20,19, -14, -9]
  +
[224,56, 28,15, -14, -8]
  +
[272,56, 20,19, -6, -7]
  +
}

Revision as of 07:49, 28 February 2012

Block Syntax

A alternative_sprites block allows you to specify alternative sprites (zoom levels and / or 32bpp) that are drop-in replacements for some real sprites in your grf. The syntax is as follows:

alternative_sprites(block_name, zoom_level, type[, filename]) {
	list of realsprites
}

block_name is the name of the replace/replace_new/fontglyph/spriteset-block for which you want to provide alternative sprites. zoom_level can be

name tile size description
ZOOM_LEVEL_IN_4x 256 x 127 4x zoom in
ZOOM_LEVEL_IN_2x 128 x 63 2x zoom in
ZOOM_LEVEL_IN_1x 64 x 31 normal tile size
ZOOM_LEVEL_OUT_2x 32 x 15 2x zoom out
ZOOM_LEVEL_OUT_4x 16 x 7 4x zoom out
ZOOM_LEVEL_OUT_8x 8 x 3 8x zoom out

The type argument specifies which kind of sprite follows. This may be either BIT_DEPTH_8BPP or BIT_DEPTH_32bpp.

Specifying a filename is optional, it's only useful if you have multiple sprites in the same file. If every sprite is in a separate file you'll have to specify the filename for each realsprite anyway, so you can leave it out of the alternative_sprites-block.

An example for an implementation

 // Foster Express tram
 spriteset(foster_express_set, "opengfx_generic_trams1.pcx") {
   [ 48,56,  8,18,   -3,-10]
   [ 64,56, 20,19,  -14, -5]
   [ 96,56, 28,15,  -14, -8]
   [144,56, 20,19,   -6, -7]
   [176,56,  8,18,   -3,-10]
   [192,56, 20,19,  -14, -9]
   [224,56, 28,15,  -14, -8]
   [272,56, 20,19,   -6, -7]
 }
 
 alternative_sprites(foster_express_set, ZOOM_LEVEL_IN_2X, BIT_DEPTH_8BPP, "opengfx_generic_trams1.pcx") {
   [ 48,56,  8,18,   -3,-10]
   [ 64,56, 20,19,  -14, -5]
   [ 96,56, 28,15,  -14, -8]
   [144,56, 20,19,   -6, -7]
   [176,56,  8,18,   -3,-10]
   [192,56, 20,19,  -14, -9]
   [224,56, 28,15,  -14, -8]
   [272,56, 20,19,   -6, -7]
 }
 
 alternative_sprites(foster_express_set, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP, "opengfx_generic_trams1.png") {
   [ 48,56,  8,18,   -3,-10]
   [ 64,56, 20,19,  -14, -5]
   [ 96,56, 28,15,  -14, -8]
   [144,56, 20,19,   -6, -7]
   [176,56,  8,18,   -3,-10]
   [192,56, 20,19,  -14, -9]
   [224,56, 28,15,  -14, -8]
   [272,56, 20,19,   -6, -7]
 }