2018-09-15

this.nearestZ = -c.disdanceHalf

    _this = this;

    this.go = function(index){

        this.nTarget = 0

        if (index < levelFuncs.length)

            levelFuncs[index]();

    }

    function addDesk(h, zPos){

        var desk = hp.addBox(c.roomWidth,h,canRad*2,  0, h/2, zPos);

        ballControls.arrTarget.push(desk);

    }

    function addBox(w, h, xPos,yPos,zPos, o){

        var desk = hp.addBox(w, h, canRad*2,  xPos, yPos+h/2, zPos, o)

        ballControls.arrTarget.push(desk);

        return desk;

    }

    function addCan(xPos,yPos,zPos,o)

    {

        var can = hp.addCan(canWidth,canHeight,  xPos,yPos+canHeight/2,zPos,o)

        ballControls.arrTarget.push(can); 

        _this.nTarget++;

        if (zPos + canRad > _this.nearestZ)  _this.nearestZ = zPos + canRad;

        return can;

    }

    function addBall(xPos, o)

    {

        var ball = hp.addBall(ballWidth, xPos, c.groundY+ballRad , c.disdanceHalf, o)

        ballControls.arrBall.push(ball);

    }

    function addBalls(cnt){

        if (cnt === undefined)

            cnt = Math.floor(c.roomWidth/(2*ballRad))

        var startX = -(cnt*ballRad) + ballRad;

        for (var i = 0; i < cnt; ++i)

            addBall(startX + i* 2*ballRad)

    }   

    function addSwingBox(w, h, xPos,yPos,zPos){

        var desk = addBox(w, h, xPos,yPos,zPos, {move:true})

        var ball = hp.addBall(ballWidth, xPos, yPos+h+ballRad+w/2, zPos, {move:false})

        ballControls.arrTarget.push(ball);

        var spring = [2, 0.3];

        world.add({ type:'jointHinge', body1:ball.body, body2:desk.body, pos1:[0, -ballRad-w/2, 0], pos2:[0, h/2, 0],

                    collision:false, spring:spring, min:90, max:-90, axe1:[0,0,1], axe2:[0,0,1]  });

        desk.body.applyImpulse(new OIMO.Vec3(0,0,0), new OIMO.Vec3(100,0,0));

    }

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • "use strict";function _classCallCheck(e,t){if(!(e instanc...
    久些阅读 6,261评论 0 2
  • var navigator = navigator || {};var window = window || {}...
    DF_Sky阅读 5,198评论 0 0
  • html this.shootHeight = 4 gui.add(c, 'shootHeight', 0, ...
    浪巅阅读 1,576评论 0 0
  • JSON APIS and AJAX Description:*Introduction to the JSON ...
    王策北阅读 3,633评论 0 1
  • 还没从宋仲基"老公"中枪的心痛中走出来,后脚朱朱就在微博上@我说,慢慢你完了!微博上面总结了几类女孩子找不到男朋友...
    慢慢龟阅读 4,312评论 0 1

友情链接更多精彩内容