Skip to content

Instantly share code, notes, and snippets.

@hmans
Created January 13, 2012 16:56
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 hmans/1607503 to your computer and use it in GitHub Desktop.
Save hmans/1607503 to your computer and use it in GitHub Desktop.
canvas = null
context = null
x = 0
y = 250
r = 0.0
img = new Image()
img.src = '/images/serve-logo.png'
$ ->
setup()
gameLoop()
setup = ->
canvas = $('#thingy').get(0)
context = canvas.getContext('2d')
gameLoop = ->
update()
draw()
setTimeout gameLoop, 1000 / 25
update = ->
x = x + 1
r = r + 0.01
draw = ->
context.clearRect(0, 0, canvas.width, canvas.height)
context.translate(x, y)
context.rotate(r)
context.drawImage(img, -img.width/2, -img.height/2, img.width, img.height)
context.rotate(-r)
context.translate(-x, -y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment