Advertisement
joseleeph

Untitled

May 15th, 2021
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1.  
  2. function love.load()
  3. --Object = require "classic"
  4. require "cjrcle"
  5. windowwidth = 1000
  6. windowheight = 1000
  7. love.graphics.setBackgroundColor(1, 1, 1)
  8. sucess = love.window.setMode(windowwidth, windowheight)
  9.  
  10. ctheta = math.pi/2
  11. x = 0
  12. y = 0
  13.  
  14. startposX = -500
  15. discr = 50
  16. hr = 10
  17.  
  18. speed = 1
  19.  
  20. -- hammer position
  21. hxpos = startposX + discr*math.cos(math.pi/2)
  22. hypos = y - discr*math.sin(math.pi/2)
  23. rv = 1 -- rotational velocity
  24. end
  25.  
  26. function love.update(dt)
  27.  
  28. ctheta = ctheta - rv*math.pi/4*dt
  29. if speed < 10 then
  30. --speed = speed*1.01
  31. startposX = startposX + speed
  32. end
  33.  
  34.  
  35. hxpos = startposX + discr*math.cos(ctheta)
  36. hypos = y - discr*math.sin(ctheta)
  37. if startposX > 0 then
  38. startposX = 0
  39. end
  40. if rv < 12 then
  41. rv = rv*1.01 -- the rotational velocity is always being updated at every frame
  42. end
  43. end
  44. --[[
  45. equation of tangent line y = -x + 50*math.sqrt(2)
  46. ]]
  47.  
  48. function love.keypressed(key)
  49. if key == "space" and startposX < 0 then
  50. speed = 0
  51. hxpos = hxpos + 1/math.cos(ctheta) -- trying to make the hammer x position the secant of ctheta
  52. hypos = hypos + 1/math.sin(ctheta) -- trying to make the hammer y position the cosecant of ctheta
  53. -- really i'm just trying to draw a tangent vector to the circle
  54. end
  55. end
  56.  
  57. function love.draw()
  58. --love.graphics.push()
  59. love.graphics.translate(windowwidth/2, windowheight/2)
  60.  
  61.  
  62. -- green circle
  63. love.graphics.setColor(0, 1, 0)
  64. cjrcle(discr, startposX, 0, 32)
  65.  
  66. --blue circle
  67. love.graphics.setColor(0, 0, 1) -- blue paint
  68.  
  69. cjrcle(10, hxpos, hypos, 16)
  70.  
  71. love.graphics.setColor(0, 0, 0) -- black
  72. love.graphics.setLineWidth(.5)
  73. love.graphics.line(50*math.sqrt(2), 0, 0, -50*math.sqrt(2))
  74. love.graphics.setColor(1,0,0) -- red
  75. love.graphics.setLineWidth(.3)
  76. love.graphics.line(50*math.tan(math.pi/4), 0, 0, -50*math.tan(math.pi/4)) -- tan π/4 = 1
  77.  
  78. love.graphics.line(0, 25*math.sqrt(3) + math.sqrt(1875)/3, 0, 25*math.sqrt(3) + math.sqrt(1875)/3)
  79.  
  80. end
  81.  
  82.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement