Guest User

Untitled

a guest
Sep 8th, 2015
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. local cube = dofile("include/cube.lua")
  2. local d=0
  3. return function (page, offset, screen_width, screen_height)
  4. local percent = math.abs(offset/page.width)
  5.  
  6. if percent < 0.02 then
  7. d = math.random(1, 4)
  8. end
  9. local sign = 0
  10. if offset > 0 then sign=1 end
  11. if offset <=0 then sign=-1 end
  12. offset = math.abs(offset)
  13. offset = (offset - (0.02 * page.width)) * 100/98
  14. if offset <0 then offset=0 end
  15. offset = sign * offset
  16. local x, z, angle = cube(page, offset, false, d)
  17.  
  18. local threshold = math.abs(math.atan((PERSPECTIVE_DISTANCE - z)/x))
  19. angle = math.abs(angle)
  20.  
  21. if angle > threshold then
  22. page.alpha = 1 - (angle - threshold)/(math.pi/2 - threshold)
  23. else
  24. page.alpha = 1
  25. end
  26. if percent > 0.98 then
  27. page.alpha = 0
  28. end
  29. end
Advertisement
Add Comment
Please, Sign In to add comment