summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/tiletex.h
diff options
context:
space:
mode:
authorennewalker <ennewalker@c06c8d41-db1a-0410-9941-cceddc491573>2008-08-23 17:07:46 +0000
committerennewalker <ennewalker@c06c8d41-db1a-0410-9941-cceddc491573>2008-08-23 17:07:46 +0000
commitb25208caa5f84ac6c370314945c6f110261d2c70 (patch)
treec477c16395f409c901bc7d405b14db67ff4a4d90 /crawl-ref/source/tiletex.h
parent02bae5372f40ac282701831cc61deb2483938876 (diff)
downloadcrawl-ref-b25208caa5f84ac6c370314945c6f110261d2c70.tar.gz
crawl-ref-b25208caa5f84ac6c370314945c6f110261d2c70.zip
RLTiles complete code rewrite: now much more robust and functional.
Added PNG and non-palettized image input. Added PNG output. Added better tile packing and support for tiles of different sizes. Converted all BMPs to PNGs (for space and explicit transparency reasons.) Added the 48x32 pandemonium demon tiles, but these are not yet used in game. Added Bill B.'s portal tile (finally). The Win32 makefiles are not updated quite yet and thus will not build. Sorry. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6850 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/tiletex.h')
-rw-r--r--crawl-ref/source/tiletex.h55
1 files changed, 53 insertions, 2 deletions
diff --git a/crawl-ref/source/tiletex.h b/crawl-ref/source/tiletex.h
index 9a8f78ccd7..8d90803ef0 100644
--- a/crawl-ref/source/tiletex.h
+++ b/crawl-ref/source/tiletex.h
@@ -7,6 +7,8 @@
#ifndef TILETEX_H
#define TILETEX_H
+#include "tiles.h"
+
enum TextureID
{
TEX_DUNGEON,
@@ -52,9 +54,58 @@ protected:
class TilesTexture : public GenericTexture
{
public:
- void get_texcoord(int idx, float &x, float &y, float &wx, float &wy);
+ TilesTexture();
+
+ void set_info(int max, tile_info *info);
+ inline const tile_info &get_info(int idx);
+ inline void get_coords(int idx, int ofs_x, int ofs_y,
+ float &pos_sx, float &pos_sy,
+ float &pos_ex, float &pos_ey,
+ float &tex_sx, float &tex_sy,
+ float &tex_ex, float &tex_ey,
+ bool centre = true, int ymax = -1);
- void get_texcoord_doll(int part, int idx, int ymax, float &x, float &y, float &wx, float &wy, int &wx_pix, int &wy_pix, int &ox, int &oy);
+protected:
+ int m_tile_max;
+ tile_info *m_tile_info;
};
+inline const tile_info &TilesTexture::get_info(int idx)
+{
+ assert(idx < m_tile_max);
+ return m_tile_info[idx];
+}
+
+inline void TilesTexture::get_coords(int idx, int ofs_x, int ofs_y,
+ float &pos_sx, float &pos_sy,
+ float &pos_ex, float &pos_ey,
+ float &tex_sx, float &tex_sy,
+ float &tex_ex, float &tex_ey,
+ bool centre, int ymax)
+{
+ const tile_info &inf = get_info(idx);
+
+ float fwidth = m_width;
+ float fheight = m_height;
+
+ // center tiles on x, but allow taller tiles to extend upwards
+ int size_ox = centre ? TILE_X / 2 - inf.width / 2 : 0;
+ int size_oy = centre ? TILE_Y - inf.height : 0;
+
+ int ey = inf.ey;
+ if (ymax > 0)
+ ey = std::min(inf.sy + ymax - inf.offset_y, ey);
+
+ pos_sx += (ofs_x + inf.offset_x + size_ox) / (float)TILE_X;
+ pos_sy += (ofs_y + inf.offset_y + size_oy) / (float)TILE_Y;
+ pos_ex = pos_sx + (inf.ex - inf.sx) / (float)TILE_X;
+ pos_ey = pos_sy + (ey - inf.sy) / (float)TILE_Y;
+
+ tex_sx = inf.sx / fwidth;
+ tex_sy = inf.sy / fheight;
+ tex_ex = inf.ex / fwidth;
+ tex_ey = ey / fheight;
+}
+
+
#endif