Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function love.load()
- --Object = require "classic"
- require "cjrcle"
- windowwidth = 1000
- windowheight = 1000
- love.graphics.setBackgroundColor(1, 1, 1)
- sucess = love.window.setMode(windowwidth, windowheight)
- ctheta = math.pi/2
- x = 0
- y = 0
- startposX = -500
- discr = 50
- hr = 10
- speed = 1
- -- hammer position
- hxpos = startposX + discr*math.cos(math.pi/2)
- hypos = y - discr*math.sin(math.pi/2)
- rv = 1 -- rotational velocity
- end
- function love.update(dt)
- ctheta = ctheta - rv*math.pi/4*dt
- if speed < 10 then
- --speed = speed*1.01
- startposX = startposX + speed
- end
- hxpos = startposX + discr*math.cos(ctheta)
- hypos = y - discr*math.sin(ctheta)
- if startposX > 0 then
- startposX = 0
- end
- if rv < 12 then
- rv = rv*1.01 -- the rotational velocity is always being updated at every frame
- end
- end
- --[[
- equation of tangent line y = -x + 50*math.sqrt(2)
- ]]
- function love.keypressed(key)
- if key == "space" and startposX < 0 then
- speed = 0
- hxpos = hxpos + 1/math.cos(ctheta) -- trying to make the hammer x position the secant of ctheta
- hypos = hypos + 1/math.sin(ctheta) -- trying to make the hammer y position the cosecant of ctheta
- -- really i'm just trying to draw a tangent vector to the circle
- end
- end
- function love.draw()
- --love.graphics.push()
- love.graphics.translate(windowwidth/2, windowheight/2)
- -- green circle
- love.graphics.setColor(0, 1, 0)
- cjrcle(discr, startposX, 0, 32)
- --blue circle
- love.graphics.setColor(0, 0, 1) -- blue paint
- cjrcle(10, hxpos, hypos, 16)
- love.graphics.setColor(0, 0, 0) -- black
- love.graphics.setLineWidth(.5)
- love.graphics.line(50*math.sqrt(2), 0, 0, -50*math.sqrt(2))
- love.graphics.setColor(1,0,0) -- red
- love.graphics.setLineWidth(.3)
- love.graphics.line(50*math.tan(math.pi/4), 0, 0, -50*math.tan(math.pi/4)) -- tan π/4 = 1
- love.graphics.line(0, 25*math.sqrt(3) + math.sqrt(1875)/3, 0, 25*math.sqrt(3) + math.sqrt(1875)/3)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement