daily pastebin goal
68%
SHARE
TWEET

Remmys Codeschnipsel

RandomGuy32 Jul 11th, 2014 239 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function timestamp() {
  2. if (window.performance && window.performance.now){
  3. return window.performance.now();
  4. } else {
  5. return new Date().getTime();
  6. }
  7. }
  8.  
  9. var fps = 60,
  10. step = 1/fps,
  11. dt = 0,
  12. now,
  13. last = timestamp();
  14.  
  15. function frame() {
  16. now = timestamp();
  17. dt = dt + Math.min(1, (now - last) / 1000);
  18. while(dt > step) {
  19. dt = dt - step;
  20. update(step);
  21. }
  22. render(ctx, dt);
  23. last = now;
  24. requestAnimationFrame(frame, canvas);
  25. }
  26. frame();
  27.  
  28. /* ======================================================== */
  29.  
  30. function timestamp() {
  31. if (window.performance && window.performance.now){
  32. return window.performance.now();
  33. }
  34. else {
  35. return new Date().getTime();
  36. }
  37. }
  38.  
  39. var fps = 60,
  40. step = 1 / fps,
  41. dt = 0,
  42. now,
  43. last = timestamp();
  44.  
  45. function frame() {
  46. now = timestamp();
  47. dt = dt + Math.min(1, (now - last) / 1000);
  48. while (dt > step) {
  49. dt = dt - step;
  50. update();
  51. }
  52. render(ctx);
  53. last = now;
  54. requestAnimationFrame(frame);
  55. }
  56.  
  57. /* ===================================================== */
  58.  
  59. var c=document.getElementById("myCanvas");
  60. var ctx=c.getContext("2d");
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top