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

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
Xoria
Citizen
Posts: 61
Joined: Sun Jan 31, 2010 1:24 am

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

Post 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)
scripto
Prole
Posts: 5
Joined: Sun Jan 31, 2010 3:52 am

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

Post by scripto »

simply look in the doc for the timer, and for the recent things idk.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

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

Post by Robin »

http://love2d.org/docs/getting_started.html is the getting started page.
Help us help you: attach a .love.
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Milwaukee, WI
Contact:

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

Post 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
Xoria
Citizen
Posts: 61
Joined: Sun Jan 31, 2010 1:24 am

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

Post by Xoria »

Thanks again.
User avatar
Jasoco
Inner party member
Posts: 3726
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

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

Post 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.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot], Semrush [Bot] and 11 guests