I had a (maybe weird) solution, where I'd have a second canvas that tracks where the player's already walked, and multiply the trail in the first canvas by the value (0 or 1) in the second canvas to determine whether the trail needs to be drawn or not.
For example, I want to add to the trail at the player's current position: But I don't want to add to it if they've already been there, so I keep track of where they've been in black: I then multiply the trail by the value of the path canvas to mask out any areas they've already been: My idea was to draw the trail to a temporary canvas, save the second canvas as an ImageData, then draw the ImageData to the temporary canvas using love.graphics.newImage like so:
Code: Select all
love.graphics.setCanvas(tempcanvas)
pathdata = pathcanvas:newImageData( ) --convert the path canvas into ImageData
love.graphics.setColor(1, 1, 1, .5)
love.graphics.circle('fill', x, y, 10) --draw a transparent circle to the tempcanvas
love.graphics.setBlendMode("multiply","premultiplied") --switch to a multiply mode
love.graphics.newImage(delaydata) --draw the path on top of the tempcanvas
Code: Select all
love.graphics.setCanvas(tempcanvas)
pathdata = pathcanvas:newImageData( ) --convert the path canvas into ImageData
love.graphics.newImage(delaydata) --draw the path on top of the tempcanvas