Page 1 of 1

[solved][b42] Non-square tiles seem to cause mouse offset

Posted: Sun Nov 18, 2012 5:24 am
by andar_b
I'm screwing around with the display settings and I kinda like using rectangular tiles, but after hacking away at my code for hours trying to find why the tooltip was inspecting the tile to the left of where I was actually hovering - I realized it was the rectangular tiles.

Here's a snippet of what I did to my game.lua

Code: Select all

function _M:setupDisplayMode()
	print("[DISPLAY MODE] 32x32 ASCII/background")
 -- when th and tw = 32, mouse works fine. When done like this, mouse is offset.
 -- font_scale = 175, which gives me a reasonably tidy way to adjust font size based on screen resolution. 
 -- It works pretty good everywhere else.
	local th = (self.h/font_scale)*5
	local tw = (self.h/font_scale)*4
	Map:setViewPort(0, 0, self.w, self.h, tw, th, "/data/font/FSEX300.ttf", (self.h/font_scale)*7, true)
	Map:resetTiles()
	Map.tiles.use_images = false
 -- snip

Re: [b42] Non-square tiles seem to cause mouse offset

Posted: Sun Nov 18, 2012 5:13 pm
by tiger_eye
Tiles displayed rectangular should work. I've played around with 'em before.

Do the source images have dimensions that are powers of two?

"th" and "tw" should probably be integers, so perhaps do:

Code: Select all

    local th = math.floor((self.h/font_scale)*5)
    local tw = math.floor((self.h/font_scale)*4)
Is anything else offset, like particles or targeting highlights?

Re: [b42] Non-square tiles seem to cause mouse offset

Posted: Sun Nov 18, 2012 5:41 pm
by andar_b
I didn't have targeting highlights or particles, let alone knowing how to activate them. ^.^

Actually, math.floor seems to have corrected the problem. I guess I'm kinda used to C's rounding off of integer values, completely forgot that I should round it manually.

Still leaves me with a few other problems with the tile display, but this issue is solved. It still might make sense to round those values internally if floating point input makes it choke.