Mouse Hit游戏类源码

本文分享了Mouse Hit游戏的类源码,深入探讨了游戏中涉及的数学建模原理,包括碰撞检测、轨迹预测等关键算法。适合对游戏开发和数学建模感兴趣的读者学习。
摘要由CSDN通过智能技术生成
/**
 * 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.
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值