Skip to content

Instantly share code, notes, and snippets.

@rsofaer
Created January 31, 2014 01:44
Show Gist options
  • Save rsofaer/8725179 to your computer and use it in GitHub Desktop.
Save rsofaer/8725179 to your computer and use it in GitHub Desktop.
<html>
<head>
<script>
var flip = function(ele){
ele.classList.toggle('flipped');
}
var move = 10;
var moveBoss = function(){
ele = document.querySelector('#boss');
if(ele.width + ele.offsetLeft >= (window.innerWidth + 200) ||
ele.offsetLeft < -200){
move = move * -1;
flip(ele);
}
ele.style.left = (ele.offsetLeft + move) + "px";
//ele.style.height= Math.max(150,Math.sin((ele.offsetLeft/(window.innerWidth + 200))*Math.PI)*480);
};
setInterval(moveBoss, 100);
</script>
<style>
#boss{
position: absolute;
}
.flipped{
-webkit-transform: scaleX(-1);
transform: scaleX(-1);
}
</style>
</head>
<body>
<img id="boss" src="https://a248.e.akamai.net/camo.github.com/56a9cd8b7e9ebbdcc75dc7baf56986a08650f50d/687474703a2f2f74686573656172657468696e67732e636f6d2f776f726b2f686174657273676f6e6e61686174652f696d672f686174657273676f6e6e61686174652d30312e676966">
</body>
</html>
@maxwell
Copy link

maxwell commented Jan 31, 2014

great job i give it an a+++-

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment