Difference between revisions of "NML:Spriteset"

From GRFSpecs
Jump to navigationJump to search
(Real sprites are only used in spritesets)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{NMLNavBlocksyntax}}
 
{{NMLNavBlocksyntax}}
 
== Spriteset ==
 
   
 
A spriteset associates a name with a number piece of an existing image file and describes the offsets with respect to some origin the graphics will be painted within the game. Different features and situations require that a single set has a certain amount of actual sprites associated. E.g. a vehicle usually requires eight sprites in order to provide on view for each of the eight possible ingame orientations of a vehicle.
 
A spriteset associates a name with a number piece of an existing image file and describes the offsets with respect to some origin the graphics will be painted within the game. Different features and situations require that a single set has a certain amount of actual sprites associated. E.g. a vehicle usually requires eight sprites in order to provide on view for each of the eight possible ingame orientations of a vehicle.
   
spriteset (SPRITESET_NAME, graphics_file) {
+
spriteset (<spriteset-name>[, <image-file>]) {
 
[[NML:Realsprites|list of realsprites]]
 
[[NML:Realsprites|list of realsprites]]
 
...
 
...
 
}
 
}
  +
  +
Parameter <spriteset-name> specifies the name of this spriteset. This name is used to refer to the spriteset later on.
  +
  +
Parameter two <image-file> (optional) is a literal (quoted) string that specifies the default file where the sprites are located. This may be overridden per-sprite (see [[NML:Realsprites|Real sprites]]).
   
 
Each sprite may be prefixed with a label, see [[NML:Spritelayout#Sprite| sprite layouts]] for more info. Example:
 
Each sprite may be prefixed with a label, see [[NML:Spritelayout#Sprite| sprite layouts]] for more info. Example:
Line 21: Line 23:
 
* For vehicles, the same as above is possible. However, to facilitate the common case of having multiple loading stages, you can also define [[NML:Spritegroup|sprite groups]], see below. These sprite groups are then used in place of a single sprite set.
 
* For vehicles, the same as above is possible. However, to facilitate the common case of having multiple loading stages, you can also define [[NML:Spritegroup|sprite groups]], see below. These sprite groups are then used in place of a single sprite set.
 
* Stations, houses, industry tiles, objects and airport tiles all define the look of a tile. This often requires more than one sprite, for example a concrete ground sprite with a building sprite on top of it. To combine and arrange these sprites a [[NML:Spritelayout|sprite layout]] is used, directly referring to sprite sets is not possible here
 
* Stations, houses, industry tiles, objects and airport tiles all define the look of a tile. This often requires more than one sprite, for example a concrete ground sprite with a building sprite on top of it. To combine and arrange these sprites a [[NML:Spritelayout|sprite layout]] is used, directly referring to sprite sets is not possible here
* Features not mmentioned here have no use for sprite sets, as such they are not supported by NML.
+
* Features not mentioned here have no use for sprite sets, as such they are not supported by NML.
 
== Real sprite format ==
 
 
Several features will need to reference actual graphics from files you created. You can provide real sprites in many different formats, all detailed below. There is a lot of information you'll need to provide. Most important are the filename and the location of the sprite in that file. Since most blocks that reference realsprites will allow you to specify a default filename, you don't often need to give a filename for every separate sprite.
 
 
Allowed formats:
 
 
[left_x, upper_y, width, height, offset_x, offset_y]
 
[left_x, upper_y, width, height, offset_x, offset_y, compression]
 
[left_x, upper_y, width, height, offset_x, offset_y, filename]
 
[left_x, upper_y, width, height, offset_x, offset_y, compression, filename]
 
[offset_x, offset_y]
 
[offset_x, offset_y, compression]
 
[offset_x, offset_y, filename]
 
[offset_x, offset_y, compression, filename]
 
 
If you don't specify left_x, upper_y, width and height it'll default to the complete file. If you don't specify the filename it'll take the filename from the block containing this realsprite. It's a fatal error not to specify a filename for either the block containing a realsprite or the realsprite itself. For possible values of compression, see the table below.
 
 
For all parameters you can use expressions as complex as you want as long as they can be resolved at compile time.
 
 
As of NML r1654 the compression bit has only two possible values. When ommitted it will take the default value.
 
 
{| class="t"
 
! Name
 
! Description
 
|-
 
| CROP (default) or NOCROP
 
| Whether to crop the sprites when the -c command line option is set.
 
|}
 
 
 
Example:
 
 
<pre style="color:blue">
 
[0, 0, 64, 31, -31, 0, TILE]
 
</pre>
 

Latest revision as of 15:04, 1 November 2014

Block Syntax

A spriteset associates a name with a number piece of an existing image file and describes the offsets with respect to some origin the graphics will be painted within the game. Different features and situations require that a single set has a certain amount of actual sprites associated. E.g. a vehicle usually requires eight sprites in order to provide on view for each of the eight possible ingame orientations of a vehicle.

spriteset (<spriteset-name>[, <image-file>]) {
	list of realsprites
	...
}

Parameter <spriteset-name> specifies the name of this spriteset. This name is used to refer to the spriteset later on.

Parameter two <image-file> (optional) is a literal (quoted) string that specifies the default file where the sprites are located. This may be overridden per-sprite (see Real sprites).

Each sprite may be prefixed with a label, see sprite layouts for more info. Example:

 	some_label: [... real sprite ...]

How to use a sprite set depends on the feature:

  • For canals, cargos, airports (not tiles!) and railtypes, you can refer to sprite sets directly from the graphics block, or use intermediate (random)switches to make a descision.
  • For vehicles, the same as above is possible. However, to facilitate the common case of having multiple loading stages, you can also define sprite groups, see below. These sprite groups are then used in place of a single sprite set.
  • Stations, houses, industry tiles, objects and airport tiles all define the look of a tile. This often requires more than one sprite, for example a concrete ground sprite with a building sprite on top of it. To combine and arrange these sprites a sprite layout is used, directly referring to sprite sets is not possible here
  • Features not mentioned here have no use for sprite sets, as such they are not supported by NML.