Created
May 14, 2019 17:24
-
-
Save Yuffster/a48442f909aa85213d687fe74e8f8f22 to your computer and use it in GitHub Desktop.
This file contains 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
.sprite { | |
background: url('./zombies.png'); | |
--sprite-width: 32px; | |
--sprite-height: 48px; | |
--sprite-x: 0; | |
--sprite-y: 0; | |
--sheet-x: 0; | |
--sheet-y: 0; | |
--offset-x: calc((var(--sheet-x) * var(--sprite-width) * 3)); | |
--offset-y: calc((var(--sheet-y) * var(--sprite-height) * 4)); | |
background-position-x: calc((var(--sprite-x) * var(--sprite-width) + var(--offset-x)) * -1); | |
background-position-y: calc((var(--sprite-y) * var(--sprite-height) + var(--offset-y)) * -1); | |
display: block; | |
width: var(--sprite-width); | |
height: var(--sprite-height); | |
border: 1px solid var(--color); | |
animation: 1s sprite-walk infinite; | |
} | |
@keyframes sprite-walk { | |
0%,32% { | |
--sprite-x: 0; | |
} | |
33%,64% { | |
--sprite-x: 1; | |
} | |
65%,100% { | |
--sprite-x: 2; | |
} | |
} | |
.sprite.left { | |
--sprite-y: 1; | |
} | |
.sprite.right { | |
--sprite-y: 2; | |
} | |
.sprite.up { | |
--sprite-y: 3; | |
} | |
.sprite.foo { | |
--sheet-x: 1; | |
} | |
.sprite.bar { | |
--sheet-y: 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment