Page 1 of 1

Help for a tug of war game.

Posted: Sun Jun 24, 2018 4:51 pm
by angrydonald
So im just trying to make a simple game. Which is a Tug of War game. Everything works but, when x==-10 or x== 10 it should say which side wins but it doesnt.

if x == -10 then
text = "red wins! Please wait"
love.timer.sleep(2)
x = 0
text = ("Keep Smashing")
end
here is the code. If anyone can tell me what i did wrong, and correct me that be nice. Also it change by increments of 1.

Re: Help for a tug of war game.

Posted: Sun Jun 24, 2018 7:41 pm
by Sir_Silver
I think you still need to upload your code.

Re: Help for a tug of war game.

Posted: Sun Jun 24, 2018 7:45 pm
by veethree

Code: Select all

if x == -10 then
This will only be true if x is exactly -10. Depending on how you're manipulating it, X might never be exactly -10. What you should do is something like this

Code: Select all

if x <= -10 then
This checks if x is lower or equal to -10.

Re: Help for a tug of war game.

Posted: Sun Jun 24, 2018 8:56 pm
by zorg
also don't use love.timer.sleep like that; you're expecting graphics to magically pop up because of that, but in reality, that's not how the game loop works. keep a timer around, and change the text value and stuff after a set amount of time elapsed; use love.update and dt for that.