Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function love.load()
- windowwidth = 1000
- windowheight = 1000
- sucess = love.window.setMode(windowwidth, windowheight)
- x = 30
- y = 50
- z = math.sin(math.pi/3)
- cx = 0
- cy = 0
- end
- function love.update(dt) -- added dt as a parameter ... is dt 1/framerate?
- cx = cx + dt
- cy = cy + dt
- end
- function love.draw() -- render to window
- love.graphics.setColor(200/255, 215/255, 0/255)
- love.graphics.setColor(145/255, 12/255, 230/255)
- love.graphics.rectangle("line", x, y, 100, 100)
- love.graphics.setColor(0/255, 12/255, 230/255)
- love.graphics.print("the sin of 60 is: " .. z, 100, 300)
- love.graphics.setColor(0/255, 200/255, 230/255)
- love.graphics.print("here is a line: ", 100, 400)
- love.graphics.setColor(0/255, 200/255, 100/255)
- love.graphics.line(100,400, math.cos(100*math.pi/3) + 200, math.sin(100*math.pi/3) + 200)
- for theta = 0, 2*math.pi, delthe do -- you must specify the incrementation or it will assumed to be 1
- r = 100
- a = 1 -- amplitude of the waves
- b = 2
- love.graphics.setColor(200/255, 0/255, 100/255)
- love.graphics.line(r*math.cos(a*theta) + windowwidth/2, r*math.sin(a*theta) + windowwidth/2, r*math.cos(a*theta + a*delthe) + windowwidth/2, r*math.sin(a*theta + a*delthe) + windowwidth/2)
- end
- for theta = 0, 2*math.pi, delthe do
- r = 2*math.cos(2*theta)
- a = 100
- b = 2
- love.graphics.setColor(100/255, 0/255, 200/255)
- love.graphics.line(a*r*math.cos(theta) + windowwidth/2, a*r*math.sin(theta) + windowheight/2, a*r*math.cos(theta + delthe) + windowwidth/2, a*r*math.sin(theta+delthe) + windowheight/2)
- end
- for theta = 0, 2*math.pi, delthe do
- r = 2*math.sin(3*theta)
- a = 100
- b = 2
- love.graphics.setColor(2/255, 200/255, 50/255)
- love.graphics.line(a*r*math.cos(theta) + windowwidth/2, a*r*math.sin(theta) + windowheight/2, a*r*math.cos(theta + delthe) + windowwidth/2, a*r*math.sin(theta+delthe) + windowheight/2)
- end
- for theta = 0, 2*math.pi, delthe do
- r = math.sin(1/3*theta)
- a = 100
- b = 2
- love.graphics.setColor(2/255, 200/255, 155/255)
- love.graphics.line(a*r*math.cos(theta) + windowwidth/2, a*r*math.sin(theta) + windowheight/2, a*r*math.cos(theta + delthe) + windowwidth/2, a*r*math.sin(theta+delthe) + windowheight/2)
- end
- -- 8 leaves
- for theta = 0, 2*math.pi, delthe do
- r = math.sin(4*theta)
- a = 100
- b = 2
- --delthe = math.pi/60 -- 3 degrees
- love.graphics.setColor(230/255, 0/255, 50/255)
- love.graphics.line(a*r*math.cos(theta) + windowwidth/2, a*r*math.sin(theta) + windowheight/2, a*r*math.cos(theta + delthe) + windowwidth/2, a*r*math.sin(theta+delthe) + windowheight/2)
- end
- love.graphics.print("x: " .. cx .. "y: " .. cy, cx, cy)
- love.graphics.circle("fill", cx, cy, 2)
- end
- function love.keypressed(key)
- if key == "space" then
- x = math.random(100, 500)
- y = math.random(100, 500)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement