Skip to content

Instantly share code, notes, and snippets.

@tarolandia
Created March 7, 2012 11:11
Show Gist options
  • Save tarolandia/1992562 to your computer and use it in GitHub Desktop.
Save tarolandia/1992562 to your computer and use it in GitHub Desktop.
class Target
contruct: (center,radio,points) ->
@center = center
@radio = radio
@points = points
isHit: (hit) ->
getScore: (hit) ->
draw: () ->
class LeShoot
canvas: null #store canvas
startTarget: 2 #first level: 2 targets
boardSize: #board config
width: 600
height: 400
jailSize: #mouse jail size
width: 50
height: 50
targets: []
construct: (canvas,size) ->
if not canvas.canvas? or not canvas.nodeName is "CANVAS"
throw "Missing Canvas object or canvas DOM node"
@canvas = if canvas.nodeName? then canvas.getContext("2d") else canvas
if size.width
@boardSize.width = size.width
if size.height
@boardSize.height = size.height
@render()
this
render: () ->
@canvas.fillStyle = "rgb(200,0,0)"
@canvas.fillRect(10,10,55,50)
addTarget: (target) ->
@targets.push(target)
renderTargets: () ->
removeTargets: () ->
nextLevel: (num) ->
countDown: (max) ->
showField: () ->
hideField: () ->
draw = ->
canvas = document.getElementById('le-shoot')
try
game = new LeShoot(canvas,{width:600,height:400});
catch err
console.log(err.message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment