Log In  

The code below should draw 10 squares, there is only one variable that define the size (b.s in _init), but sometimes some squares appear with a width different of the height. I don't know if its a bug, or I'm using rectifll in the wrong way.


function _init()
    for x=1,10 do
        local b={}

function _draw()
    for b in all(blocks) do
P#20958 2016-05-20 21:39 ( Edited 2016-05-21 03:11)

:: scgrn

The rnd() function returns floating point values (actually 16:16 fixed point) so when it comes time to render, the rectfill () function will round to the closest integer pixel coordinate. That's why you'll occasionally see rectangles with width and height differing by one pixel.

I'd recommend wrapping the assignments to b.x, b.y, and b.s in with flr() to force them to integer values.

P#20959 2016-05-20 21:48 ( Edited 2016-05-21 01:49)

The rounding is still something I'm getting used to too. I had to make a couple methods to help with randomizing and rounding.


Forum tip: Try include the nature of your question in the thread subject rather than just "help" - it just makes it easier for people to find things later.

P#20964 2016-05-20 22:25 ( Edited 2016-05-21 02:25)

thanks scgrn, that worked. With a small resolution these things become very noticeable.

morningtoast, you are right, I renamed with a better title.

P#20969 2016-05-20 23:11 ( Edited 2016-05-21 03:11)

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2022-06-28 03:14:35 | 0.006s | Q:14