Pause Game Element

Pause Game Element

Hi, I do Javascript for fun, and I’m tryinng to add a pause game feature. How do I do this?

Imagine you have var moving that increases after button press and that you have var switch that switches between true and false(boolean). If it’s true, it’s paused and button pressing doesn’t increase var moving. When you press pause again, switch variable goes to false, and pressing button again increases moving.

Pseudo code:

var switch= true;
if clicked on switch, switch get opposite of what it holds at  moment of clicking on it.

Setting switch true initially also is good since before starting a game, it’s just as is paused …

This isn’t really possible to answer because it depends entirely on how the game is coded as to whether this is simple, as @codename11 describes, or extremely difficult. Need more context. What they describe is how it will work at a high level, but how it actually works in practise is something different.