Created
June 16, 2012 05:23
-
-
Save yusugomori/2940062 to your computer and use it in GitHub Desktop.
Danboard.coffee
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
class Danboard | |
constructor: (id) -> | |
$danboard = $(id) | |
baseRotateX = 60 | |
baseRotateY = 150 | |
baseRotateZ = -20 | |
$(window).keydown (e) => | |
if e.which is 37 # KEYLEFT | |
e.preventDefault() | |
baseRotateY -= 1 | |
$danboard.css | |
WebkitTransform: "rotateX(#{baseRotateX}deg) rotateY(#{baseRotateY}deg) rotateZ(#{baseRotateZ}deg)" | |
else if e.which is 39 # KEYRIGHT | |
e.preventDefault() | |
baseRotateY += 1 | |
$danboard.css | |
WebkitTransform: "rotateX(#{baseRotateX}deg) rotateY(#{baseRotateY}deg) rotateZ(#{baseRotateZ}deg)" | |
else if e.which is 38 # KEYUP | |
e.preventDefault() | |
baseRotateX += 1 | |
$danboard.css | |
WebkitTransform: "rotateX(#{baseRotateX}deg) rotateY(#{baseRotateY}deg) rotateZ(#{baseRotateZ}deg)" | |
else if e.which is 40 # KEYDOWN | |
e.preventDefault() | |
baseRotateX -= 1 | |
$danboard.css | |
WebkitTransform: "rotateX(#{baseRotateX}deg) rotateY(#{baseRotateY}deg) rotateZ(#{baseRotateZ}deg)" | |
$ -> | |
if document.getElementById('danboard')? | |
danboard = new Danboard('#danboard') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment