joseleeph

Untitled

Apr 16th, 2021 (edited)
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1.  
  2. function love.load() -- do global variables get declared here?
  3. windowwidth = 1000
  4. windowheight = 1000
  5. sucess = love.window.setMode(windowwidth, windowheight)
  6. x = 30
  7. y = 50
  8. z = math.sin(math.pi/3)
  9. cx = 0
  10. cy = 0
  11. a = 20
  12. b = 1/4
  13. ps = 0
  14. end
  15.  
  16. function love.update(dt)
  17.  
  18.  
  19. local m = math.pow(2, dt)
  20. if love.keyboard.isDown("up") then
  21. a = a*m
  22. end
  23. if love.keyboard.isDown("down") then
  24. a = a/m
  25. end
  26. if love.keyboard.isDown("right") then
  27. b = b*m
  28. end
  29. if love.keyboard.isDown("left") then
  30. b = b/m
  31. end
  32. if love.keyboard.isDown("a") then
  33. ps = ps - 1
  34. end
  35. if love.keyboard.isDown("s") then
  36. ps = ps + 1
  37. end
  38.  
  39. end
  40.  
  41.  
  42.  
  43.  
  44. function love.draw() -- render to window
  45. -- y = asin(bx + c)
  46. love.graphics.setColor(200/255, 215/255, 0/255)
  47. delthe = math.pi/60 -- 3 degrees
  48. --a = 20
  49. x = 0
  50. p = 1
  51. odeg = math.pi/180
  52.  
  53. for theta = -32*math.pi, 32*math.pi, odeg do
  54. love.graphics.line(x + ps, a*math.sin(b*(theta + ps))+windowwidth/2, x+odeg + ps, a*math.sin(b*theta+odeg + ps + 0.1)+windowwidth/2)
  55. -- phaseshift = 3 for an interesting pattern
  56. -- love.graphics.line(x, a*math.sin(theta/ps)+windowwidth/2, x+odeg, a*math.sin(theta/ps+odeg)+windowwidth/2)
  57. x = x + 0.1
  58. --ps = ps + 0.1
  59. end
  60.  
  61. end
  62.  
Add Comment
Please, Sign In to add comment