Skip to content

Instantly share code, notes, and snippets.

@AjayMT
Created March 10, 2012 16:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AjayMT/2011951 to your computer and use it in GitHub Desktop.
Save AjayMT/2011951 to your computer and use it in GitHub Desktop.
Represents a ball in a pong clone created in lua(see 'Main.lua' & 'Player.lua')
Ball = class()
function Ball:init()
    self.pos=vec2(WIDTH/2,HEIGHT/2)
    self.acc=vec2(0,0)
end
function Ball:draw()
    fill(255, 0, 0, 255)
    self.pos = self.pos + self.acc
    ellipse(self.pos.x,self.pos.y,20)
end
function Ball:touched(touch)
    -- Codea does not automatically call this method
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment