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 pfp
|
||||||
|
|
||||||
var music = new Audio("/snds/Lotus Waters.ogg")
|
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.loop = true
|
||||||
music.playbackRate = 0
|
music.volume = 0.45
|
||||||
// var whipLash = new Audio("/snds/johnny-test-whip-crack.mp3")
|
whipLash.volume = 0.25
|
||||||
// whipLash.volume = 0.25
|
|
||||||
|
|
||||||
var sock
|
var sock
|
||||||
|
|
||||||
var spins = 0
|
var spins = 1
|
||||||
var lastSent = 0
|
|
||||||
var globalSpins = 0
|
var globalSpins = 0
|
||||||
|
|
||||||
var spinning = false
|
|
||||||
|
|
||||||
var firsttimeDebounce = true
|
var firsttimeDebounce = true
|
||||||
|
|
||||||
var spinWaiting = false
|
var spinWaiting = false
|
||||||
|
@ -44,36 +38,24 @@ function resetPFP() {
|
||||||
pfp.src = "https://api.violets-purgatory.dev/v1/pfp?" + new Date().getTime()
|
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() {
|
function spinLoop() {
|
||||||
spinWaiting = true
|
spinWaiting = true
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
spinWaiting = false
|
spinWaiting = false
|
||||||
if (spinning) {
|
if (!music.paused) {
|
||||||
music.volume = 0.5
|
|
||||||
music.playbackRate = lerp(music.playbackRate, 1, 1/spinSpeed)
|
|
||||||
if (spins > 1) {
|
if (spins > 1) {
|
||||||
document.querySelector(".spinnyCount").style.display = "block"
|
document.querySelector(".spinnyCount").style.display = "block"
|
||||||
document.querySelector(".localSpins").innerHTML = Math.ceil(spins - 1);
|
document.querySelector(".localSpins").innerHTML = Math.ceil(spins - 1);
|
||||||
}
|
}
|
||||||
spins += 1/spinSpeed / 3
|
spins += 0.5
|
||||||
document.querySelector(".pfp").style.rotate = (spins * 360) + "deg"
|
if (Math.round(spins) == spins && sock && sock.OPEN) {
|
||||||
if (Math.floor(spins) != lastSent && sock && sock.OPEN) {
|
|
||||||
document.querySelector(".globalSpins").innerHTML = globalSpins + 1
|
|
||||||
lastSent = Math.floor(spins)
|
|
||||||
// resetPFP()
|
// resetPFP()
|
||||||
sock.send(`{"op": 4}`)
|
sock.send(`{"op": 4}`)
|
||||||
console.log("Spin Sent!")
|
console.log("Spin Sent!")
|
||||||
}
|
}
|
||||||
} else {
|
spinLoop()
|
||||||
music.playbackRate = lerp(music.playbackRate, 0.5, 1/spinSpeed)
|
|
||||||
music.volume = lerp(music.volume, 0, 1/spinSpeed * 4)
|
|
||||||
}
|
}
|
||||||
spinLoop()
|
}, 1500);
|
||||||
}, 1/spinSpeed * 1000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onbeforeunload = function () {
|
window.onbeforeunload = function () {
|
||||||
|
@ -85,33 +67,26 @@ window.onload = function () {
|
||||||
|
|
||||||
pfp = document.querySelector(".pfp")
|
pfp = document.querySelector(".pfp")
|
||||||
|
|
||||||
spinLoop()
|
|
||||||
|
|
||||||
pfp.addEventListener("mousedown", () => {
|
pfp.addEventListener("mousedown", () => {
|
||||||
// if (!spinWaiting) {
|
if (!spinWaiting) {
|
||||||
// spinLoop();
|
spinLoop();
|
||||||
// }
|
}
|
||||||
music.play()
|
music.play()
|
||||||
|
|
||||||
spinning = true
|
pfp.style.animationName = "spinny"
|
||||||
|
|
||||||
pfp.style.transition = ""
|
|
||||||
|
|
||||||
pfp.style.scale = "1.1"
|
pfp.style.scale = "1.1"
|
||||||
})
|
})
|
||||||
|
|
||||||
document.body.onmouseup = () => {
|
document.body.onmouseup = () => {
|
||||||
if (music.currentTime != 0) {
|
if (music.currentTime != 0) {
|
||||||
// music.currentTime = 0
|
music.currentTime = 0
|
||||||
// music.pause()
|
music.pause()
|
||||||
|
|
||||||
// whipLash.currentTime = 0
|
whipLash.currentTime = 0
|
||||||
// whipLash.play()
|
whipLash.play()
|
||||||
|
|
||||||
spinning = false
|
|
||||||
|
|
||||||
pfp.style.transition = "all 3s cubic-bezier(0.39, 0.575, 0.565, 1)"
|
|
||||||
|
|
||||||
|
pfp.style.animationName = "unset"
|
||||||
pfp.style.scale = "1"
|
pfp.style.scale = "1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue