Tile

From SuperTux

Jump to: navigation, search

Contents

[edit] Introduction

Supertux tilemaps are composed from tiles. Little 32x32 pixel wide images. These tiles are defined in an S-expr based file, "data/images/tiles.strf", or for one or two bleeding-edge SVN levels a custom tileset ending with ".stts". These tilesets are included into the level by a tileset or tilesets entry, usually at the beginning of the level. A tile has an ID number a set of images (it's an animated tile if it has more than 1 image) and contains a set of attributes like solid, icy, anim-fps...

[edit] Example

An example of a simple solid tile looks like this:

(tile
  (id 7)
  (solid #t)
  (images
    "tiles/snow/snow1.png"
  )
)

An animated waterfall tile (animation played with 10 fps):

(tile
  (id 175)
  (images
    "tiles/waterfall/trans1-1-1.png"
    "tiles/waterfall/trans1-1-2.png"
    "tiles/waterfall/trans1-1-3.png"
    "tiles/waterfall/trans1-1-4.png"
  )
  (water #t)
  (anim-fps 10)
)

It's also possible to extract parts of bigger images to create tiles. This extracts the upper left edge of the foresttiles-1.png file:

(tile
  (id 1000)
  (images
    (region "tiles/forest/foresttiles-1.png" 0 0 32 32)
  )
)

Note that in Milestone 2, the last variant is deprecated in favor of a more compact approach at defining multiple tiles:

(tiles
  (width 3)
  (height 4)
  (ids  7  8  9
       13 14 15
       10 11 12
       16 17 18)
  (attributes 0 0 0
              1 1 1
              1 1 1
              0 0 0)
  (image "tiles/snow/convex.png")
)

In this example, a block of 3x4 tiles will be extracted from an image with only the middle rows solid. To ignore a portion of the image, use an id of 0 in the appropriate place.

More complex variants are also supported:

(tiles
  (width 11)
  (height 4)
  (ids
    7  8  9  0    1826 1827 0    1837 1838 1843 1844
    13 14 15 1829 1830 1831 1832 1839 1840 1845 1846
    10 11 12 1833 1834 1835 1836 1841 1842 1847 1848
    16 17 18 0    0    0    0    0    0    1849 1850
  )
  (attributes
    0 0 0 0  0  0  0  0  0  0  0
    1 1 1 17 17 17 17 17 17 17 17
    1 1 1 1  1  1  1  1  1  17 17
    0 0 0 0  0  0  0  0  0  1  1
  )
  (datas
    0 0 0 0  0  0  0  0 0 0  0
    0 0 0 18 34 32 16 2 0 66 48
    0 0 0 0  0  0  0  0 0 50 64
    0 0 0 0  0  0  0  0 0 0  0
  )
  (image "tiles/snow/convex.png")
)

17 is used for slopes, and the appropriate data/slope-type is put in datas. Alternately, you could go minimalist with no data or attributes:

(tiles
  (width  12)
  (height 14)
  (ids 
     2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 
     2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 
     2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 
     2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 
     2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 
     2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 
     2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 
     2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 
     2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 
     2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 
     2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 
     2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 
     2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 
     2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379
  )
  (image "tiles/castle/background.png")
)

[edit] Tile attributes

Tiles can have the following attributes:


  • solid defines if the tile should be considered for collision detection (value 1 for attributes)
  • unisolid the tile will only be considered for collision detection when tux is falling down. That is you can jump through the tile from below but not fall through it. (value 3 for attributes - both solid and unisolid are applied)
  • brick A brick that can be destroyed by jumping under it (value 4 for attributes)
  • goal The level should be finished when touching a goaltile. If data is 0 then the endsequence should be triggered, if data is 1 then the level is finished instantly. (value 8 for attributes)
  • fullbox Bonusbox, content is stored in data (value 32 for attributes)
  • coin The tile is a coin (value 64 for attributes)
  • ice the tile will be slippery (currently not implemented) (value 256)
  • water The tile is a water tile (needed for fish enemy) (value 512)
  • hurts The tile will hurt you when you hit it (value 1024)
  • slope-type The tile is a slope. You have to add a slope number to reference what sort of slope the tile is. Take a look for possible types here (take the basic form and add the deform to get the number)

Image:Slopes.png

[edit] Adding new tiles

You can simply add new tiles with your favourite text editor. However we also provide an easy to use editor to make this task easier (especially extracting regions of bigger images). You can find it in the tools/tilemanager directory. It's a mono/gtk# app so you have to have these 2 things installed and should invoke make in that directory then. It'll create tilemanager.exe which you can then start with mono like this:

mono tilemanager.exe

NOTE: You should be careful when choosing tile ids to not overwrite existing tiles. You should also keep in mind that existing levels will break if you change tile numbers later (the levels just save a big a list of numbers that reference the tile file).

WARNING: Unfortunately the tilemanage application is broken at the moment and does not work correctly! You'll destroy several tile attributes like slopes and some of the tiles created from multiple images, when opening and saving a tileset with the editor!

[edit] Testing

Simply open the flexlay or ST# editor and the new tiles should appear.

[edit] Trickery

Note that some tiles aren't actually used in-game. Right after the level is loaded, various tiles in the solid tilemaps are replaced with objects. These include all with the coin, fullbox, brick, or goal attributes, and tile id 112 (invisible block). But the game doesn't end there. It also adds light sources to torches and lava, which are then hidden unless the level uses a lightmap.

Personal tools