Created
June 22, 2021 12:59
-
-
Save stephanbogner/ba9da77e9b9620ef9771d4bf77ef296b to your computer and use it in GitHub Desktop.
Script to make a flickering with increasing frequency (think tak ...... tak .... tak ... tak .. tak . takkkkk ). Useful for when a timing is ending. I used this algorithm in combination with a shader for our GMTK Game Jam 2021 Game "Cursed Leash" (https://st-phan.itch.io/cursed-leash)
This file contains hidden or 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
<script> | |
let counter = 0; | |
setInterval(function(){ | |
counter += 0.03/8; | |
counter = Math.min(1, counter); | |
var y = Math.sin(counter * counter * counter * 80); | |
var bool = true; | |
if (y < 0) { | |
document.body.style.background = "grey"; | |
bool = false; | |
}else{ | |
document.body.style.background = "white"; | |
} | |
console.log(counter, y); | |
}, 30) | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment