Advertisement
joseleeph

Untitled

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