Last change
on this file since 218 was
218,
checked in by sam, 12 years ago
|
The Tile size can now be specified upon TileSet load. Add a sample
with the Monsterz tiles.
|
-
Property svn:keywords set to
Id
|
File size:
1.0 KB
|
Line | |
---|
1 | // |
---|
2 | // Deus Hax (working title) |
---|
3 | // Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> |
---|
4 | // |
---|
5 | |
---|
6 | #if defined HAVE_CONFIG_H |
---|
7 | # include "config.h" |
---|
8 | #endif |
---|
9 | |
---|
10 | #include "core.h" |
---|
11 | |
---|
12 | /* |
---|
13 | * Tiler implementation class |
---|
14 | */ |
---|
15 | |
---|
16 | static class TilerData |
---|
17 | { |
---|
18 | friend class Tiler; |
---|
19 | |
---|
20 | public: |
---|
21 | Dict tilesets; |
---|
22 | } |
---|
23 | tilerdata; |
---|
24 | |
---|
25 | static TilerData * const data = &tilerdata; |
---|
26 | |
---|
27 | /* |
---|
28 | * Public Tiler class |
---|
29 | */ |
---|
30 | |
---|
31 | int Tiler::Register(char const *path, int size) |
---|
32 | { |
---|
33 | int id = data->tilesets.MakeSlot(path); |
---|
34 | |
---|
35 | if (!data->tilesets.GetEntity(id)) |
---|
36 | { |
---|
37 | TileSet *tileset = new TileSet(path, size); |
---|
38 | data->tilesets.SetEntity(id, tileset); |
---|
39 | } |
---|
40 | |
---|
41 | return id + 1; /* ID 0 is for the empty tileset */ |
---|
42 | } |
---|
43 | |
---|
44 | void Tiler::Deregister(int id) |
---|
45 | { |
---|
46 | data->tilesets.RemoveSlot(id - 1); /* ID 0 is for the empty tileset */ |
---|
47 | } |
---|
48 | |
---|
49 | void Tiler::BlitTile(uint32_t code, int x, int y, int z, int o) |
---|
50 | { |
---|
51 | int id = (code >> 16) - 1; /* ID 0 is for the empty tileset */ |
---|
52 | |
---|
53 | TileSet *tileset = (TileSet *)data->tilesets.GetEntity(id); |
---|
54 | tileset->BlitTile(code & 0xffff, x, y, z, o); |
---|
55 | } |
---|
56 | |
---|
Note: See
TracBrowser
for help on using the repository browser.