Coffeescript Game Tutorial Libary an Interlude 2014-07-28 ProgrammingCoffeeScript CoffeeScript, Game, Programming 지금까지 했던걸 라이브러리 형태로 정리한 코드이다. 1234567891011121314151617181920212223242526272829303132333435363738394041424344# BEGIN LIBRARY CODEx = 150y = 150dx = 2dy = 4WIDTH = 0HEIGHT = 0ctx = nullinit = ->canvas = document.getElementById("myCanvas")ctx = canvas.getContext("2d")WIDTH = canvas.widthHEIGHT = canvas.heightintervalId = setInterval(draw, 10)circle = (x, y, r) ->ctx.beginPath()ctx.arc(x, y, r, 0, Math.PI*2, true)ctx.closePath()ctx.fill()rect = (x, y, w, h) ->ctx.beginPath()ctx.rect(x, y, w, h)ctx.closePath()ctx.fill()clear = ->ctx.clearRect(0, 0, WIDTH, HEIGHT)# END LIBRARY CODEdraw = ->clear()circle(x, y, 10)x += dx;y += dy;window.onload = ->init() Reference Newer Coffeescript Game Tutorial Action Older Coffeescript Game Tutorial Bounce