Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function love.load()
- love.window.setMode(0, 0, {fullscreen = true})
- love.mouse.setVisible(true)
- width, height = love.window.getDimensions()
- state = 0
- ms = 0
- avg = 0
- takes = 0
- total = 0
- errors = 0
- math.randomseed(os.time())
- timer = math.random(2, 5)
- end
- function love.draw()
- if state == 0 then
- love.graphics.setBackgroundColor(100, 100, 100)
- love.graphics.print("Current FPS: "..tostring(love.timer.getFPS( )), 10, 10)
- local delta = love.timer.getAverageDelta()
- love.graphics.print(string.format("Average frame time: %.3f ms", 1000 * delta), 10, 20)
- love.graphics.print("Timer: "..ms, 10, 30)
- love.graphics.print("Avg: "..avg, 10, 40)
- love.graphics.print("Takes: "..takes, 10, 50)
- love.graphics.print("Errors: "..errors, 10, 60)
- return
- end
- if state == 1 then
- love.graphics.setBackgroundColor(0, 255, 0)
- end
- if state == 2 then
- love.graphics.setBackgroundColor(255, 0, 0)
- love.graphics.print("Timer: "..ms, 10, 10)
- end
- end
- function love.keypressed(key)
- if key == 'escape' then
- love.event.quit()
- end
- if key == 'delete' then
- total = 0
- avg = 0
- takes = 0
- errors = 0
- end
- end
- function love.mousepressed(x, y)
- if state == 0 then
- state = 1
- timer = math.random(2, 5)
- return
- elseif state == 1 then
- state = 0
- timer = math.random(2, 5)
- errors = errors + 1;
- return
- elseif state == 2 then
- state = 0
- timer = math.random(2, 5)
- takes = takes + 1;
- total = total + ms;
- avg = total / takes;
- end
- end
- function love.update(dt)
- if state == 1 then
- timer = timer - dt;
- ms = 0
- if timer <= 0 then
- state = 2
- end
- end
- if state == 2 then
- ms = ms + dt;
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement