-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Chayapatr Archiwaranguprok
committed
Oct 9, 2019
1 parent
b9e3986
commit 2620fbb
Showing
4 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "Press F for no reason", | ||
"description": "just press F (or r for reset on keyboard)", | ||
"author": "Chayapatr Archiwaranguprok", | ||
"facebook": "https://www.facebook.com/chayapatr" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
const init = () => { | ||
window.counter = 0 | ||
window.time = 60.00 | ||
window.start = false | ||
window.highScore = +window.localStorage.getItem('highscore') || 0 | ||
window.buttonMode = "start" | ||
document.querySelector("#timer").innerHTML = `time : 60` | ||
document.querySelector("#counter").innerHTML = `F pressed : ${window.counter}` | ||
document.querySelector("#fps").innerHTML = "F per sec : 0.000" | ||
document.querySelector("#hs").innerHTML = `highscore : ${window.highScore}` | ||
} | ||
const reset = () => { | ||
init() | ||
clearTimeout(window.guide) | ||
clearInterval(window.countdown) | ||
clearInterval(window.persec) | ||
document.querySelector("#msg").style.display = "none" | ||
} | ||
const start = () => { | ||
window.start = true | ||
window.countdown = setInterval(() => { | ||
window.time -= 0.01 | ||
document.querySelector("#timer").innerHTML = `time : ${window.time.toFixed(3)}` | ||
if (window.time <= 0) { | ||
window.start = false | ||
clearInterval(window.countdown) | ||
clearInterval(window.persec) | ||
document.querySelector("#timer").innerHTML = "times up" | ||
window.guide = setTimeout(() => { | ||
document.querySelector("#msg").style.display = "inline" | ||
}, 3000) | ||
if(window.counter > window.highScore) window.localStorage.setItem('highscore', window.counter); | ||
} | ||
if (isFinite(window.counter / (60 - window.time).toFixed(3))) | ||
document.querySelector("#fps").innerHTML = | ||
`F per sec : ${(window.counter/(60-window.time)).toFixed(3)}` | ||
}, 10) | ||
} | ||
document.addEventListener('keydown', e => { | ||
if (e.key.toLowerCase() === "f") window.start ? document.querySelector("#counter").innerHTML = `F pressed : ${++window.window.counter}` : start() | ||
if (e.key.toLowerCase() === "r" && window.start) reset() | ||
}) | ||
document.querySelector("#img").addEventListener("mousedown", () => { | ||
window.start ? document.querySelector("#counter").innerHTML = `F pressed : ${++window.window.counter}` : start() | ||
window.resetTimer = setTimeout(reset, 1500) | ||
console.log("down") | ||
}) | ||
document.body.addEventListener("mouseup", () => {if (window.resetTimer) clearTimeout(window.resetTimer)}) | ||
init() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
body { | ||
overflow: hidden; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: space-around; | ||
width: 100%; | ||
height: 100vh; | ||
margin: 0; | ||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif | ||
} | ||
#msg{ display: none; } | ||
#head-wrapper { | ||
overflow: hidden; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
#text { margin-bottom: 0px; } | ||
#img-wrapper { | ||
height: 270px; | ||
width: 480px; | ||
position: relative; | ||
text-align: center; | ||
box-shadow: 10px 0px 15px -5px rgba(0, 0, 0, 0.75); | ||
} | ||
#img-wrapper:active { | ||
box-shadow: 10px 0px 15px -52px rgba(0, 0, 0, 0.75); | ||
transform: translate(2px, 2px); | ||
} | ||
#img-wrapper > h1 { | ||
position: absolute; | ||
top: 25%; | ||
left: 50%; | ||
color: white; | ||
font-size: 7rem; | ||
transform: translate(-50%, -50%); | ||
} | ||
#img { | ||
background-image: url(./f.gif); | ||
background-size: cover; | ||
} |