Skip to content

Commit

Permalink
Add mute button, clean up readme
Browse files Browse the repository at this point in the history
  • Loading branch information
gamalielhere committed Jan 24, 2018
1 parent ecd3bc3 commit 035ae87
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ My design approach is basically reviving a retro game. I used "Press Start 2P" a
All of my user stories can be found in my [Trelloboards](https://trello.com/b/TTtZgl3z)

# CODE
[The code can be found here](https://github.com/gamalielhere/projects/tree/master/project_1/snake)
[The code can be found here](https://github.com/gamalielhere/snake)

[And the hosted game site can be found here](http://gamalielhere.github.io/snake/)
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ <h3 class="score"></h3>
<button class="reset" onclick="resetGame();">RESET</button>
<button class="pause" onclick="pauseGame();">PAUSE</button>
<button class="resume" onclick="resumeGame();">RESUME</button>
<button class="mute" onclick="muteGame();">Music: <span class="musicSetting"> On</span></button>
<h1>HIGHSCORE: <span id="highScore"></span> </h1>
</div>
</div>
Expand Down
22 changes: 21 additions & 1 deletion js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
// Music Variables
const run = document.getElementById("run"),
die = document.getElementById("die"),
eat = document.getElementById("eat");
eat = document.getElementById("eat"),
musicSetting = document.getElementsByClassName("musicSetting");
let muted = false;

// Button Variables
const startButton = document.getElementsByClassName("start"),
Expand Down Expand Up @@ -99,6 +101,7 @@
}

function startTheGame() {
musicSetting[0].innerHTML = "On";
score = 0;
foodAte = 0;
speed = 70;
Expand Down Expand Up @@ -364,6 +367,7 @@

window.pauseGame = function() {
clearInterval(loopGame);
run.pause();
startButton[0].style.display = "none";
resumeButton[0].style.display = "inline-block";
pauseButton[0].style.display = "none";
Expand Down Expand Up @@ -413,4 +417,20 @@
window.mobileDown = function() {
direction = "down";
};

window.muteGame = function() {
if(muted) {
musicSetting[0].innerHTML = "On";
muted = false;
run.muted = false;
die.muted = false;
eat.muted = false;
} else {
musicSetting[0].innerHTML = "Off";
muted = true;
run.muted = true;
die.muted = true;
eat.muted = true;
}
};
})();

0 comments on commit 035ae87

Please sign in to comment.