手游超级玛丽,超级马里奥
各位老铁们,大家好,今天由我来为大家分享手游超级玛丽,以及超级马里奥的相关问题知识,希望对大家有所帮助。如果可以帮助到大家,还望关注收藏下本站,您的支持是我们最大的动力,谢谢大家了哈,下面我们开始吧!
1、玩法:点击鼠标左键进行马里奥跳跃,带着马里奥跳跃不同的障碍物,统计分数,快去玩变态超级玛丽吧^^。\n
开始游戏
2、<canvasid="gamescene"></canvas>\ncss
#game_div.horizontal{width:680px;height:480px;}\n.horizontal#start{background:transparent;width:680px;height:460px;}\n.horizontal#start.title{margin:15pxauto15px;}\n.horizontal#play{background:transparent;width:680px;height:300px;}\n.horizontal#end{width:680px;height:400px;}\n.horizontal#footer{bottom:0;}\njs
varP=function(canvas,size,procedure){\nvarself=this;\nself.debug=true;\nself.width=size.width;\nself.height=size.height;\nself.director=newP.Director;\nself.loader=newP.Loader;\nself.root=newP.Group(this);\nself.ctx=document.getElementById(canvas).getContext('2d');\nself.camera=newP.Camera(this);\nself.pe=newP.Physics(this);\nself.other={};\nself.other={};\nprocedure.preload&&procedure.preload(this);\nself.loader.waitForComplete(P.Util.proxy(function(){\nprocedure.init&&procedure.init(this);\nprocedure.start&&procedure.start(this);\nself.render(self.ctx);\n},this));\n}\nP.prototype.render=function(ctx){\nvarself=this;\nP.Util.setIntervalWithTimeout(function(){\nctx.clearRect(0,0,ctx.canvas.width,ctx.canvas.height);\nself.camera.update();\nself.renderTree(self.root,ctx);\n},1000/60);\n}\nP.prototype.renderTree=function(node,ctx){\nif(node.img){\nif(node.stype=="normal"){\nvarx=node.x-(this.camera.x);\nvary=node.y-(this.camera.y);\nctx.drawImage(node.img,0+node.width*node.frame,0,\nnode.width,node.height,x,y,node.width,node.height);\n}elseif(node.stype=="repeat-x"){\nvarx=node.x;\nvary=node.y-(this.camera.y);\nvarstartX=(this.camera.x>node.x)\n?((node.x-this.camera.x)%node.width)\n:(-(node.width+(this.camera.x-node.x)%node.width));\nvarnumber=Math.ceil((this.width-startX)/node.width);\nfor(vari=0;i<number;i++){\nctx.drawImage(node.img,startX+i*node.width,y);\n}\n}elseif(node.stype=="repeat-x-rect"){\nvarpattern=ctx.createPattern(node.img,"repeat-x");\nctx.fillStyle=pattern;\nctx.fillRect(0,0,this.width,this.height);\n}elseif(node.stype=="group"){\n}\n}\nfor(varxinnode.children){\nthis.renderTree(node.children[x],ctx);\n}\n}\n//P.Camera\nP.Camera=function(game){\nthis.x=0;\nthis.y=0;\nthis.padding={\ntop:0\n,right:0\n,bottom:0\n,left:0\n};\nthis.player=null;\nthis.game=game;\n}\nP.Camera.prototype.follow=function(player,playerPosition,stype,options){\nthis.player=player;\nthis.playerPosition=playerPosition;\nthis.stype=stype;\nif(stype=="padding"){\nthis.padding=options;\nvarwidth=this.game.width-options.left-options.right;\nvarheight=this.game.height-options.top-options.bottom;\nthis.x=player.x-(width*playerPosition.x+options.left);\nthis.y=player.y-(height*playerPosition.y+options.top);\n}elseif(stype=="viewport"){\nthis.viewport=options;\nthis.x=player.x-(options.width*playerPosition.x+options.x);\nthis.y=player.y-(options.height*playerPosition.y+options.y);\n}\n}\nP.Camera.prototype.update=function(){\nif(this.player){\nif(this.stype=="padding"){\nif(this.player.x<this.x+this.padding.left){\nthis.x+=this.player.x-(this.x+this.padding.left);\n}elseif(this.player.x>this.x+this.game.width-this.padding.right){\nthis.x+=this.player.x-(this.x+this.game.width-this.padding.right);\n}\nif(this.player.y<this.y+this.padding.top){\nthis.y+=this.player.y-(this.y+this.padding.top);\n}elseif(this.player.y>this.y+this.game.height-this.padding.bottom){\nthis.y+=this.player.y-(this.camera.y+this.game.height-this.padding.bottom);\n}\n}elseif(this.stype=="viewport"){\nif(this.player.x<this.x+this.viewport.x){\nthis.x+=this.player.x-(this.x+this.viewport.x);\n}elseif(this.player.x>this.x+this.game.width-\n(this.game.width-this.viewport.x-this.viewport.width)){\nthis.x+=this.player.x-(this.x+this.game.width-\n(this.game.width-this.viewport.x-this.viewport.width));\n}\nif(this.player.y<this.y+this.viewport.y){\nthis.y+=this.player.y-(this.y+this.viewport.y);\n}elseif(this.player.y>this.y+this.game.height-\n(this.game.height-this.viewport.y-this.viewport.height)){\nthis.y+=this.player.y-(this.camera.y+this.game.height-\n(this.game.height-this.viewport.y-this.viewport.height));\n}\n}\n}\n}\nP.Physics=function(game){\nthis.game=game;\nthis.loop=null;\nthis.gravity=0;\nthis.children={};\nthis.isRunning=false;\n}\nP.Physics.prototype.start=function(){\nvarself=this;\nself.isRunning=true;\nself.loop=P.Util.setIntervalWithTimeout(function(){\nself.update();\n},1000/60);\n}\nP.Physics.prototype.stop=function(){\nP.Util.clearIntervalWithTimeout(this.loop);\nthis.loop=null;\nthis.isRunning=false;\n}\n
源码
3、转载:欢迎来到本站,转载请注明文章出处https://ormcc.com/
文章到此结束,如果本次分享的手游超级玛丽和超级马里奥的问题解决了您的问题,那么我们由衷的感到高兴!