Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Playable on device with no keyboard #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions game.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@ var userClickedPattern = [];
var started = false;
var level = 0;

$(document).keypress(function() {
if (!started) {
$("#level-title").text("Level " + level);
nextSequence();
started = true;
const handleStart = (event) => {
if(!started){
$('#level-title').text('Level ' + level )
$('.click-start-btn').addClass('display-none')
$('label').addClass('display-none')
nextSequence()
started = true

}
});
}

$(document).on('keydown', handleStart)
$('.click-start-btn').on('click', handleStart)

$(".btn").click(function() {

Expand All @@ -36,9 +42,14 @@ function checkAnswer(currentLevel) {
}
} else {
playSound("wrong");

$("body").addClass("game-over");
$("#level-title").text("Game Over, Press Any Key to Restart");


$('.click-start-btn').removeClass('display-none')
$('label').removeClass('display-none')

setTimeout(function () {
$("body").removeClass("game-over");
}, 200);
Expand Down
6 changes: 6 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@

<body>
<h1 id="level-title">Press A Key to Start</h1>

<div>
<button class="click-start-btn">Start</button>
</div>
<label >(For devices with no keyboard)</label>

<div class="container">
<div lass="row">

Expand Down
24 changes: 24 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,27 @@ body {
box-shadow: 0 0 20px white;
background-color: grey;
}

body label {
color: yellow;
font-family: 'Press Start 2P', cursive;
}

.click-start-btn {
display: inline;
width: 100px;
background-color: blue;
color: whitesmoke;
font-weight: bold;
border-radius: 12px ;
font-family: 'Press Start 2P', cursive;
padding: 10px;
margin-bottom: 5px;
}
.click-start-btn:hover {
border: 3px solid yellow;
}

.display-none {
display: none;
}