Coffeescript Game Tutorial the Mouse 2014-08-01 ProgrammingCoffeeScript CoffeeScript, Game, Programming 마우스 이벤트 처리 코드를 추가하였다. 1234567891011121314151617181920212223242526272829303132init_mouse = ->canvasMinX = 0canvasMaxX = canvasMinX + WIDTHdocument.onmousemove = (evt) ->if evt.pageX > canvasMinX and evt.pageX < canvasMaxXpaddlex = evt.pageX - canvasMinXdraw = ->clear()circle(x, y, 10)# move the paddle if left or right is currently pressedpaddlex += 5 if rightDownpaddlex -= 5 if leftDownrect(paddlex, HEIGHT-paddleh, paddlew, paddleh)dx = -dx if x + dx > WIDTH or x + dx < 0if y + dy < 0 then dy = -dyelse if y + dy > HEIGHTif x > paddlex and x < paddlex + paddlewdy = -dyelse# game over, so stop the animationclearInterval(intervalId)x += dx;y += dy;window.onload = ->init()init_mouse() Reference Newer Coffeescript Game Tutorial the Keyboard Older 피보나치 수열