Skip to content

Instantly share code, notes, and snippets.

@yusugomori
Created June 16, 2012 05:23
Show Gist options
  • Save yusugomori/2940062 to your computer and use it in GitHub Desktop.
Save yusugomori/2940062 to your computer and use it in GitHub Desktop.
Danboard.coffee
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