diff --git a/bird.js b/bird.js index c24d204..1bf589f 100644 --- a/bird.js +++ b/bird.js @@ -9,13 +9,15 @@ const setTop = ( top ) => birdElem.style.setProperty( "--bird-top", top ) const getTop = () => parseFloat( getComputedStyle( birdElem ).getPropertyValue( "--bird-top" ) ) const handleJump = ( event ) => { - if ( event.code === "Space" ) timeSinceLastJump = 0 + if ( event.code === "Space" || event.type == "click") timeSinceLastJump = 0 } export const setupBird = () => { setTop( window.innerHeight / 2 ) document.removeEventListener( "keydown", handleJump ) document.addEventListener( "keydown", handleJump ) + document.removeEventListener( "click", handleJump ) + document.addEventListener( "click", handleJump ) } export const updateBird = ( delta ) => { diff --git a/images/background.png b/images/background.png index 4c6ff94..b871b85 100644 Binary files a/images/background.png and b/images/background.png differ diff --git a/index.html b/index.html index 2717bb0..da5ec06 100644 --- a/index.html +++ b/index.html @@ -12,10 +12,10 @@

- Press Any Key To Start + Press Any Key or Click To Start

- + \ No newline at end of file diff --git a/script.js b/script.js index 7653aec..6126dc0 100644 --- a/script.js +++ b/script.js @@ -48,8 +48,10 @@ const handleLose = () => setTimeout( () => { } subtitle.innerHTML = `Score: ${score}
Highscore: ${highscore}` - document.addEventListener( "keydown", handleStart, { once: true } ) + document.addEventListener( "keypress", handleStart, { once: true } ) + document.addEventListener( "click", handleStart, { once: true } ) }, 100 ) subtitle.innerHTML = `Highscore: ${parseFloat(localStorage.getItem('highscore')) || 0}` -document.addEventListener( "keypress", handleStart, { once: true } ) \ No newline at end of file +document.addEventListener( "keypress", handleStart, { once: true } ) +document.addEventListener( "click", handleStart, { once: true } ) \ No newline at end of file diff --git a/styles.css b/styles.css index 45f03ff..9565362 100644 --- a/styles.css +++ b/styles.css @@ -3,12 +3,10 @@ *::before { box-sizing: border-box; } - body { margin: 0; background-image: url(images/background.png); background-size: cover; - width: 100vw; height: 100vh; font-family: "Lato", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", @@ -41,6 +39,7 @@ body { .bird { --bird-top: -1000; --bird-size: 60px; + user-select: none; position: absolute; width: var(--bird-size); left: var(--bird-size);