Help with a 3 lives game

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
100sle
Prole
Posts: 2
Joined: Sun Mar 10, 2013 2:04 am

Help with a 3 lives game

Post by 100sle »

I'm trying to make a game when you have 3 lives and if you loose your lives, game over. I've tried to put in this code...

function.load ()
lives = 3
paused = false;
end
if paused print("Game Over", 0, 0)
if lives = 0 then paused = true
end

function takeScore(n)
lives = lives - tonumber(n)
if lives < 1 then
lives = 0
end
end
User avatar
Lafolie
Inner party member
Posts: 809
Joined: Tue Apr 05, 2011 2:59 pm
Location: SR388
Contact:

Re: Help with a 3 lives game

Post by Lafolie »

Please use the [ code ] tags.

There are at least three syntax errors in your code (although one of them is valid, but doesn't do what you thought).

Code: Select all

function load()
    lives = 3
    paused = false --redundant unless you call this function multiple times
end

function takeScore(n)
    lives = lives - n
    paused = lives < 1 and true
end

--presumably
function love.graphics.draw()
    if paused then love.graphics.print("Game Over", 0, 0) end
end
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Help with a 3 lives game

Post by Robin »

Code: Select all

paused = lives < 1 and true
is the same as

Code: Select all

paused = lives < 1
Help us help you: attach a .love.
Post Reply

Who is online

Users browsing this forum: No registered users and 72 guests