/**
* Mouse Hit游戏类
*/
(function() {
var MouseHit = function(cfg) {
/**
* 锤子
*/
this.hammer = null;
/**
* 地鼠,有5种
*/
this.mouse0=[];
this.mouse1=[];
this.mouse2=[];
this.mouse3=[];
this.mouse4=[];
/**
* 地鼠初始化x轴位置
*/
this.mouseX = [
[130,322,516],
[106,322,522],
[97,322,544]
];
/**
* 地鼠初始化y轴位置
*/
this.mouseY = [170,262,362];
this.mouseType=[106];
//存在矩阵,表示在那个坑存在地鼠
this.existMatrix=[
[0,0,0],
[0,0,0],
[0,0,0]
];
/**
* 星星
*/
this.star = [];
/**
* 分数帧类
*/
this.scoreObject = [];
/**
* UI对象
*/
this.ui = null;
/**
* 预备时间
*/
this.readyTime = 0;
/**
* 是否即将开始
*/
this.isGo = false;
/**
* canvas上下文
*/
this.canvas;
this.context;
// 地鼠洞
this.bg_hole;
// 地鼠洞遮掩
this.bg_holeHide;
//准备3,2,1数字,Game over
this.startNumber= my.ImageManager.get('icon');
//计时条
this.timeRoller = my.ImageManager.get('time_roller');
//计时数,不打算用一个新的setInterval来做
this.timeCaculator =0;
//第几关,初始是第一关
this.dijiguan = 1;
//每关过关分数,第一默认为2000
this.requireScore =2000;
this.readyInterval;
this.drawMouseInterval;
this.drawCanvasInterval;
}
/**
* @private
* 创建锤子
*/
MouseHit.prototype.__createHammer = function() {
var hammer = new Hammer();
this.hammer = hammer;
}
/**
* @private
* 创建分数对象
*/
MouseHit.prototype.__createScoreObject = function() {
for(i=0;i<3;i++)
{
var arr = [];
for(j=0;j<3;j++)
{
var score = new Score();
arr[j] = score;
}
this.scoreObject[i] = arr;
}
}
/**
* @private
* 创建地鼠
*/
MouseHit.prototype.
Mouse Hit游戏类源码
本文分享了Mouse Hit游戏的类源码,深入探讨了游戏中涉及的数学建模原理,包括碰撞检测、轨迹预测等关键算法。适合对游戏开发和数学建模感兴趣的读者学习。
摘要由CSDN通过智能技术生成