diff --git a/game/engine/Entity.lua b/game/engine/Entity.lua index 5dd702d01469f9abaa9688caab547d50c054e48a..5905de0ec85be23b5b212a3fb52d891278b44102 100644 --- a/game/engine/Entity.lua +++ b/game/engine/Entity.lua @@ -72,6 +72,12 @@ function _M:init(t, no_default) self.color_bb = self.color.bb self.color = nil end + if self.tint then + self.tint_r = self.tint.r / 255 + self.tint_g = self.tint.g / 255 + self.tint_b = self.tint.b / 255 + self.tint = nil + end if not no_default then self.image = self.image or nil @@ -82,6 +88,9 @@ function _M:init(t, no_default) self.color_br = self.color_br or -1 self.color_bg = self.color_bg or -1 self.color_bb = self.color_bb or -1 + self.tint_r = self.tint_r or 1 + self.tint_g = self.tint_g or 1 + self.tint_b = self.tint_b or 1 end if self.unique and type(self.unique) ~= "string" then self.unique = self.name end diff --git a/game/engine/Map.lua b/game/engine/Map.lua index 10eb7bd6500e338da3ad2e996fb5d2ce9436d14a..04ebba78e94a28800c86a555f9fdb9b69db6f47d 100644 --- a/game/engine/Map.lua +++ b/game/engine/Map.lua @@ -295,6 +295,10 @@ function _M:updateMap(x, y) local o = self(x, y, OBJECT) local a = self(x, y, ACTOR) local t = self(x, y, TRAP) + local g_r, g_g, g_b + local o_r, o_g, o_b + local a_r, a_g, a_b + local t_r, t_g, t_b -- Update minimap if any local mm = MM_FLOOR @@ -302,11 +306,13 @@ function _M:updateMap(x, y) if g then mm = mm + (g:check("block_move") and MM_BLOCK or 0) mm = mm + (g:check("change_level") and MM_LEVEL_CHANGE or 0) + g_r, g_g, g_b = g.tint_r, g.tint_g, g.tint_b g = self.tiles:get(g.display, g.color_r, g.color_g, g.color_b, g.color_br, g.color_bg, g.color_bb, g.image) end if t then -- Handles invisibility and telepathy and other such things if not self.actor_player or t:knownBy(self.actor_player) then + t_r, t_g, t_b = t.tint_r, t.tint_g, t.tint_b t = self.tiles:get(t.display, t.color_r, t.color_g, t.color_b, t.color_br, t.color_bg, t.color_bb, t.image) mm = mm + MM_TRAP else @@ -314,6 +320,7 @@ function _M:updateMap(x, y) end end if o then + o_r, o_g, o_b = o.tint_r, o.tint_g, o.tint_b o = self.tiles:get(o.display, o.color_r, o.color_g, o.color_b, o.color_br, o.color_bg, o.color_bb, o.image) mm = mm + MM_OBJECT end @@ -322,6 +329,7 @@ function _M:updateMap(x, y) if not self.actor_player or self.actor_player:canSee(a) then local r = self.actor_player:reactionToward(a) mm = mm + (r > 0 and MM_FRIEND or (r == 0 and MM_NEUTRAL or MM_HOSTILE)) + a_r, a_g, a_b = a.tint_r, a.tint_g, a.tint_b a = self.tiles:get(a.display, a.color_r, a.color_g, a.color_b, a.color_br, a.color_bg, a.color_bb, a.image) else a = nil @@ -329,7 +337,13 @@ function _M:updateMap(x, y) end -- Cache the textures in the C map object - self._map:setGrid(x, y, g, t, o, a, mm) + self._map:setGrid(x, y, + g, g_r, g_g, g_b, + t, t_r, t_g, t_b, + o, o_r, o_g, o_b, + a, a_r, a_g, a_b, + mm + ) -- Update FOV caches if self:checkAllEntities(x, y, "block_sight", self.actor_player) then self._fovcache.block_sight:set(x, y, true) diff --git a/game/modules/tome/class/Player.lua b/game/modules/tome/class/Player.lua index ab2a3a7326b7fe995592fe4d143bbcaa38d780ed..7b4446bab8df36aef608200af34a036e6e08996e 100644 --- a/game/modules/tome/class/Player.lua +++ b/game/modules/tome/class/Player.lua @@ -150,6 +150,7 @@ function _M:playerFOV() if not game.zone.wilderness then self:computeFOV(self.esp.range or 10, "block_esp", function(x, y) game.level.map:applyESP(x, y) end, true, true) end -- Compute both the normal and the lite FOV, using cache if game.zone.wilderness_see_radius then + self:computeFOV(self.sight or 20, "block_sight", function(x, y, dx, dy, sqdist) game.level.map:apply(x, y) end, true, false, true) self:computeFOV(game.zone.wilderness_see_radius, "block_sight", function(x, y, dx, dy, sqdist) game.level.map:applyLite(x, y) end, true, true, true) else self:computeFOV(self.sight or 20, "block_sight", function(x, y, dx, dy, sqdist) game.level.map:apply(x, y) end, true, false, true) diff --git a/game/modules/tome/data/gfx/terrain/gate-morning.png b/game/modules/tome/data/gfx/terrain/gate-morning.png new file mode 100644 index 0000000000000000000000000000000000000000..c7cdbb2adf9fc60ebb588d309b88f7db4bfc4189 Binary files /dev/null and b/game/modules/tome/data/gfx/terrain/gate-morning.png differ diff --git a/game/modules/tome/data/maps/wilderness/arda-fareast.lua b/game/modules/tome/data/maps/wilderness/arda-fareast.lua index fb683dbcb5389aaab1874c8d8c55bfcd2214db35..cd5fef7d8fd678b206fc12d97efa3f87f0ae4e68 100644 --- a/game/modules/tome/data/maps/wilderness/arda-fareast.lua +++ b/game/modules/tome/data/maps/wilderness/arda-fareast.lua @@ -19,19 +19,19 @@ -- The far east on Arda -quickEntity('w', {show_tooltip=true, name='Sun Wall', display='^', color=colors.GOLD, image="terrain/mountain.png", block_move=true}) -quickEntity('=', {show_tooltip=true, name='the great sea', display='~', color=colors.BLUE, image="terrain/river.png", block_move=true}) -quickEntity(' ', {show_tooltip=true, name='plains', display='.', color=colors.LIGHT_GREEN, image="terrain/grass.png", can_encounter=true, equilibrium_level=-10}) -quickEntity('~', {show_tooltip=true, name='river', display='~', color={r=0, g=80, b=255}, image="terrain/river.png", can_encounter=true, equilibrium_level=-10}) -quickEntity('s', {show_tooltip=true, name='desert', display='.', color={r=203,g=189,b=72}, image="terrain/sand.png", can_encounter=true, equilibrium_level=-10}) -quickEntity('t', {show_tooltip=true, name='forest', display='#', color=colors.LIGHT_GREEN, image="terrain/tree.png", block_move=true}) -quickEntity('m', {show_tooltip=true, name='mountains', display='^', color=colors.UMBER, image="terrain/mountain.png", block_move=true}) -quickEntity('h', {show_tooltip=true, name='low hills', display='^', color=colors.GREEN, image="terrain/hills.png", can_encounter=true, equilibrium_level=-10}) +quickEntity('w', {always_remember = true, show_tooltip=true, name='Sun Wall', display='^', color=colors.GOLD, image="terrain/mountain.png", tint=colors.GOLD, block_move=true}) +quickEntity('=', {always_remember = true, show_tooltip=true, name='the great sea', display='~', color=colors.BLUE, image="terrain/river.png", block_move=true}) +quickEntity(' ', {always_remember = true, show_tooltip=true, name='plains', display='.', color=colors.LIGHT_GREEN, image="terrain/grass.png", can_encounter=true, equilibrium_level=-10}) +quickEntity('~', {always_remember = true, show_tooltip=true, name='river', display='~', color={r=0, g=80, b=255}, image="terrain/river.png", can_encounter=true, equilibrium_level=-10}) +quickEntity('s', {always_remember = true, show_tooltip=true, name='desert', display='.', color={r=203,g=189,b=72}, image="terrain/sand.png", can_encounter=true, equilibrium_level=-10}) +quickEntity('t', {always_remember = true, show_tooltip=true, name='forest', display='#', color=colors.LIGHT_GREEN, image="terrain/tree.png", block_move=true}) +quickEntity('m', {always_remember = true, show_tooltip=true, name='mountains', display='^', color=colors.UMBER, image="terrain/mountain.png", block_move=true}) +quickEntity('h', {always_remember = true, show_tooltip=true, name='low hills', display='^', color=colors.GREEN, image="terrain/hills.png", can_encounter=true, equilibrium_level=-10}) ---quickEntity('A', {show_tooltip=true, name="Caves below the tower of Amon Sûl", display='>', color={r=0, g=255, b=255}, notice = true, change_level=1, change_zone="tower-amon-sul"}) +--quickEntity('A', {always_remember = true, show_tooltip=true, name="Caves below the tower of Amon Sûl", display='>', color={r=0, g=255, b=255}, notice = true, change_level=1, change_zone="tower-amon-sul"}) ---quickEntity('1', {show_tooltip=true, name="Bree (Town)", desc="A quiet town at the crossroads of the north", display='*', color={r=255, g=255, b=255}, image="terrain/town1.png", notice = true, change_level=1, change_zone="town-bree"}) ---quickEntity('2', {show_tooltip=true, name="Minas Tirith (Town)", desc="Captical city of the Reunited-Kingdom and Gondor ruled by High King Eldarion", display='*', color={r=255, g=255, b=255}, image="terrain/town1.png", notice = true, change_level=1, change_zone="town-minas-tirith"}) +quickEntity('1', {always_remember = true, show_tooltip=true, name="Gates of Morning", desc="A massive hole in the Sun Wall", display='*', color=colors.GOLD, image="terrain/gate-morning.png", tint=colors.GOLD, notice = true, change_level=1, change_zone="town-gates-of-morning"}) +--quickEntity('2', {always_remember = true, show_tooltip=true, name="Minas Tirith (Town)", desc="Captical city of the Reunited-Kingdom and Gondor ruled by High King Eldarion", display='*', color={r=255, g=255, b=255}, image="terrain/town1.png", notice = true, change_level=1, change_zone="town-minas-tirith"}) -- Load encounters for this map --[[ @@ -84,7 +84,7 @@ return [[ ===== www============ ===== www============ ====== www============ -======== ======= hhhhhh Mww============ +======== ======= hhhhhh 1ww============ ============================== hhhhhhh www============ ================================ h www============ ================================= hh www============ diff --git a/game/modules/tome/data/zones/wilderness-arda-fareast/zone.lua b/game/modules/tome/data/zones/wilderness-arda-fareast/zone.lua index 3c543997d6d96f6c413f4aa63e0f3a6b1c19b564..835d7f2374b1a93fcd72dac7150fc60694f8b4f5 100644 --- a/game/modules/tome/data/zones/wilderness-arda-fareast/zone.lua +++ b/game/modules/tome/data/zones/wilderness-arda-fareast/zone.lua @@ -22,9 +22,9 @@ return { level_range = {1, 1}, max_level = 1, width = 100, height = 100, - all_remembered = true, - all_lited = true, - persistant = "memory", +-- all_remembered = true, +-- all_lited = true, +-- persistant = "memory", wilderness = true, wilderness_see_radius = 3, ambiant_music = "last", diff --git a/src/map.c b/src/map.c index bf11c9a55df972ed25524001c48e8a51d3b8ea41..5db22ca8a9c27a8c0a86572ceb463da63293fd7f 100644 --- a/src/map.c +++ b/src/map.c @@ -18,6 +18,7 @@ Nicolas Casalini "DarkGod" darkgod@te4.org */ +#include <math.h> #include "lua.h" #include "lauxlib.h" #include "lualib.h" @@ -69,10 +70,10 @@ static int map_new(lua_State *L) map->my = my; map->mwidth = mwidth; map->mheight = mheight; - map->grids_terrain = calloc(w, sizeof(GLuint*)); - map->grids_actor = calloc(w, sizeof(GLuint*)); - map->grids_trap = calloc(w, sizeof(GLuint*)); - map->grids_object = calloc(w, sizeof(GLuint*)); + map->grids_terrain = calloc(w, sizeof(map_texture*)); + map->grids_actor = calloc(w, sizeof(map_texture*)); + map->grids_trap = calloc(w, sizeof(map_texture*)); + map->grids_object = calloc(w, sizeof(map_texture*)); map->grids_seens = calloc(w, sizeof(bool*)); map->grids_remembers = calloc(w, sizeof(bool*)); map->grids_lites = calloc(w, sizeof(bool*)); @@ -82,10 +83,10 @@ static int map_new(lua_State *L) int i; for (i = 0; i < w; i++) { - map->grids_terrain[i] = calloc(h, sizeof(GLuint)); - map->grids_actor[i] = calloc(h, sizeof(GLuint)); - map->grids_object[i] = calloc(h, sizeof(GLuint)); - map->grids_trap[i] = calloc(h, sizeof(GLuint)); + map->grids_terrain[i] = calloc(h, sizeof(map_texture)); + map->grids_actor[i] = calloc(h, sizeof(map_texture)); + map->grids_object[i] = calloc(h, sizeof(map_texture)); + map->grids_trap[i] = calloc(h, sizeof(map_texture)); map->grids_seens[i] = calloc(h, sizeof(bool)); map->grids_remembers[i] = calloc(h, sizeof(bool)); map->grids_lites[i] = calloc(h, sizeof(bool)); @@ -202,17 +203,51 @@ static int map_set_grid(lua_State *L) map_type *map = (map_type*)auxiliar_checkclass(L, "core{map}", 1); int x = luaL_checknumber(L, 2); int y = luaL_checknumber(L, 3); + GLuint *g = lua_isnil(L, 4) ? NULL : (GLuint*)auxiliar_checkclass(L, "gl{texture}", 4); - GLuint *t = lua_isnil(L, 5) ? NULL : (GLuint*)auxiliar_checkclass(L, "gl{texture}", 5); - GLuint *o = lua_isnil(L, 6) ? NULL : (GLuint*)auxiliar_checkclass(L, "gl{texture}", 6); - GLuint *a = lua_isnil(L, 7) ? NULL : (GLuint*)auxiliar_checkclass(L, "gl{texture}", 7); - unsigned char mm = luaL_checknumber(L, 8); + float g_r = lua_tonumber(L, 5); + float g_g = lua_tonumber(L, 6); + float g_b = lua_tonumber(L, 7); + + GLuint *t = lua_isnil(L, 8) ? NULL : (GLuint*)auxiliar_checkclass(L, "gl{texture}", 8); + float t_r = lua_tonumber(L, 9); + float t_g = lua_tonumber(L, 10); + float t_b = lua_tonumber(L, 11); + + GLuint *o = lua_isnil(L, 12) ? NULL : (GLuint*)auxiliar_checkclass(L, "gl{texture}", 12); + float o_r = lua_tonumber(L, 13); + float o_g = lua_tonumber(L, 14); + float o_b = lua_tonumber(L, 15); + + GLuint *a = lua_isnil(L, 16) ? NULL : (GLuint*)auxiliar_checkclass(L, "gl{texture}", 16); + float a_r = lua_tonumber(L, 17); + float a_g = lua_tonumber(L, 18); + float a_b = lua_tonumber(L, 19); + + unsigned char mm = lua_tonumber(L, 8); if (x < 0 || y < 0 || x >= map->w || y >= map->h) return 0; - map->grids_terrain[x][y] = g ? *g : 0; - map->grids_trap[x][y] = t ? *t : 0; - map->grids_actor[x][y] = a ? *a : 0; - map->grids_object[x][y] = o ? *o : 0; + + map->grids_terrain[x][y].texture = g ? *g : 0; + map->grids_terrain[x][y].tint_r = g_r; + map->grids_terrain[x][y].tint_g = g_g; + map->grids_terrain[x][y].tint_b = g_b; + + map->grids_trap[x][y].texture = t ? *t : 0; + map->grids_trap[x][y].tint_r = t_r; + map->grids_trap[x][y].tint_g = t_g; + map->grids_trap[x][y].tint_b = t_b; + + map->grids_actor[x][y].texture = a ? *a : 0; + map->grids_actor[x][y].tint_r = a_r; + map->grids_actor[x][y].tint_g = a_g; + map->grids_actor[x][y].tint_b = a_b; + + map->grids_object[x][y].texture = o ? *o : 0; + map->grids_object[x][y].tint_r = o_r; + map->grids_object[x][y].tint_g = o_g; + map->grids_object[x][y].tint_b = o_b; + map->minimap[x][y] = mm; return 0; } @@ -303,6 +338,7 @@ static int map_to_screen(lua_State *L) int x = luaL_checknumber(L, 2); int y = luaL_checknumber(L, 3); int i = 0, j = 0; + float r, g, b, a, n; for (i = map->mx; i < map->mx + map->mwidth; i++) { @@ -317,13 +353,16 @@ static int map_to_screen(lua_State *L) { if (map->grids_seens[i][j]) { - glColor4f(map->shown_r, map->shown_g, map->shown_b, map->shown_a); - if (map->multidisplay) { - if (map->grids_terrain[i][j]) + if (map->grids_terrain[i][j].texture) { - glBindTexture(GL_TEXTURE_2D, map->grids_terrain[i][j]); + map_texture *m = &(map->grids_terrain[i][j]); + if (m->tint_r < 1 || m->tint_g < 1 || m->tint_b < 1) + glColor4f((map->shown_r + m->tint_r)/2, (map->shown_g + m->tint_g)/2, (map->shown_b + m->tint_b)/2, map->shown_a); + else + glColor4f(map->shown_r, map->shown_g, map->shown_b, map->shown_a); + glBindTexture(GL_TEXTURE_2D, map->grids_terrain[i][j].texture); glBegin(GL_QUADS); glTexCoord2f(0,0); glVertex3f(0 +dx, 0 +dy,-99); glTexCoord2f(1,0); glVertex3f(map->tile_w +dx, 0 +dy,-99); @@ -331,9 +370,14 @@ static int map_to_screen(lua_State *L) glTexCoord2f(0,1); glVertex3f(0 +dx, map->tile_h +dy,-99); glEnd(); } - if (map->grids_trap[i][j]) + if (map->grids_trap[i][j].texture) { - glBindTexture(GL_TEXTURE_2D, map->grids_trap[i][j]); + map_texture *m = &(map->grids_trap[i][j]); + if (m->tint_r < 1 || m->tint_g < 1 || m->tint_b < 1) + glColor4f((map->shown_r + m->tint_r)/2, (map->shown_g + m->tint_g)/2, (map->shown_b + m->tint_b)/2, map->shown_a); + else + glColor4f(map->shown_r, map->shown_g, map->shown_b, map->shown_a); + glBindTexture(GL_TEXTURE_2D, map->grids_trap[i][j].texture); glBegin(GL_QUADS); glTexCoord2f(0,0); glVertex3f(0 +dx, 0 +dy,-99); glTexCoord2f(1,0); glVertex3f(map->tile_w +dx, 0 +dy,-99); @@ -341,9 +385,14 @@ static int map_to_screen(lua_State *L) glTexCoord2f(0,1); glVertex3f(0 +dx, map->tile_h +dy,-99); glEnd(); } - if (map->grids_object[i][j]) + if (map->grids_object[i][j].texture) { - glBindTexture(GL_TEXTURE_2D, map->grids_object[i][j]); + map_texture *m = &(map->grids_object[i][j]); + if (m->tint_r < 1 || m->tint_g < 1 || m->tint_b < 1) + glColor4f((map->shown_r + m->tint_r)/2, (map->shown_g + m->tint_g)/2, (map->shown_b + m->tint_b)/2, map->shown_a); + else + glColor4f(map->shown_r, map->shown_g, map->shown_b, map->shown_a); + glBindTexture(GL_TEXTURE_2D, map->grids_object[i][j].texture); glBegin(GL_QUADS); glTexCoord2f(0,0); glVertex3f(0 +dx, 0 +dy,-99); glTexCoord2f(1,0); glVertex3f(map->tile_w +dx, 0 +dy,-99); @@ -351,9 +400,14 @@ static int map_to_screen(lua_State *L) glTexCoord2f(0,1); glVertex3f(0 +dx, map->tile_h +dy,-99); glEnd(); } - if (map->grids_actor[i][j]) + if (map->grids_actor[i][j].texture) { - glBindTexture(GL_TEXTURE_2D, map->grids_actor[i][j]); + map_texture *m = &(map->grids_actor[i][j]); + if (m->tint_r < 1 || m->tint_g < 1 || m->tint_b < 1) + glColor4f((map->shown_r + m->tint_r)/2, (map->shown_g + m->tint_g)/2, (map->shown_b + m->tint_b)/2, map->shown_a); + else + glColor4f(map->shown_r, map->shown_g, map->shown_b, map->shown_a); + glBindTexture(GL_TEXTURE_2D, map->grids_actor[i][j].texture); glBegin(GL_QUADS); glTexCoord2f(0,0); glVertex3f(0 +dx, 0 +dy,-99); glTexCoord2f(1,0); glVertex3f(map->tile_w +dx, 0 +dy,-99); @@ -364,9 +418,14 @@ static int map_to_screen(lua_State *L) } else { - if (map->grids_actor[i][j]) + if (map->grids_actor[i][j].texture) { - glBindTexture(GL_TEXTURE_2D, map->grids_actor[i][j]); + map_texture *m = &(map->grids_actor[i][j]); + if (m->tint_r < 1 || m->tint_g < 1 || m->tint_b < 1) + glColor4f((map->shown_r + m->tint_r)/2, (map->shown_g + m->tint_g)/2, (map->shown_b + m->tint_b)/2, map->shown_a); + else + glColor4f(map->shown_r, map->shown_g, map->shown_b, map->shown_a); + glBindTexture(GL_TEXTURE_2D, map->grids_actor[i][j].texture); glBegin(GL_QUADS); glTexCoord2f(0,0); glVertex3f(0 +dx, 0 +dy,-99); glTexCoord2f(1,0); glVertex3f(map->tile_w +dx, 0 +dy,-99); @@ -374,9 +433,14 @@ static int map_to_screen(lua_State *L) glTexCoord2f(0,1); glVertex3f(0 +dx, map->tile_h +dy,-99); glEnd(); } - else if (map->grids_object[i][j]) + else if (map->grids_object[i][j].texture) { - glBindTexture(GL_TEXTURE_2D, map->grids_object[i][j]); + map_texture *m = &(map->grids_object[i][j]); + if (m->tint_r < 1 || m->tint_g < 1 || m->tint_b < 1) + glColor4f((map->shown_r + m->tint_r)/2, (map->shown_g + m->tint_g)/2, (map->shown_b + m->tint_b)/2, map->shown_a); + else + glColor4f(map->shown_r, map->shown_g, map->shown_b, map->shown_a); + glBindTexture(GL_TEXTURE_2D, map->grids_object[i][j].texture); glBegin(GL_QUADS); glTexCoord2f(0,0); glVertex3f(0 +dx, 0 +dy,-99); glTexCoord2f(1,0); glVertex3f(map->tile_w +dx, 0 +dy,-99); @@ -384,9 +448,14 @@ static int map_to_screen(lua_State *L) glTexCoord2f(0,1); glVertex3f(0 +dx, map->tile_h +dy,-99); glEnd(); } - else if (map->grids_trap[i][j]) + else if (map->grids_trap[i][j].texture) { - glBindTexture(GL_TEXTURE_2D, map->grids_trap[i][j]); + map_texture *m = &(map->grids_trap[i][j]); + if (m->tint_r < 1 || m->tint_g < 1 || m->tint_b < 1) + glColor4f((map->shown_r + m->tint_r)/2, (map->shown_g + m->tint_g)/2, (map->shown_b + m->tint_b)/2, map->shown_a); + else + glColor4f(map->shown_r, map->shown_g, map->shown_b, map->shown_a); + glBindTexture(GL_TEXTURE_2D, map->grids_trap[i][j].texture); glBegin(GL_QUADS); glTexCoord2f(0,0); glVertex3f(0 +dx, 0 +dy,-99); glTexCoord2f(1,0); glVertex3f(map->tile_w +dx, 0 +dy,-99); @@ -394,9 +463,14 @@ static int map_to_screen(lua_State *L) glTexCoord2f(0,1); glVertex3f(0 +dx, map->tile_h +dy,-99); glEnd(); } - else if (map->grids_terrain[i][j]) + else if (map->grids_terrain[i][j].texture) { - glBindTexture(GL_TEXTURE_2D, map->grids_terrain[i][j]); + map_texture *m = &(map->grids_terrain[i][j]); + if (m->tint_r < 1 || m->tint_g < 1 || m->tint_b < 1) + glColor4f((map->shown_r + m->tint_r)/2, (map->shown_g + m->tint_g)/2, (map->shown_b + m->tint_b)/2, map->shown_a); + else + glColor4f(map->shown_r, map->shown_g, map->shown_b, map->shown_a); + glBindTexture(GL_TEXTURE_2D, map->grids_terrain[i][j].texture); glBegin(GL_QUADS); glTexCoord2f(0,0); glVertex3f(0 +dx, 0 +dy,-99); glTexCoord2f(1,0); glVertex3f(map->tile_w +dx, 0 +dy,-99); @@ -408,10 +482,14 @@ static int map_to_screen(lua_State *L) } else { - glColor4f(map->obscure_r, map->obscure_g, map->obscure_b, map->obscure_a); - if (map->grids_terrain[i][j]) + if (map->grids_terrain[i][j].texture) { - glBindTexture(GL_TEXTURE_2D, map->grids_terrain[i][j]); + map_texture *m = &(map->grids_terrain[i][j]); + if (m->tint_r < 1 || m->tint_g < 1 || m->tint_b < 1) + glColor4f((map->obscure_r + m->tint_r)/2, (map->obscure_g + m->tint_g)/2, (map->obscure_b + m->tint_b)/2, map->obscure_a); + else + glColor4f(map->obscure_r, map->obscure_g, map->obscure_b, map->obscure_a); + glBindTexture(GL_TEXTURE_2D, map->grids_terrain[i][j].texture); glBegin(GL_QUADS); glTexCoord2f(0,0); glVertex3f(0 +dx, 0 +dy,-99); glTexCoord2f(1,0); glVertex3f(map->tile_w +dx, 0 +dy,-99); diff --git a/src/map.h b/src/map.h index f7800d139189362da37b5161b2dfbd9c2f792771..1eb3fb4f5824ce11e06cf00f5edc986cb6fbaace 100644 --- a/src/map.h +++ b/src/map.h @@ -24,10 +24,17 @@ #include "tgl.h" typedef struct { - GLuint **grids_terrain; - GLuint **grids_actor; - GLuint **grids_object; - GLuint **grids_trap; + GLuint texture; + float tint_r; + float tint_g; + float tint_b; +} map_texture; + +typedef struct { + map_texture **grids_terrain; + map_texture **grids_actor; + map_texture **grids_object; + map_texture **grids_trap; bool **grids_seens; bool **grids_remembers; bool **grids_lites;