Compare commits
No commits in common. "aafd533803bd8ed0f9ee3be6160f40a1467389a1" and "9367dbd72be6a79f64835cf9b84086aaa19e65c3" have entirely different histories.
aafd533803
...
9367dbd72b
1 changed files with 18 additions and 43 deletions
|
@ -17,25 +17,19 @@ const discStatuses = {
|
|||
}
|
||||
}
|
||||
|
||||
const spinSpeed = 30
|
||||
|
||||
var pfp
|
||||
|
||||
var music = new Audio("/snds/Lotus Waters.ogg")
|
||||
music.preservesPitch = false
|
||||
var whipLash = new Audio("/snds/johnny-test-whip-crack.mp3")
|
||||
music.loop = true
|
||||
music.playbackRate = 0
|
||||
// var whipLash = new Audio("/snds/johnny-test-whip-crack.mp3")
|
||||
// whipLash.volume = 0.25
|
||||
music.volume = 0.45
|
||||
whipLash.volume = 0.25
|
||||
|
||||
var sock
|
||||
|
||||
var spins = 0
|
||||
var lastSent = 0
|
||||
var spins = 1
|
||||
var globalSpins = 0
|
||||
|
||||
var spinning = false
|
||||
|
||||
var firsttimeDebounce = true
|
||||
|
||||
var spinWaiting = false
|
||||
|
@ -44,36 +38,24 @@ function resetPFP() {
|
|||
pfp.src = "https://api.violets-purgatory.dev/v1/pfp?" + new Date().getTime()
|
||||
}
|
||||
|
||||
function lerp(a, b, t) {
|
||||
return a * (1 - t) + b * t
|
||||
}
|
||||
|
||||
function spinLoop() {
|
||||
spinWaiting = true
|
||||
setTimeout(() => {
|
||||
spinWaiting = false
|
||||
if (spinning) {
|
||||
music.volume = 0.5
|
||||
music.playbackRate = lerp(music.playbackRate, 1, 1/spinSpeed)
|
||||
if (!music.paused) {
|
||||
if (spins > 1) {
|
||||
document.querySelector(".spinnyCount").style.display = "block"
|
||||
document.querySelector(".localSpins").innerHTML = Math.ceil(spins - 1);
|
||||
}
|
||||
spins += 1/spinSpeed / 3
|
||||
document.querySelector(".pfp").style.rotate = (spins * 360) + "deg"
|
||||
if (Math.floor(spins) != lastSent && sock && sock.OPEN) {
|
||||
document.querySelector(".globalSpins").innerHTML = globalSpins + 1
|
||||
lastSent = Math.floor(spins)
|
||||
spins += 0.5
|
||||
if (Math.round(spins) == spins && sock && sock.OPEN) {
|
||||
// resetPFP()
|
||||
sock.send(`{"op": 4}`)
|
||||
console.log("Spin Sent!")
|
||||
}
|
||||
} else {
|
||||
music.playbackRate = lerp(music.playbackRate, 0.5, 1/spinSpeed)
|
||||
music.volume = lerp(music.volume, 0, 1/spinSpeed * 4)
|
||||
spinLoop()
|
||||
}
|
||||
spinLoop()
|
||||
}, 1/spinSpeed * 1000);
|
||||
}, 1500);
|
||||
}
|
||||
|
||||
window.onbeforeunload = function () {
|
||||
|
@ -85,33 +67,26 @@ window.onload = function () {
|
|||
|
||||
pfp = document.querySelector(".pfp")
|
||||
|
||||
spinLoop()
|
||||
|
||||
pfp.addEventListener("mousedown", () => {
|
||||
// if (!spinWaiting) {
|
||||
// spinLoop();
|
||||
// }
|
||||
if (!spinWaiting) {
|
||||
spinLoop();
|
||||
}
|
||||
music.play()
|
||||
|
||||
spinning = true
|
||||
|
||||
pfp.style.transition = ""
|
||||
pfp.style.animationName = "spinny"
|
||||
|
||||
pfp.style.scale = "1.1"
|
||||
})
|
||||
|
||||
document.body.onmouseup = () => {
|
||||
if (music.currentTime != 0) {
|
||||
// music.currentTime = 0
|
||||
// music.pause()
|
||||
music.currentTime = 0
|
||||
music.pause()
|
||||
|
||||
// whipLash.currentTime = 0
|
||||
// whipLash.play()
|
||||
|
||||
spinning = false
|
||||
|
||||
pfp.style.transition = "all 3s cubic-bezier(0.39, 0.575, 0.565, 1)"
|
||||
whipLash.currentTime = 0
|
||||
whipLash.play()
|
||||
|
||||
pfp.style.animationName = "unset"
|
||||
pfp.style.scale = "1"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue