Advertisement
joseleeph

Untitled

Apr 15th, 2021
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. function love.load() -- do global variables get declared here?
  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. function love.update(dt) -- added dt as a parameter ... is dt 1/framerate?
  12.  
  13. if love.keyboard.isDown("up") then
  14. a = a*2
  15. end
  16. if love.keyboard.isDown("down") then
  17. a = a/2
  18. end
  19. if love.keyboard.isDown("left") then
  20. b = b*2
  21. end
  22. if love.keyboard.isDown("right") then
  23. b = b/2
  24. end
  25.  
  26. end
  27. function love.draw() -- render to window
  28. -- y = asin(bx + c)
  29. love.graphics.setColor(200/255, 215/255, 0/255)
  30. delthe = math.pi/60 -- 3 degrees
  31. a = 20
  32. x = 0
  33. p = 1
  34. b = 3
  35. ps = 4 -- phase shift of 4
  36. odeg = math.pi/180
  37. for theta = -32*math.pi, 32*math.pi, odeg do
  38.  
  39. love.graphics.line(x, a*math.sin(b*(theta))+windowwidth/2, x+odeg, a*math.sin(b*theta+odeg)+windowwidth/2)
  40. -- phaseshift = 3 for an interesting pattern
  41. -- love.graphics.line(x, a*math.sin(theta/ps)+windowwidth/2, x+odeg, a*math.sin(theta/ps+odeg)+windowwidth/2)
  42.  
  43.  
  44. x = x + 0.1
  45. end
  46. love.update()
  47. end
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement