Page 1 of 1

Where can I find a newb friendly layout on getting started?

Posted: Sun Jan 31, 2010 1:33 am
by Xoria
I understand that there was a recent update, but I can only find the 'getting started' page of the older v. Where's latest version of LOVE's getting started page? Thanks in advance

Edit: Also, how does one start a timer since the app has been launched? (Something that tells you how long you were playing)

Re: Where can I find a newb friendly layout on getting started?

Posted: Sun Jan 31, 2010 3:54 am
by scripto
simply look in the doc for the timer, and for the recent things idk.

Re: Where can I find a newb friendly layout on getting started?

Posted: Sun Jan 31, 2010 9:09 am
by Robin
http://love2d.org/docs/getting_started.html is the getting started page.

Re: Where can I find a newb friendly layout on getting started?

Posted: Sun Jan 31, 2010 5:16 pm
by TechnoCat
Xoria wrote:Edit: Also, how does one start a timer since the app has been launched? (Something that tells you how long you were playing)
untested:

Code: Select all

function love.load()
   time=0
end
function love.update(dt)
   time = time+dt
end
function love.draw()
   love.graphics.print(math.floor(time).." seconds have passed",0,12) --math.floor(x) truncates the decimal off x
end

Re: Where can I find a newb friendly layout on getting started?

Posted: Sun Jan 31, 2010 7:08 pm
by Xoria
Thanks again.

Re: Where can I find a newb friendly layout on getting started?

Posted: Sun Jan 31, 2010 10:51 pm
by Jasoco
I offer an alternative method.

Code: Select all

function love.load()
   stime = love.timer.getTime()
end
function love.update(dt)
   time = stime - love.timer.getTime()
end
function love.draw()
   love.graphics.print(math.floor(time).." seconds have passed",0,12)
end
At least this method works in 0.5.0. As long as 0.6.0 still uses getTime() to return the seconds since application launch.

And a bonus, a function that converts seconds into hours, minutes and seconds that I wrote myself:

Code: Select all

function formatTime(t) return math.floor(math.mod(t/60/60,60)) .. ":" .. string.sub("0" .. math.floor(math.mod(t/60,60)),-2) .. ":" .. string.sub("0" .. math.floor(math.mod(t,60)),-2) end
I used this method for my game engine to calculate how much total time you spent in a single game session between saves. You know like how RPG's will display total play time.

Use this when setting up the game variables:

Code: Select all

gameStartTime = love.timer.getTime()
Then use this when you load a game right after loading the game, or set it to 0 if starting a new one: (Usually right in the same function)

Code: Select all

gameSessionPrevious = gameSession
Use this every update during the actual game play:

Code: Select all

gameSession = love.timer.getTime() - gameStartTime
When saving the game, save the gameSession variable for loading next time.