复制代码代码如下: // JavaScript Document var c = document.getElementById("dotu"); var cxt = c.getContext("2d"); var img = newImg("./assets/bg_01.jpg"); var fps; cxt.drawImage(img,0,0,480,800);
var flivverLog = 0; var flivver1 = newImg("./assets/flivver.png"); var flivver2 = newImg("./assets/flivver2.png"); var flivver3 = newImg("./assets/flivver3.png");
// 用于记录游戏的时间,越到后面越快 var time1 = 0; var time2 = 80;
// 积分 var jifen = 0;
function getSudu(){ var number = parseInt(Math.random()*10); if(number 5 number 0){ return number; } return 1; } // 飞机的对象 function flivverObj(hp,ewidth,eheight,eimg,esudu){ // 随机的X this.x = parseInt(Math.random()*460+1); this.y = 0; // 血量 this.hp = hp; // 挨打 this.hit = 0; // 是否死亡 this.over = 0;
// 获取飞机 function getFlivver(type){ switch(type){ case 1: return new flivverObj(100,50,30,flivver1,getSudu()); case 2: return new flivverObj(500,70,90,flivver2,getSudu()); case 3: return new flivverObj(1000,110,170,flivver3,getSudu()); } } function cartridge(x,y){ this.x = x; this.y = y; }
(function(cxt){ var dotu = {nums:0}; // 用于存放小飞机 var flivver = new Array(); var flivverImg = newImg("./assets/flivver.png"); // 自己 var me = {x:240,y:750}; var meImg = newImg('assets/me.png'); // 子弹 var cartridges = new Array(); var cartridgeImg = newImg('./assets/cartridge.png');
var boo1 = newImg('./assets/boo1.png'); var over = newImg('./assets/over.png'); // dotu.update = function(){