Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function timestamp() {
- if (window.performance && window.performance.now){
- return window.performance.now();
- } else {
- return new Date().getTime();
- }
- }
- var fps = 60,
- step = 1/fps,
- dt = 0,
- now,
- last = timestamp();
- function frame() {
- now = timestamp();
- dt = dt + Math.min(1, (now - last) / 1000);
- while(dt > step) {
- dt = dt - step;
- update(step);
- }
- render(ctx, dt);
- last = now;
- requestAnimationFrame(frame, canvas);
- }
- frame();
- /* ======================================================== */
- function timestamp() {
- if (window.performance && window.performance.now){
- return window.performance.now();
- }
- else {
- return new Date().getTime();
- }
- }
- var fps = 60,
- step = 1 / fps,
- dt = 0,
- now,
- last = timestamp();
- function frame() {
- now = timestamp();
- dt = dt + Math.min(1, (now - last) / 1000);
- while (dt > step) {
- dt = dt - step;
- update();
- }
- render(ctx);
- last = now;
- requestAnimationFrame(frame);
- }
- /* ===================================================== */
- var c=document.getElementById("myCanvas");
- var ctx=c.getContext("2d");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement