Advertisement
Guest User

Untitled

a guest
Apr 18th, 2021
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.13 KB | None | 0 0
  1. function love.load()
  2. windowwidth = 1000
  3. windowheight = 1000
  4. sucess = love.window.setMode(windowwidth, windowheight)
  5. x = 30
  6. y = 50
  7. z = math.sin(math.pi/3)
  8. cx = 0
  9. cy = 0
  10. end
  11.  
  12. function love.update(dt) -- added dt as a parameter ... is dt 1/framerate?
  13. cx = cx + dt
  14. cy = cy + dt
  15. end
  16.  
  17. function love.draw() -- render to window
  18. love.graphics.setColor(200/255, 215/255, 0/255)
  19.  
  20. love.graphics.setColor(145/255, 12/255, 230/255)
  21. love.graphics.rectangle("line", x, y, 100, 100)
  22. love.graphics.setColor(0/255, 12/255, 230/255)
  23. love.graphics.print("the sin of 60 is: " .. z, 100, 300)
  24. love.graphics.setColor(0/255, 200/255, 230/255)
  25. love.graphics.print("here is a line: ", 100, 400)
  26. love.graphics.setColor(0/255, 200/255, 100/255)
  27. love.graphics.line(100,400, math.cos(100*math.pi/3) + 200, math.sin(100*math.pi/3) + 200)
  28. for theta = 0, 2*math.pi, delthe do -- you must specify the incrementation or it will assumed to be 1
  29.  
  30. r = 100
  31. a = 1 -- amplitude of the waves
  32. b = 2
  33.  
  34. love.graphics.setColor(200/255, 0/255, 100/255)
  35.  
  36. 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)
  37. end
  38.  
  39. for theta = 0, 2*math.pi, delthe do
  40. r = 2*math.cos(2*theta)
  41. a = 100
  42. b = 2
  43.  
  44. love.graphics.setColor(100/255, 0/255, 200/255)
  45. 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)
  46. end
  47.  
  48. for theta = 0, 2*math.pi, delthe do
  49. r = 2*math.sin(3*theta)
  50. a = 100
  51. b = 2
  52.  
  53. love.graphics.setColor(2/255, 200/255, 50/255)
  54. 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)
  55. end
  56.  
  57. for theta = 0, 2*math.pi, delthe do
  58. r = math.sin(1/3*theta)
  59. a = 100
  60. b = 2
  61.  
  62. love.graphics.setColor(2/255, 200/255, 155/255)
  63. 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)
  64. end
  65. -- 8 leaves
  66. for theta = 0, 2*math.pi, delthe do
  67. r = math.sin(4*theta)
  68. a = 100
  69. b = 2
  70. --delthe = math.pi/60 -- 3 degrees
  71. love.graphics.setColor(230/255, 0/255, 50/255)
  72. 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)
  73. end
  74.  
  75. love.graphics.print("x: " .. cx .. "y: " .. cy, cx, cy)
  76. love.graphics.circle("fill", cx, cy, 2)
  77. end
  78.  
  79. function love.keypressed(key)
  80. if key == "space" then
  81. x = math.random(100, 500)
  82. y = math.random(100, 500)
  83. end
  84. end
  85.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement