Coffeescript Game Tutorial Bounce 2014-07-29 ProgrammingCoffeScript CoffeScript, Game, Programming 공 튀기는 코드이다. 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647### BEGIN LIBRARY CODE ###x = 150y = 150dx = 2dy = 4ctx = nullWIDTH = 0HEIGHT = 0init = ->canvas = document.getElementById("myCanvas")ctx = canvas.getContext("2d")WIDTH = canvas.widthHEIGHT = canvas.heightsetInterval(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 CODE ###draw = ->clear()circle(x, y, 10)dx = -dx if x + dx > WIDTH or x + dx < 0dy = -dy if y + dy > HEIGHT or y + dy < 0x += dx;y += dy;window.onload = ->init() Reference Newer Coffeescript Game Tutorial Libary an Interlude Older Coffeescript Game Tutorial Add a Paddle