Antonioss Posted August 13, 2016 Share Posted August 13, 2016 hi there,i am new in javascript,i am following the w3schools tutorials for making a gameto be specific this tutorial http://www.w3schools.com/games/tryit.asp?filename=trygame_gravity_game but i need help to add a pause function , i have tried a few things but nothing.i dont know if i have to add Time and loop, or if this can be done only with Frame No.Thank you Link to comment Share on other sites More sharing options...
Ingolme Posted August 13, 2016 Share Posted August 13, 2016 Add a property "paused" to myGameArea myGameArea = { paused : false, Create a function that should be called by the pause button: function pause() { myGameArea.paused = !myGameArea.paused; } In the updateGameArea() function, do nothing if the game is paused: function updateGameArea() { var x, height, gap, minHeight, maxHeight, minGap, maxGap; if(myGameArea.paused) { return; } How and when the pause() function is called is up to you. Games are very complex programs, if you're new to Javascript you probably do not have enough experience yet to solve the kind of problems that games provide. 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now