Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Sphere rotation program
- -- main.lua first
- -- Use this function to perform your initial setup
- function setup()
- -- displayMode(FULLSCREEN)
- ballX =3D 300
- ballY =3D 300
- diameter =3D 200
- rot =3D 0
- watch("x")
- watch("y")
- parameter("rot",0,90)
- end
- -- This function gets called once every frame
- function draw()
- -- This sets a dark background color
- background(86, 37, 90, 255)
- strokeWidth(5)
- stroke(186, 218, 20, 255)
- Sphere:draw(ballX,ballY,ballZ,diameter)
- end
- -- Sphere.lua to follow
- Sphere =3D class()
- function Sphere:init()
- -- you can accept and set parameters here
- self.x =3D x
- self.y =3D y
- self.z =3D z
- self.diameter =3D 50
- end
- function Sphere:draw(x,y,diameter,diameter)
- -- Codea does not automatically call this method
- pushStyle()
- pushMatrix()
- fill(48, 181, 200, 255)
- stroke(7, 8, 7, 255)
- strokeWidth(1)
- ellipseMode(CENTER)
- ellipse(x,y,diameter,diameter)
- noFill()
- diff =3D diameter/10
- rotate(rot)
- for loop =3D 1, 9 do
- angle =3D loop*diff
- ellipse(x,y,diameter,angle)
- ellipse(x,y,angle,diameter)
- end
- popMatrix()
- popStyle()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement