Skip to content

Instantly share code, notes, and snippets.

@evelynriossf
Last active December 26, 2015 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evelynriossf/7199674 to your computer and use it in GitHub Desktop.
Save evelynriossf/7199674 to your computer and use it in GitHub Desktop.
KittyCat
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Cat Walk</title>
</head>
<body>
<img id="kittyCat"; style="position:absolute;" src="http://www.anniemation.com/clip_art/images/cat-walk.gif">
</body>
</html>
<script>
var kittyCat = document.getElementById('kittyCat');
kittyCat.style.left = "0px";
function catWalk () {
var oldLocation = parseInt(kittyCat.style.left);
var newLocation = oldLocation + 10;
kittyCat.style.left = newLocation + 'px';
if (parseInt(kittyCat.style.left) > window.innerWidth - 30){
kittyCat.style.left = "0px";
}
}
window.setInterval(catWalk, 50);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment