Because if you check if the game is not paused
or the game is not in menu, then when you are paused, but not in menu, the statement will still return true and thus will run the update function. You should use
and instead. When you're stuck, just make the classic truth table:
Code: Select all
or | not inPause | not inMenu | result
------------------------+-------------+------------+--------
game paused and in menu | false | false | false
game paused | false | true | true
game in menu | true | false | true
game playing | true | true | true
and | not inPause | not inMenu | result
------------------------+-------------+------------+--------
game paused and in menu | false | false | false
game paused | false | true | false
game in menu | true | false | false
game playing | true | true | true
You only want the statement to be true if the game is playing normally, not paused and not in menu, so look at the table, you'll see that only happens if you use "(not inPause) and (not inMenu)", not
or. It's because you're negating. If you didn't check for
not inPause, then you would've used
or, for example:
Code: Select all
if inPause or inMenu then
-- do nothing
else
gameupdate(dt)
end