背景出不来
var can1;
var can2;
var ctx1;
var ctx2;
var lastTime;
var deltaTime;
var bgPic=new Image();
var canWidth;
var canHeight;
document.body.onload=game;
function game(){
lastTime=Date.now();
deltaTime=0;
init();
gameloop();
}
function init(){
can1=document.getElementById("canvas1");
can2=document.getElementById("canvas2");
ctx1=can1.getContext("2d");
ctx2=can2.getContext("2d");
bgPic.src="src/background.jpg";
canWidth=canvas1.width;
canHeight=canvas1.height;
}
function gameloop(){
window.requestAnimFrame(gameloop);
var now=Date.now();
deltaTime=now-lastTime;
lastTime=now;
drawBackground();
}