I'm trying to make an effect that "simulates" the stars in movement and I'm making them with the color white, but some lines are showing grey, as you can see in the image:
function GameEffect:draw()
for i=1, #self.rays do
love.graphics.setColor(255, 255, 255)
love.graphics.setLineWidth(1.5)
love.graphics.line(self.rays[i].x, self.rays[i].y, self.rays[i].x + self.rays[i].lenght, self.rays[i].y)
love.graphics.setLineWidth(self.defaultWidth)
end
end
I used setLineWidth to see if this could help, but it didn't.
local GameEffect = {}
function love.load()
love.window.setMode(430, 356)
local gen = love.math.newRandomGenerator(4)
GameEffect.rays = {}
GameEffect.defaultWidth = 1
for i = 1, 15 do
GameEffect.rays[#GameEffect.rays + 1] = {
lenght = 60;
x = gen:random(370);
y = gen:random(354);
}
end
end
function love.draw()
love.graphics.clear(217, 207, 80)
GameEffect:draw()
end
function GameEffect:draw()
for i=1, #self.rays do
love.graphics.setColor(255, 255, 255)
love.graphics.setLineWidth(1.5)
love.graphics.line(self.rays[i].x, self.rays[i].y, self.rays[i].x + self.rays[i].lenght, self.rays[i].y)
love.graphics.setLineWidth(self.defaultWidth)
end
end
function love.keypressed(k) if k == "escape" then love.event.quit() end end
If you need further help, please post a .love file or at least a complete reproducible test case like the above.
@Kibita: Is it possible you are drawing the lines at non-integer coordinates (10.393, 12.939 for example)? If so, try to math.floor the coordinates before drawing.
love.graphics.clear is unnecessary in the default [wiki]love.run[/wiki], since LÖVE calls it directly before love.draw is called. You can use [wiki]love.graphics.setBackgroundColor[/wiki] to set the color it uses for that clear call.
local GameEffect = {}
function love.load()
love.window.setMode(430, 356)
local gen = love.math.newRandomGenerator(4)
GameEffect.rays = {}
GameEffect.defaultWidth = 1
for i = 1, 15 do
GameEffect.rays[#GameEffect.rays + 1] = {
lenght = 60;
x = gen:random()*370;
y = gen:random()*354;
}
end
love.graphics.setBackgroundColor(217, 207, 80)
end
function love.draw()
GameEffect:draw()
end
function GameEffect:draw()
for i=1, #self.rays do
love.graphics.setColor(255, 255, 255)
love.graphics.setLineWidth(1.5)
love.graphics.line(self.rays[i].x, self.rays[i].y, self.rays[i].x + self.rays[i].lenght, self.rays[i].y)
love.graphics.setLineWidth(self.defaultWidth)
end
end
function love.keypressed(k) if k == "escape" then love.event.quit() end end