how to put a time

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
needhelp911
Prole
Posts: 3
Joined: Sun Jun 17, 2018 2:33 am

how to put a time

Post by needhelp911 »

guys, i need to put time in my game, but i really don`t know how. Can you help me??
it`s just to pass while the game is running and when the user win then the time stop, how can i do this????
HELP ME PLEASEEE
Atone
Prole
Posts: 6
Joined: Mon Aug 28, 2017 5:16 am

Re: how to put a time

Post by Atone »

When love calls your love.update function, it passes in an argument called dt, aka delta time, which is the time elapsed since the last update (in seconds, probably a very small number like 0.01). You can use this for timing. The following is a simple example of a timer, just counting the time since the program started and printing it out every frame.

Code: Select all

local timer = 0

function love.update(dt)
	timer = timer + dt
	print(timer)
end
DarkShroom
Citizen
Posts: 86
Joined: Mon Jul 17, 2017 2:07 pm

Re: how to put a time

Post by DarkShroom »

or

Code: Select all

--save start time
start_time = love.timer.getTime()

--to get the time since start
time_elapsed = love.timer.getTime() - start_time

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 48 guests