chris-kun wrote:the following code should work:
Ok, I was right, the problem with the different colors is because one was a line, and the other was an image. Check out the below code (unneeded code removed for clarity):
Code: Select all
function love.load()
x = 850
y = 650
love.graphics.setMode(x, y, false, true, 0)
love.graphics.setBackgroundColor(51,51,51)
p1,p2 = 0,0
paddle={
{x1=25, x2=25, y1=y/2-46, y2=y/2+46},
{x1=825, x2=825, y1=y/2-46, y2=y/2+46}
}
paddle_color = {122, 150, 191}
love.graphics.setLineWidth(2)
end
function love.draw()
love.graphics.setColor(paddle_color)
for i=1, #paddle do
love.graphics.line(paddle[i].x1, paddle[i].y1, paddle[i].x2, paddle[i].y2)
end
love.graphics.setColor(255,255,255)
love.graphics.print(p1,5,5)
love.graphics.print(p2,x-13,5)
end
This will draw both paddles using lines (no image needed) at the same color, which is #7a96bf according to Photoshop: exactly what we told it to be. The only other big difference in this code is that at load I tell the lines to be 2 pixels wide, rather than 1. As vrld pointed out, half-pixels are your enemy: in this case, it's make your line appear to be 2px wide, but also semitransparent, netting you a very dark #525e70-ish color.
Some other friendly advice: use longer variable names, ones that are more descriptive. I assume p1 and p2 represent player scores, but it's not very clear. Same with your x and y variables: they seem to represent the screen width and height, but that has a high chance of tripping you up later.
Another thing you may want to do is change your print statements to printf statements, and then make the right one right-aligned, like so:
Code: Select all
love.graphics.printf(p2, x-55, 5, 50, "right")
I know it looks more complex, but it'll save you from the headache of the player score going offscreen (change p2 to 20 to see what I mean)