Smooth line

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Leandros
Prole
Posts: 1
Joined: Thu Dec 31, 2015 3:56 pm

Smooth line

Post by Leandros »

Good evening,

I want to draw a line, following my player, but the line looks jagged (not related to missing AA) if the player is doing a sideway movement. See attached screenshot for the situation.

What I'm doing (just the line related stuff):

Code: Select all

local lines = {}

function love.update()
    -- Move Lines
    for i = 1, #lines, 1 do
        if i % 2 == 0 then
            lines[i] = lines[i] - 10 -- this will move the y-coord of the line 10 up, to simulate movement.
        end
    end

    -- Create new line
    table.insert(lines, objects.player.body:getX())
    table.insert(lines, objects.player.body:getY())
    table.insert(lines, objects.player.body:getX())
    table.insert(lines, objects.player.body:getY() - 10)
end

function love.draw(dt)
    love.graphics.setColor(0, 0, 0)
    love.graphics.setLineWidth(4*win_scale)
    love.graphics.setLineStyle("smooth")
    love.graphics.setLineJoin("none")
    if #lines > 2 then
        love.graphics.line(lines)
    end
end
Any ideas?
And while I have this thread, any ideas how to make the line a little wider each few ticks, equally smooth, though.
Attachments
Screen Shot 2015-12-31 at 17.01.16.png
Screen Shot 2015-12-31 at 17.01.16.png (88.37 KiB) Viewed 929 times
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 8 guests