Advertisement
Guest User

starry night script _2

a guest
Apr 2nd, 2017
420
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.99 KB | None | 0 0
  1. var colors = [12,13,12,13,12,13,11,12,12,11,12,11,12,13,12,12,12,11,12,11,12,13,13,13,12,12,12,13,12,12,12,13,13,13,12,13,12,13,12,13,12,13,12,13,12,13,12,13,12,13,12,13,12,13,12,13,12,12,12,13,12,12,11,11,13,12,12,12,13,13,13,12,13,13,13,12,13,12,13,12,13,12,12,11,12,9,12,12,9,12,11,12,13,12,11,0,9,0,11,12,13,
  2. 12,12,11,9,11,9,11,12,12,12,12,13,12,13,12,13,11,12,13,13,13,12,12,12,13,12,13,12,13,12,13,12,13,13,13,12,13,11,11,13,12,12,13,11,9,6,12,6,11,12,6,9,12,9,9,12,13,12,12,11,13,9,8,0,0,8,9,12,11,12,13,12,9,6,9,12,12,12,13,12,9,8,0,8,9,9,8,0,8,9,12,13,13,13,12,13,11,13,12,12,
  3. 11,9,11,11,9,11,12,12,12,13,12,13,13,13,12,12,12,13,11,11,13,6,11,12,12,12,12,11,12,9,9,12,12,13,12,12,12,12,11,12,0,6,6,0,12,12,12,12,12,3,11,12,11,12,13,12,13,12,9,8,0,8,9,12,0,6,0,12,13,11,11,12,13,11,13,13,12,13,9,8,0,0,8,9,13,12,13,12,13,12,13,12,12,12,11,13,12,12,9,6,
  4. 6,9,6,9,6,9,6,11,9,11,9,13,12,13,12,11,12,9,8,0,0,8,9,12,11,12,3,3,12,13,12,13,11,11,12,12,11,9,11,9,11,9,8,0,8,9,12,13,12,13,12,13,12,11,12,12,13,0,6,6,0,13,13,11,13,12,13,12,13,12,13,12,13,12,13,11,6,9,6,8,8,8,6,8,8,9,6,8,11,12,12,12,13,12,11,12,9,12,12,9,
  5. 12,11,13,12,3,3,13,12,12,12,13,12,12,12,13,12,13,12,13,11,9,12,9,11,13,13,13,12,13,12,13,11,13,12,9,8,0,0,8,9,12,12,12,13,12,13,12,13,12,13,11,13,11,6,8,6,6,8,6,6,6,6,6,8,9,6,11,13,13,13,12,13,12,11,12,11,12,12,11,13,12,12,3,3,12,12,12,13,13,13,11,11,12,13,13,12,13,12,13,12,
  6. 12,12,13,12,13,12,13,12,13,12,13,12,11,9,11,12,9,12,13,12,13,12,13,12,13,12,12,12,11,12,11,9,6,8,8,6,6,6,8,8,8,8,9,9,9,12,13,12,12,12,13,12,13,12,13,12,13,13,12,12,3,9,8,0,0,8,9,13,12,13,12,13,12,13,12,13,13,13,12,13,13,13,12,12,12,13,12,12,12,12,12,12,12,13,12,13,12,13,13,13,
  7. 13,12,13,12,12,11,12,9,11,2,8,8,6,6,6,8,8,8,8,8,6,8,9,11,11,12,13,12,13,12,12,12,12,12,12,12,13,12,3,12,0,6,6,0,12,12,13,12,12,12,13,12,12,12,13,12,12,12,12,12,12,12,12,12,12,12,12,12,12,11,11,12,13,12,12,13,12,12,13,12,12,10,13,10,12,10,9,6,8,6,6,6,6,8,8,8,8,8,9,6,
  8. 9,11,1,11,13,13,12,12,13,12,13,13,12,13,12,3,3,12,0,6,6,0,12,13,12,12,12,12,12,13,13,13,12,12,12,12,12,12,12,12,12,12,12,12,10,12,12,12,1,12,12,12,12,11,9,12,12,9,10,12,12,13,10,10,9,9,8,8,6,6,6,8,8,8,8,8,9,9,6,11,11,11,11,12,10,12,12,13,12,12,13,12,13,3,3,9,8,0,0,8,
  9. 9,12,13,12,12,13,12,12,12,13,13,12,11,11,12,12,1,1,1,11,12,11,12,12,12,12,12,10,12,12,12,9,8,0,0,8,9,10,12,12,12,10,12,10,8,8,8,6,6,6,8,8,8,6,8,8,9,11,11,1,11,11,12,12,12,13,12,13,13,12,13,13,3,12,12,12,13,13,12,12,13,12,13,12,12,12,12,1,1,1,11,1,1,1,11,1,11,1,11,1,
  10. 11,1,11,1,11,12,12,12,12,12,0,6,6,0,10,12,10,12,12,12,9,9,9,8,8,6,6,6,6,6,8,6,6,9,6,1,11,11,11,11,11,11,12,11,12,11,12,13,12,3,3,13,13,13,12,13,12,13,13,12,12,12,12,12,1,12,1,11,1,11,1,11,1,11,1,1,1,1,1,1,1,11,12,11,1,12,10,10,0,6,6,8,9,12,10,12,12,9,11,12,
  11. 9,9,6,6,8,8,8,8,6,6,9,6,11,11,1,1,11,1,11,11,9,9,11,11,12,12,13,3,3,9,12,12,13,13,13,12,12,12,12,12,12,1,1,6,11,6,6,1,1,1,11,1,11,12,1,12,1,12,1,12,1,12,12,12,12,10,9,10,12,9,12,9,10,10,10,10,9,11,12,6,9,6,8,6,6,6,8,9,6,11,12,1,12,12,12,6,12,1,1,11,
  12. 11,9,9,11,11,12,3,3,12,12,12,12,12,12,12,12,1,1,11,11,1,1,11,11,12,12,1,1,11,1,1,1,1,1,1,1,12,12,11,1,11,12,11,12,12,12,10,12,10,12,12,12,12,12,12,11,11,9,6,9,6,9,6,9,9,6,11,12,10,12,1,1,11,1,1,1,9,9,11,11,1,9,12,12,3,3,3,10,11,11,9,9,1,1,11,11,11,11,11,12,
  13. 1,0,11,11,12,9,12,11,1,12,1,12,1,12,12,12,11,12,12,12,12,11,12,11,10,10,12,12,10,11,11,11,12,9,9,11,12,10,12,9,9,6,6,12,10,12,13,12,11,12,1,1,11,11,1,11,11,1,11,3,11,3,3,3,3,11,1,1,11,11,12,12,6,11,1,11,1,1,11,11,12,1,1,12,11,1,1,12,1,12,1,12,1,11,13,12,11,12,11,12,
  14. 11,11,11,10,12,12,12,10,12,12,12,13,9,9,12,13,13,6,6,10,12,13,13,11,11,11,1,11,11,6,1,1,11,11,1,11,1,3,12,3,3,3,3,1,11,11,1,1,11,11,11,1,1,1,11,11,13,13,12,12,13,13,13,12,1,11,1,11,1,1,11,13,11,13,11,12,11,12,12,12,10,12,11,11,10,13,13,12,12,12,12,12,12,12,12,13,13,12,12,12,
  15. 12,12,10,11,11,13,13,12,11,11,1,1,1,1,11,3,11,3,3,3,3,11,1,1,11,1,12,12,1,6,6,1,13,13,1,1,11,11,12,12,13,12,1,1,1,11,1,1,11,13,11,13,12,12,12,11,11,12,12,12,12,12,12,10,11,11,13,11,11,12,12,12,12,12,12,13,13,11,11,12,12,1,1,12,12,13,13,1,11,11,1,1,11,3,3,3,3,3,3,1,
  16. 3,1,1,12,13,12,12,1,1,11,12,1,12,12,1,1,12,13,1,1,12,1,9,1,9,1,12,12,13,12,11,11,11,12,12,12,12,12,11,12,11,11,10,12,12,12,12,12,10,10,10,10,6,6,1,6,6,6,10,1,1,12,1,1,11,11,1,12,11,11,1,3,3,3,3,3,3,11,3,13,0,1,1,13,1,1,13,13,12,1,11,1,11,1,12,11,13,12,12,1,
  17. 9,1,9,1,12,11,13,11,12,12,12,11,11,11,1,11,11,12,12,12,12,11,11,12,10,12,10,10,10,10,6,6,6,6,6,10,9,12,8,1,8,11,1,1,11,11,1,1,8,3,3,3,3,3,3,11,3,1,1,12,12,13,13,13,13,1,11,12,11,1,11,1,11,1,13,12,1,12,12,13,13,11,12,11,12,1,1,11,11,12,0,1,11,1,1,11,11,11,11,12,
  18. 12,11,11,10,12,10,1,1,6,11,11,11,6,9,9,1,1,6,1,1,11,11,11,11,11,8,8,3,3,3,3,3,3,3,3,11,11,13,13,13,12,1,12,1,12,1,1,1,1,1,11,11,12,13,12,13,13,12,11,12,12,1,1,6,6,1,1,11,11,11,1,11,11,12,12,11,11,11,11,12,10,8,9,9,1,6,6,6,6,1,1,1,9,12,8,1,8,12,12,12,
  19. 6,8,8,6,6,3,3,3,3,3,3,3,3,13,13,13,12,12,12,1,12,0,1,11,1,1,11,11,1,13,12,11,13,13,1,1,1,1,6,6,11,1,12,10,0,12,11,11,11,1,11,1,11,11,12,11,12,10,8,1,1,8,8,6,11,11,6,6,9,9,9,11,11,12,12,11,11,11,6,8,8,6,6,3,3,3,3,3,3,3,3,11,11,12,12,12,12,12,1,12,
  20. 12,1,12,8,1,12,13,1,13,1,1,12,12,6,6,12,12,1,1,11,12,11,1,11,10,1,11,11,1,11,0,11,9,11,1,0,0,11,6,11,12,9,6,11,11,11,11,11,10,11,11,11,11,11,11,11,1,8,8,8,8,3,3,3,3,3,3,3,3,3,3,1,12,1,1,8,8,1,1,12,11,1,11,1,12,12,12,12,1,1,11,12,11,11,11,12,11,12,11,11,
  21. 1,11,1,1,11,11,1,11,1,9,9,0,1,1,1,6,2,7,6,6,11,10,10,10,3,3,3,11,11,11,11,11,11,11,11,1,8,1,1,3,3,3,3,3,3,3,3,10,3,10,12,0,8,9,8,9,8,1,12,13,13,13,1,1,1,1,12,11,11,11,12,12,12,12,11,11,12,12,11,1,11,1,1,1,12,1,0,1,0,9,6,9,6,8,8,6,11,11,13,3,
  22. 3,3,3,3,3,12,12,12,12,12,12,12,11,11,11,12,12,3,3,3,3,3,3,3,3,12,3,12,10,13,8,1,9,2,2,12,1,12,12,0,12,12,13,13,11,12,12,12,12,12,12,12,12,1,11,12,11,12,1,1,10,10,1,1,8,8,6,6,12,9,12,15,12,3,3,3,3,3,3,3,3,3,3,10,10,1,1,6,12,9,12,10,12,12,12,3,3,3,3,3,
  23. 3,3,3,10,3,3,3,1,1,1,8,8,2,1,12,10,0,10,0,10,12,12,12,12,12,1,1,12,10,11,1,1,1,10,1,2,9,1,11,10,11,11,10,6,9,11,12,12,6,6,3,3,13,3,3,3,13,3,3,3,13,1,8,11,11,11,6,1,6,12,9,12,12,3,3,3,3,3,3,3,3,12,3,3,3,12,0,12,0,12,1,12,9,9,1,9,6,6,6,6,
  24. 6,6,6,1,1,1,6,1,6,1,1,1,6,6,1,10,10,8,8,8,10,10,10,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,6,6,6,1,1,1,6,6,9,12,3,3,3,3,3,3,3,3,3,3,10,3,3,9,10,9,10,6,6,1,6,9,1,6,6,6,6,6,1,9,6,6,12,12,6,11,12,11,11,9,10,11,10,3,3,3,3,3,3,
  25. 3,3,13,3,3,13,3,12,13,12,3,12,3,12,3,12,3,11,6,0,6,11,11,11,11,6,6,1,9,3,3,3,3,3,3,3,3,3,3,9,3,3,3,9,0,1,6,1,6,1,6,1,1,1,10,12,10,9,12,9,12,11,12,3,3,3,3,3,3,3,3,3,12,12,12,12,3,3,3,3,12,12,12,12,12,12,12,12,12,12,13,12,13,12,12,12,12,12,12,11,
  26. 9,9,6,1,1,6,9,3,3,3,3,3,3,3,3,3,3,10,3,3,3,3,6,12,0,11,9,11,9,10,9,10,12,11,6,11,10,6,12,11,3,12,12,12,12,12,12,12,3,13,3,3,3,3,3,3,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,12,12,11,11,9,12,12,11,11,3,3,3,3,3,3,3,3,3,3,3,10,3,3,3,
  27. 3,9,10,12,3,3,3,3,3,3,3,13,3,3,3,3,12,11,12,12,12,12,12,12,12,12,12,3,3,3,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,12,13,13,10,12,12,13,13,13,12,11,11,9,12,3,3,3,3,3,3,3,3,3,3,3,3,12,3,3,3,3,3,3,12,3,12,13,13,13,13,13,3,12,3,3,12,3,11,12,12,12,12,
  28. 12,12,12,12,12,12,3,3,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,12,12,13,13,13,10,13,13,3,3,13,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,12,13,13,13,12,13,13,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,3,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
  29. 13,12,12,13,10,10,12,3,3,3,3,13,13,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,12,12,12,12,12,12,12,12,12,12,12,12,12,11,12,12,3,3,3,3,3,12,12,13,12,13,12,12,13,11,11,12,12,12,11,11,12,12,12,13,13,13,13,12,12,12,10,12,13,13,13,3,3,3,3,3,3,3,3,3,3,3,
  30. 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,12,12,12,3,11,12,11,12,11,12,12,12,12,11,12,3,12,12,12,13,12,12,13,12,12,12,13,11,13,13,13,11,13,13,13,11,13,13,13,11,11,11,13,11,10,10,12,13,13,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,12,12,3,13,11,12,
  31. 11,12,11,3,3,3,3,11,10,13,12,12,12,12,12,12,12,13,12,12,12,13,11,13,13,13,11,13,13,13,11,13,13,13,12,12,13,12,10,10,12,10,3,3,3,10,3,10,10,12,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,12,12,3,3,3,3,3,12,3,12,3,3,3,11,11,11,3,12,12,12,12,12,12,12,12,12,12,12,11,
  32. 11,12,12,13,12,13,13,12,11,11,12,12,12,12,11,11,12,11,11,10,12,10,3,10,3,10,10,12,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,12,3,3,3,12,12,12,12,3,12,13,3,3,11,12,3,3,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,11,11,13,12,13,13,12,13,13,12,13,12,13,12,13,12,12,3,10,
  33. 3,10,3,10,10,12,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,12,3,3,3,13,12,12,12,6,13,6,11,11,11,11,11,11,3,11,3,12,12,11,11,11,12,11,11,12,12,11,11,12,12,11,12,11,11,13,12,13,13,13,13,12,13,12,13,12,13,3,3,12,3,3,12,10,10,12,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
  34. 3,3,3,3,3,3,3,3,13,3,13,13,13,13,11,3,11,3,11,11,3,11,11,3,3,2,13,3,3,13,13,3,3,13,13,3,3,13,13,11,12,11,11,13,13,12,13,13,13,3,3,3,3,12,3,3,3,13,10,10,12,12,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,12,3,3,3,13,13,11,3,11,12,12,12,3,12,
  35. 3,3,3,3,3,13,13,3,3,12,13,3,13,12,13,12,13,12,13,13,13,13,13,12,13,12,13,13,13,13,13,13,3,3,3,13,13,10,10,12,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,12,3,3,12,3,13,13,3,3,3,3,3,13,11,11,11,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,12,13,13,13,13,12,
  36. 13,13,11,12,13,12,12,12,10,13,3,13,3,13,13,3,3,12,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,12,3,3,3,3,3,3,12,13,13,3,13,11,11,13,3,3,6,3,11,12,3,3,3,12,12,12,12,12,12,12,12,12,12,3,13,13,12,12,13,12,12,6,12,12,12,12,10,10,13,10,13,3,3,12,10,10,3,3,3,3,3,
  37. 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,12,12,12,12,12,12,12,3,6,11,3,11,12,3,3,12,12,12,12,12,12,12,12,12,12,12,3,3,13,13,3,12,13,11,12,13,6,12,6,3,3,3,10,10,3,3,3,10,3,10,3,3,3,10,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
  38. 3,3,12,12,12,12,12,12,12,3,3,3,3,3,3,3,12,12,12,13,12,13,12,13,12,12,12,3,12,11,12,11,3,12,12,13,13,13,13,13,3,3,3,7,3,3,3,10,3,10,3,10,3,10,3,10,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,10,12,10,10,10,12,12,13,13,10,13,10,13,10,13,13,13,13,13,13,
  39. 13,13,13,13,3,3,3,3,3,3,12,12,12,12,12,13,13,3,3,3,3,13,13,13,3,3,10,3,10,3,3,10,3,10,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
  40. 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
  41. 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
  42. 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
  43. 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
  44. 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
  45. 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
  46. 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
  47. 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
  48. 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
  49. 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,] ;
  50.  
  51. var colorsABGR = [];
  52.  
  53. var babaevski = {
  54. x: 312, /*Bottom left corner X*/
  55. y: 984, /*Bottom left corner Y*/
  56. width: 78, /*WIDTH OF IMAGE*/
  57. height: 62 /*HEIGHT OF IMAGE*/
  58. };
  59.  
  60. var perfect_timeout = 60;
  61.  
  62. // hooks
  63. var client;
  64. var canvasse;
  65. var jQuery;
  66.  
  67. var currentDrawPosition = 0;
  68. var currentLoop = 0;
  69.  
  70. r.placeModule("babaevski", function(e){
  71. client = e("client");
  72. canvasse = e("canvasse");
  73. jQuery = e("jQuery");
  74.  
  75. for(var i=0; i<client.palette.length; i++){
  76. colorsABGR[i] = client.getPaletteColorABGR(i);
  77. }
  78.  
  79. attempt();
  80.  
  81. });
  82.  
  83. function attempt(){
  84. console.log("tried to draw");
  85. var toWait = client.getCooldownTimeRemaining();
  86. if(toWait === 0)
  87. {
  88. tryDrawPixel();
  89. }
  90. else
  91. {
  92. setTimeout(attempt, toWait + Math.round(Math.random() * 1500));
  93. console.log("set a timeout");
  94. }
  95. }
  96.  
  97. function tryDrawPixel()
  98. {
  99. var toWait = client.getCooldownTimeRemaining();
  100. if(toWait === 0 && currentLoop < babaevski.width*babaevski.height)
  101. {
  102. currentLoop++;
  103. console.log("checking pixel " + currentDrawPosition);
  104. var targetPoint = getPoint(currentDrawPosition);
  105.  
  106. $.get( "/api/place/pixel.json", { x:targetPoint.x, y:targetPoint.y }, function( data )
  107. {
  108. setTimeout(function() {
  109. //wait an extra half second for reddits servers
  110.  
  111.  
  112. console.log("x" + targetPoint.x + " y"+ targetPoint.y);
  113. if (data.color == undefined)
  114. data.color = 0;
  115. canvasse.drawTileAt(data.x, data.y, colorsABGR[data.color]);
  116. if (colors[currentDrawPosition] != data.color && colors[currentDrawPosition] !== -1)
  117. {
  118. client.setColor(colors[currentDrawPosition]);
  119. client.drawTile(targetPoint.x, targetPoint.y);
  120. console.log("drew pixel at " + targetPoint.x + "/" + targetPoint.y);
  121. var toWait = client.getCooldownTimeRemaining();
  122. setTimeout(attempt, toWait + Math.round(Math.random() * 1500));
  123. currentLoop = 0;
  124. console.log("set a timeout");
  125. }
  126. else
  127. {
  128. var positionIncrease = Math.floor(Math.random() * (Math.min(0.2*currentLoop, 40))) + 1;
  129. currentDrawPosition += positionIncrease;
  130. //console.log("" + currentLoop + ", " +positionIncrease);
  131. if (currentDrawPosition >= babaevski.width*babaevski.height)
  132. currentDrawPosition = 0;
  133. tryDrawPixel(currentDrawPosition);
  134. }
  135. }, 100);
  136. });
  137. }
  138. else
  139. {
  140. var added_timeout = 0;
  141. if (currentLoop == babaevski.width*babaevski.height)
  142. added_timeout = perfect_timeout*1000;
  143. setTimeout(attempt, toWait + Math.round(Math.random() * 1500) + added_timeout);
  144. currentLoop = 0;
  145. console.log("set a timeout");
  146. }
  147.  
  148. }
  149.  
  150. function drawTestRTC(){
  151. for(var i=0; i < babaevski.width*babaevski.height; i++){
  152. if(colors[i] === -1){
  153. continue;
  154. }
  155. var targetPoint = getPoint(i);
  156. canvasse.drawTileAt(targetPoint.x, targetPoint.y, colorsABGR[colors[i]]);
  157. }
  158. }
  159.  
  160. function getPoint(i){
  161. var x = i % babaevski.width;
  162. return {
  163. x: babaevski.x + x,
  164. y: babaevski.y + (i - x) / babaevski.width - babaevski.height
  165. };
  166. }
  167.  
  168. function getPixel(x, y){
  169. return canvasse.writeBuffer[canvasse.getIndexFromCoords(x, y)];
  170. }
  171.  
  172. //Updated by haydnG (hayhay)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement