Decouple transparency and background colours for tiles

Moderator: Moderator

Post Reply
Message
Author
Grey
Loremaster
Posts: 3517
Joined: Thu Sep 23, 2010 10:18 pm
Location: London, England
Contact:

Decouple transparency and background colours for tiles

#1 Post by Grey »

Currently one cannot have background colours on tiles without having transparency enabled. I'm not sure why but it's quite annoying... ASCII just looks silly with transparency, but it can look very bland without background colours. Can this be changed? (And rather soon...?)
http://www.gamesofgrey.com - My own T-Engine games!
Roguelike Radio - A podcast about roguelikes

darkgod
Master of Eyal
Posts: 10750
Joined: Wed Jul 24, 2002 9:26 pm
Location: Angolwen
Contact:

Re: Decouple transparency and background colours for tiles

#2 Post by darkgod »

I .. I have no idea what you are asking, got an example of what you'd like ?
[tome] joylove: You can't just release an expansion like one would release a Kraken XD
--
[tome] phantomfrettchen: your ability not to tease anyone is simply stunning ;)

Grey
Loremaster
Posts: 3517
Joined: Thu Sep 23, 2010 10:18 pm
Location: London, England
Contact:

Re: Decouple transparency and background colours for tiles

#3 Post by Grey »

Unless I understand incorrectly the way to turn off transparency is to set "Map.tiles.force_back_color". But using that prevents the use of background colours on tiles (well, allows only one colour). Am I incorrect?

Edit: Also turning this on seems to block particle effects from squares with actors on them - bug?
http://www.gamesofgrey.com - My own T-Engine games!
Roguelike Radio - A podcast about roguelikes

darkgod
Master of Eyal
Posts: 10750
Joined: Wed Jul 24, 2002 9:26 pm
Location: Angolwen
Contact:

Re: Decouple transparency and background colours for tiles

#4 Post by darkgod »

If you have setup your map to allow for back colors (like the example module does) you can set a non-transparent color on any entities by setting

Code: Select all

back_color=colors.FOO
in the entity's definition
[tome] joylove: You can't just release an expansion like one would release a Kraken XD
--
[tome] phantomfrettchen: your ability not to tease anyone is simply stunning ;)

Grey
Loremaster
Posts: 3517
Joined: Thu Sep 23, 2010 10:18 pm
Location: London, England
Contact:

Re: Decouple transparency and background colours for tiles

#5 Post by Grey »

Just to repeat, this doesn't seem to work unless you have transparency enabled. As I understand it you need Map.tiles.force_back_color defined to stop the ASCII on top of ASCII look, but that prevents the game from reading any back_color definitions for tiles. If I comment out Map.tiles.force_back_color then the background colours work, but I'm stuck with ASCII on top of ASCII again.
http://www.gamesofgrey.com - My own T-Engine games!
Roguelike Radio - A podcast about roguelikes

darkgod
Master of Eyal
Posts: 10750
Joined: Wed Jul 24, 2002 9:26 pm
Location: Angolwen
Contact:

Re: Decouple transparency and background colours for tiles

#6 Post by darkgod »

Show me your code please it should work
[tome] joylove: You can't just release an expansion like one would release a Kraken XD
--
[tome] phantomfrettchen: your ability not to tease anyone is simply stunning ;)

Grey
Loremaster
Posts: 3517
Joined: Thu Sep 23, 2010 10:18 pm
Location: London, England
Contact:

Re: Decouple transparency and background colours for tiles

#7 Post by Grey »

Here ya go:

https://sites.google.com/site/darrenjoh ... ects=0&d=1

(there's been some changes since then, but it has the coloured backgrounds and force_back_colour turned off - if I make a symbol on the floor grids then you get that horrible ASCII on ASCII look)
http://www.gamesofgrey.com - My own T-Engine games!
Roguelike Radio - A podcast about roguelikes

darkgod
Master of Eyal
Posts: 10750
Joined: Wed Jul 24, 2002 9:26 pm
Location: Angolwen
Contact:

Re: Decouple transparency and background colours for tiles

#8 Post by darkgod »

Ah I think I understand what you want:
Show the background color of the grid tile & its ascii symbol.
But when the player walks over it show the background color of the GRID and the ascii of the PLAYER.
Right ?

Then you have to change how the engine sends map info to the core to be displayed. Luckily I already thought about that :)
In your load.lua you want to add:

Code: Select all

local Map = require "engine.Map"
Map.updateMapDisplay = function (self, x, y, mos)
	local g = self(x, y, self.TERRAIN)
	local gb = nil
	local o = self(x, y, self.OBJECT)
	local a = self(x, y, self.ACTOR)
	local t = self(x, y, self.TRAP)
	local p = self(x, y, self.PROJECTILE)
	if g then
		-- Update path caches from path strings
		for i = 1, #self.path_strings do
			local ps = self.path_strings[i]
			self._fovcache.path_caches[ps]:set(x, y, g:check("block_move", x, y, ps, false, true))
		end

		g:getMapObjects(self.tiles, mos, 1)
		g:setupMinimapInfo(g._mo, self)
		if g.default_tile then gb = g.default_tile end
	end
	if t then
		-- Handles trap being known
		if not self.actor_player or t:knownBy(self.actor_player) then
			t:getMapObjects(self.tiles, mos, 3)
			t:setupMinimapInfo(t._mo, self)
		else
			t = nil
		end
	end
	if o then
		o:getMapObjects(self.tiles, mos, 3)
		o:setupMinimapInfo(o._mo, self)
		if self.object_stack_count then
			local mo = o:getMapStackMO(self, x, y)
			if mo then mos[5] = mo end
		end
	end
	if a then
		-- Handles invisibility and telepathy and other such things
		if not self.actor_player or self.actor_player:canSee(a) then
			a:getMapObjects(self.tiles, mos, 3)
			a:setupMinimapInfo(a._mo, self)
		end
	end
	if p then
		p:getMapObjects(self.tiles, mos, 3)
		p:setupMinimapInfo(p._mo, self)
	end

	if gb and not p and not a and not o and not t then
		gb:getMapObjects(self.tiles, mos, 3)
	end
end
This will modify the display code to work nearly exactluy the same as before except it will place everything but the terrain on the same Z layer, so the display will show in order either: projectiles, actors, objects or traps.
It also checks for a "default_tile" property on the terrain and dislpays it if no projectiles, actors, objects or traps are found.

This means taht if you change your grids.lua to:

Code: Select all

newEntity{
	define_as = "DOWN",
	name = "next level",
	default_tile=class.new{_noalpha=false, display = '>', color_r=130, color_g=255, color_b=30}, display='', back_color=colors.SLATE,
	notice = true,
	always_remember = true,
	change_level = 1,
}

newEntity{
	define_as = "FLOOR",
	name = "floor",
	default_tile=class.new{_noalpha=false, display = ' ', color_r=185, color_g=185, color_b=245}, display='', back_color=colors.SLATE,
	always_remember = true,
}

newEntity{
	define_as = "WALL",
	name = "wall",
	default_tile=class.new{_noalpha=false, display = '#', color_r=165, color_g=165, color_b=205}, display='', back_color=colors.DARK_SLATE_GRAY,
	always_remember = true,
	does_block_move = true,
	can_pass = {pass_wall=1},
	block_sight = true,
	air_level = -20,
	dig = "FLOOR",
}

newEntity{
	define_as = "DOWN2",
	name = "next level",
	default_tile=class.new{_noalpha=false, display = '>', color_r=230, color_g=100, color_b=100}, display='', back_color=colors.SLATE,
	notice = true,
	always_remember = true,
	change_level = 1,
	change_zone = "dungeon2",
}
It'll do what you want :)

Basically this grids.lua file defines the same grids you did but only gives them a backcolor. The ascii symbol is set in the default_tile. This way the ascii symbol is only shown if nothing is over the terrain.
[tome] joylove: You can't just release an expansion like one would release a Kraken XD
--
[tome] phantomfrettchen: your ability not to tease anyone is simply stunning ;)

Grey
Loremaster
Posts: 3517
Joined: Thu Sep 23, 2010 10:18 pm
Location: London, England
Contact:

Re: Decouple transparency and background colours for tiles

#9 Post by Grey »

Ah, brilliant! Sorry it took so long to make clear what I wanted - guess I should have been clearer.

Solution is a bit longer than I expected (most cool stuff in the T-Engine only takes 1 line :P) but I'll get it copied in. Thankfully don't have many grids set up yet to change.
http://www.gamesofgrey.com - My own T-Engine games!
Roguelike Radio - A podcast about roguelikes

darkgod
Master of Eyal
Posts: 10750
Joined: Wed Jul 24, 2002 9:26 pm
Location: Angolwen
Contact:

Re: Decouple transparency and background colours for tiles

#10 Post by darkgod »

Hehe :!)
[tome] joylove: You can't just release an expansion like one would release a Kraken XD
--
[tome] phantomfrettchen: your ability not to tease anyone is simply stunning ;)

Post Reply