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
Help with a 3 lives game
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Help with a 3 lives game
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).
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.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Help with a 3 lives game
Code: Select all
paused = lives < 1 and true
Code: Select all
paused = lives < 1
Help us help you: attach a .love.
Who is online
Users browsing this forum: Ahrefs [Bot] and 16 guests