score = 0 timer = 30 letter = string.char(math.random(97, 122)) font = love.graphics.newFont(48) gameover = false love.graphics.setFont(font) function love.update(dt) timer = timer - dt if timer <= 0 then gameover = true end end function love.draw() if not gameover then love.graphics.setColor(50/256, 127/256, 75/256) love.graphics.rectangle('fill', 0, love.graphics.getHeight()/2 - 50, love.graphics.getWidth() * (timer / 30), 100) love.graphics.setColor(1, 1, 1) love.graphics.print(letter, love.graphics.getWidth() / 2 - font:getWidth(letter)/2, love.graphics.getHeight()/2 - font:getHeight()/2) else love.graphics.setColor(200/256, 50/256, 50/256) love.graphics.print("GAME OVER", love.graphics.getWidth() / 2 - font:getWidth("GAME OVER")/2, love.graphics.getHeight()/2 - font:getHeight()/2) love.graphics.print("Press R to Restart", love.graphics.getWidth() / 2 - font:getWidth("Press R to Restart")/2, love.graphics.getHeight()/2 + font:getHeight() * 3/2) end love.graphics.setColor(1, 1, 1) love.graphics.print(score, love.graphics.getWidth() / 2 - font:getWidth(tostring(score)) / 2, 0) end function love.keypressed(key, scancode) if key == letter and not gameover then score = score + 1 letter = string.char(math.random(97, 122)) elseif gameover and scancode == 'r' then score = 0 gameover = false timer = 30 end end