<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>飞机加速减速HTML5游戏 - 网页模板</title>
<script type="text/javascript" src="js/jquery.min.js"></script>
<style>
body {
margin:0;
padding:0;
background:#000;
}
canvas {
display:block;
margin:0 auto;
background:#f8982b;
}
</style>
</head>
<body>
<canvas></canvas>
<script type="text/javascript">
if ( !window.requestAnimationFrame ) {
window.requestAnimationFrame = ( function() {
return window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function( /* function FrameRequestCallback */ callback, /* DOMElement Element */ element ) {
window.setTimeout( callback, 1000 / 60 );
};
} )();
}
// stats.js r6 - https://github.com/mrdoob/stats.js
var Stats=function(){function s(a,g,d){var f,c,e;for(c=0;c<30;c++)for(f=0;f<73;f++)e=(f+c*74)*4,a[e]=a[e+4],a[e+1]=a[e+5],a[e+2]=a[e+6];for(c=0;c<30;c++)e=(73+c*74)*4,c<g?(a[e]=b[d].bg.r,a[e+1]=b[d].bg.g,a[e+2]=b[d].bg.b):(a[e]=b[d].fg.r,a[e+1]=b[d].fg.g,a[e+2]=b[d].fg.b)}var r=0,t=2,g,u=0,j=(new Date).getTime(),F=j,v=j,l=0,w=1E3,x=0,k,d,a,m,y,n=0,z=1E3,A=0,f,c,o,B,p=0,C=1E3,D=0,h,i,q,E,b={fps:{bg:{r:16,g:16,b:48},fg:{r:0,g:255,b:255}},ms:{bg:{r:16,g:48,b:16},fg:{r:0,g:255,b:0}},mb:{bg:{r:48,g:16,
b:26},fg:{r:255,g:0,b:128}}};g=document.createElement("div");g.style.cursor="pointer";g.style.width="80px";g.style.opacity="0.9";g.style.zIndex="10001";g.addEventListener("click",function(){r++;r==t&&(r=0);k.style.display="none";f.style.display="none";h.style.display="none";switch(r){case 0:k.style.display="block";break;case 1:f.style.display="block";break;case 2:h.style.display="block"}},!1);k=document.createElement("div");k.style.backgroundColor="rgb("+Math.floor(b.fps.bg.r/2)+","+Math.floor(b.fps.bg.g/
2)+","+Math.floor(b.fps.bg.b/2)+")";k.style.padding="2px 0px 3px 0px";g.appendChild(k);d=document.createElement("div");d.style.fontFamily="Helvetica, Arial, sans-serif";d.style.textAlign="left";d.style.fontSize="9px";d.style.color="rgb("+b.fps.fg.r+","+b.fps.fg.g+","+b.fps.fg.b+")";d.style.margin="0px 0px 1px 3px";d.innerHTML='<span style="font-weight:bold">FPS</span>';k.appendChild(d);a=document.createElement("canvas");a.width=74;a.height=30;a.style.display="block";a.style.marginLeft="3px";k.appendChild(a);
m=a.getContext("2d");m.fillStyle="rgb("+b.fps.bg.r+","+b.fps.bg.g+","+b.fps.bg.b+")";m.fillRect(0,0,a.width,a.height);y=m.getImageData(0,0,a.width,a.height);f=document.createElement("div");f.style.backgroundColor="rgb("+Math.floor(b.ms.bg.r/2)+","+Math.floor(b.ms.bg.g/2)+","+Math.floor(b.ms.bg.b/2)+")";f.style.padding="2px 0px 3px 0px";f.style.display="none";g.appendChild(f);c=document.createElement("div");c.style.fontFamily="Helvetica, Arial, sans-serif";c.style.textAlign="left";c.style.fontSize=
"9px";c.style.color="rgb("+b.ms.fg.r+","+b.ms.fg.g+","+b.ms.fg.b+")";c.style.margin="0px 0px 1px 3px";c.innerHTML='<span style="font-weight:bold">MS</span>';f.appendChild(c);a=document.createElement("canvas");a.width=74;a.height=30;a.style.display="block";a.style.marginLeft="3px";f.appendChild(a);o=a.getContext("2d");o.fillStyle="rgb("+b.ms.bg.r+","+b.ms.bg.g+","+b.ms.bg.b+")";o.fillRect(0,0,a.width,a.height);B=o.getImageData(0,0,a.width,a.height);try{performance&&performance.memory&&performance.memory.totalJSHeapSize&&
(t=3)}catch(G){}h=document.createElement("div");h.style.backgroundColor="rgb("+Math.floor(b.mb.bg.r/2)+","+Math.floor(b.mb.bg.g/2)+","+Math.floor(b.mb.bg.b/2)+")";h.style.padding="2px 0px 3px 0px";h.style.display="none";g.appendChild(h);i=document.createElement("div");i.style.fontFamily="Helvetica, Arial, sans-serif";i.style.textAlign="left";i.style.fontSize="9px";i.style.color="rgb("+b.mb.fg.r+","+b.mb.fg.g+","+b.mb.fg.b+")";i.style.margin="0px 0px 1px 3px";i.innerHTML='<span style="font-weight:bold">MB</span>';
h.appendChild(i);a=document.createElement("canvas");a.width=74;a.height=30;a.style.display="block";a.style.marginLeft="3px";h.appendChild(a);q=a.getContext("2d");q.fillStyle="#301010";q.fillRect(0,0,a.width,a.height);E=q.getImageData(0,0,a.width,a.height);return{domElement:g,update:function(){u++;j=(new Date).getTime();n=j-F;z=Math.min(z,n);A=Math.max(A,n);s(B.data,Math.min(30,30-n/200*30),"ms");c.innerHTML='<span style="font-weight:bold">'+n+" MS</span> ("+z+"-"+A+")";o.putImageData(B,0,0);F=j;if(j>
v+1E3){l=Math.round(u*1E3/(j-v));w=Math.min(w,l);x=Math.max(x,l);s(y.data,Math.min(30,30-l/100*30),"fps");d.innerHTML='<span style="font-weight:bold">'+l+" FPS</span> ("+w+"-"+x+")";m.putImageData(y,0,0);if(t==3)p=performance.memory.usedJSHeapSize*9.54E-7,C=Math.min(C,p),D=Math.max(D,p),s(E.data,Math.min(30,30-p/2),"mb"),i.innerHTML='<span style="font-weight:bold">'+Math.round(p)+" MB</span> ("+Math.round(C)+"-"+Math.round(D)+")",q.putImageData(E,0,0);v=j;u=0}}}};
//Insane - Tech Demo
(function( Insane, $, undefined ) {
//Public Vars
Insane.WIDTH = 320;
Insane.HEIGHT = 480;
Insane.scale = 1,
Insane.offset = {top: 0, left: 0},
Insane.RATIO = null,
Insane.currentWidth = null,
Insane.currentHeight = null,
Insane.canvas = null,
Insane.ctx = null,
Insane.ua = null,
Insane.android = null,
Insane.ios = null,
Insane.startTime = Date.now(),
Insane.dtime,
Insane.stats, //FPS stats
Insane.rychlost = 80,
Insane.hvezdy = [],
Insane.planety = [],
Insane.boostery = [],
Insane.slowery = [],
Insane.player
//FPS init
function fpsInit() {
stCon = document.createElement( 'div' );
document.body.appendChild( stCon );
Insane.stats = new Stats();
Insane.stats.domElement.style.position = 'absolute';
Insane.stats.domElement.style.top = '0px';
stCon.appendChild(Insane.stats.domElement);
}
//Init funkce
Insane.init = function() {
Insane.RATIO = Insane.WIDTH / Insane.HEIGHT;
Insane.currentWidth = Insane.WIDTH;
Insane.currentHeight = Insane.HEIGHT;
Insane.canvas = document.getElementsByTagName('canvas')[0];
Insane.canvas.width = Insane.WIDTH;
Insane.canvas.height = Insane.HEIGHT;
Insane.ctx = Insane.canvas.getContext('2d');
Insane.ua = navigator.userAgent.toLowerCase();
Insane.android = Insane.ua.indexOf('android') > -1 ? true : false;
Insane.ios = ( Insane.ua.indexOf('iphone') > -1 || Insane.ua.indexOf('ipad') > -1 ) ? true : false;
// Controls
window.addEventListener('click', function(e) {
e.preventDefault();
//Insane.player1.x = e.clientX - Insane.offset.left / Insane.scale;
//console.log(Insane.player1.x);
}, false);
// listen for touches
window.addEventListener('touchstart', function(e) {
e.preventDefault();
Insane.player1.x = (event.touches[0].pageX - Insane.offset.left) / Insane.scale;
}, false);
window.addEventListener('touchmove', function(e) {
e.preventDefault();
Insane.player1.x = (event.touches[0].pageX - Insane.offset.left) / Insane.scale;
}, false);
window.addEventListener('touchend', function(e) {
e.preventDefault();
Insane.player1.x = (event.touches[0].pageX - Insane.offset.left) / Insane.scale;
}, false);
window.addEventListener('keydown', function(e) {
if(e.keyCode == "37") {
Insane.player1.x -= 1*Insane.rychlost/40;
}
if(e.keyCode == "39") {
Insane.player1.x += 1*Insane.rychlost/40;
}
}, false);
window.addEventListener('mousemove', function(e) {
e.preventDefault();
Insane.player1.x = (e.clientX - Insane.offset.left) / Insane.scale;
}, false);
window.addEventListener('mousedown', function(e) {
e.preventDefault();
//Insane.player1.x = e.clientX - Insane.offset.left;
}, false);
//
Insane.resize();
fpsInit();
Insane.player1 = new Insane.Player();
Insane.player1.reset();
Insane.loop();
}
//Resize funkce
Insane.resize = function() {
Insane.currentHeight = window.innerHeight;
Insane.currentW