Changes

Jump to navigation Jump to search

Balls Example

18 bytes added, 04:24, 27 August 2013
just a tad better
Line 4: Line 4:       −
<syntaxhighlight>Ball = class()
+
<syntaxhighlight>ballsTable = {}
 +
isGrabbing = false
 +
txt2 = "not moving anything"
 +
 
 +
 
 +
Ball = class()
    
function Ball:init(x,y,r,color)
 
function Ball:init(x,y,r,color)
Line 19: Line 24:  
  gc:fillArc(self.x,self.y,self.r,self.r,0,360)
 
  gc:fillArc(self.x,self.y,self.r,self.r,0,360)
 
  if self.isActive then
 
  if self.isActive then
     gc:setColorRGB(0)  
+
     gc:setColorRGB(0,0,0)  
 
     gc:drawArc(self.x,self.y,self.r,self.r,0,360)
 
     gc:drawArc(self.x,self.y,self.r,self.r,0,360)
 
  end
 
  end
Line 73: Line 78:  
  gc:drawString("Press Enter to create a Ball object", 2, 190, "top")
 
  gc:drawString("Press Enter to create a Ball object", 2, 190, "top")
 
end
 
end
  −
ballsTable = {}
  −
grabFlag = false
  −
isGrabbing = false
  −
txt2 = "not moving anything"
      
function on.enterKey()
 
function on.enterKey()
 
  ballsTable[#ballsTable+1] = Ball(math.random(10,250), math.random(10,180), 15, {math.random(0,255),math.random(0,255),math.random(0,255)})
 
  ballsTable[#ballsTable+1] = Ball(math.random(10,250), math.random(10,180), 15, {math.random(0,255),math.random(0,255),math.random(0,255)})
 +
platform.window:invalidate()
 
end</syntaxhighlight>
 
end</syntaxhighlight>

Navigation menu