love.graphics.print not working?
Posted: Wed Oct 09, 2019 5:43 pm
Hi, I am trying to print the score to the screen but it doesn't seem to be working. I start using love2d again recently when the new update came out, and this used to work for me.
This is the whole .lua file, and the print line is right at the bottom so scroll all the way down.
This is the whole .lua file, and the print line is right at the bottom so scroll all the way down.
Code: Select all
function love.load()
width = 400;
height = 488;
love.window.setMode(width, height);
love.window.setTitle("Floppy Box");
birdX = 50;
birdY = 220;
gravity = 0;
difficulty = "easy";
score = 0;
end
function spawnAsteroid()
end
function love.keypressed(key)
if (key == "space") then
jump();
end
end
function jump()
if not (birdY < 25) then
gravity = -160;
end
end
function love.update(dt)
gravity = gravity + (dt * 350)
birdY = birdY + (gravity * dt);
if (love.keyboard.isDown("escape")) then
love.event.quit();
end
end
function love.mousepressed(x, y, button, pressed)
if (button == 1) then
jump();
end
end
function love.draw()
love.graphics.setColor(.14, .36, .46);
love.graphics.rectangle("fill", 0, 0, width, height);
-- background
love.graphics.print("Score: ".. score, 50, 50);
love.graphics.setColor(.87, .84, .27);
love.graphics.rectangle("fill", birdX, birdY, 30, 25);
end