原生JS沙滩足球游戏
今天要给大家展示一个游戏,一个小小的程序啦!这个游戏玩的时候有音乐!很有趣的哦! 废话不多说,我们直接上代码!!
首先我们看一下目录
有图片 ,有音频,有它css样式,有js 哈哈哈哈 !! 有点啰嗦了,,上代码 上代码 !!!
我们看一下它的game.css
html,body{background-color:#000;margin:0;padding:0;position:relative;font-family:arial;width:100%}#game{position:absolute;left:0;top:0;z-index:0}#ajaxbar{background:url(media/graphics/loading/ajax-loader.gif) center no-repeat}#canvas{position:absolute;left:0;top:0;width:100%;height:100%;-ms-interpolation-mode:nearest-neighbor;-webkit-transform:scale3d(1,1,1);z-index:1}#orientate{position:absolute;float:left;width:100%;height:100%;top:0;left:0;z-index:10002;display:none}#orientate img{position:absolute;float:left;width:100%;height:100%}.play{position:absolute;float:left;width:100%;height:100%;z-index:1000;background-color:#fff;left:0;top:0;display:none}.play img{position:absolute;float:left;width:100%;height:100%;z-index:1000;left:0;top:0}#nohtml5{position:absolute;top:0;left:0;width:100%;height:100%;background-color:#000;z-index:1002;visibility:hidden}#nohtml5 img{position:absolute;width:100%;height:100%}#nohtml5-bubble{position:absolute;bottom:20px;left:50px;width:380px;height:100px;z-index:1002;color:#000;background:rgba(255,255,255,.75);-webkit-border-radius:10px;-moz-border-radius:10px;border-radius:10px}#nohtml5-text{padding:10px}.horizontal-seperator{height:10px;width:100%}@font-face{font-family:luckiest-guy;src:url(media/fonts/luckiest-guy.woff),url(media/fonts/luckiest-guy.ttf);src:local('☺'),url(media/fonts/luckiest-guy.woff) format('woff'),url(media/fonts/luckiest-guy.ttf) format('truetype');font-weight:400;font-style:normal}#MobileAdInGamePreroll,#MobileAdInGamePreroll2,#MobileAdInGamePreroll3{position:absolute;float:left;min-width:320px;z-index:10000;left:0;top:0;display:none;background:rgba(0,0,0,.7);-webkit-transition:all .6s ease;-moz-transition:all .6s ease;-o-transition:all .6s ease}#MobileAdInGamePreroll-Box,#MobileAdInGamePreroll2-Box,#MobileAdInGamePreroll3-Box{z-index:10000;position:absolute;width:302px;height:250px}#MobileAdInGamePreroll-Box-Body,#MobileAdInGamePreroll2-Box-Body,#MobileAdInGamePreroll3-Box-Body{z-index:10000;position:relative;background:0 0}#MobileAdInGamePreroll-Box-Footer,#MobileAdInGamePreroll2-Box-Footer,#MobileAdInGamePreroll3-Box-Footer{z-index:10000;position:relative;font-size:11px;height:20px;color:#fff;background:0 0}#MobileAdInGamePreroll-Box-Header,#MobileAdInGamePreroll2-Box-Header,#MobileAdInGamePreroll3-Box-Header{z-index:10000;position:relative;margin-top:-2px;font-size:11px;height:20px;text-align:right;color:#fff;background:0 0}#MobileAdInGamePreroll-Box-Close,#MobileAdInGamePreroll2-Box-Close,#MobileAdInGamePreroll3-Box-Close{position:absolute;z-index:10005;background-image:url(media/graphics/generic-ad/light/close-button.png);background-repeat:no-repeat;width:22px;height:22px;top:-4px;margin-right:-1px;display:none}#MobileAdInGameHeader,#MobileAdInGameHeader2,#MobileAdInGameHeader3{display:none;position:absolute;background:0 0}#MobileAdInGameFooter,#MobileAdInGameFooter2,#MobileAdInGameFooter3{display:none;position:absolute;background:0 0}#MobileAdInGameEnd,#MobileAdInGameEnd2,#MobileAdInGameEnd3{position:absolute;float:left;min-width:320px;z-index:10000;left:0;top:0;display:none;background:rgba(0,0,0,.7);-webkit-transition:all .6s ease;-moz-transition:all .6s ease;-o-transition:all .6s ease}#MobileAdInGameEnd-Box,#MobileAdInGameEnd2-Box,#MobileAdInGameEnd3-Box{z-index:10000;position:absolute;width:302px;height:250px}#MobileAdInGameEnd-Box-Body,#MobileAdInGameEnd2-Box-Body,#MobileAdInGameEnd3-Box-Body{z-index:10000;position:relative;background:0 0}#MobileAdInGameEnd-Box-Footer,#MobileAdInGameEnd2-Box-Footer,#MobileAdInGameEnd3-Box-Footer{z-index:10000;position:relative;font-size:11px;height:20px;color:#fff;background:0 0}#MobileAdInGameEnd-Box-Header,#MobileAdInGameEnd2-Box-Header,#MobileAdInGameEnd3-Box-Header{z-index:10000;position:relative;margin-top:-2px;font-size:11px;height:20px;text-align:right;color:#fff;background:0 0}#MobileAdInGameEnd-Box-Close,#MobileAdInGameEnd2-Box-Close,#MobileAdInGameEnd3-Box-Close{position:absolute;z-index:10005;background-image:url(media/graphics/generic-ad/light/close-button.png);background-repeat:no-repeat;width:22px;height:22px;top:-4px;margin-right:-1px;display:none}.ig_debug{position:fixed;left:0;bottom:0;width:100%;background-color:#000;border-top:2px solid #f57401;font-size:12px;color:#fff;z-index:1000;-webkit-user-select:none;display:none}.ig_debug_panel_menu{height:28px;background:#222;background:-webkit-gradient(linear,left bottom,left top,color-stop(0,#000000),color-stop(1,#333));background:-moz-linear-gradient(center bottom,#000000 0%,#333 100%);background:-o-linear-gradient(#333,#000000)}.ig_debug_panel_menu div{float:left;height:22px;padding:6px 8px 0;border-right:1px solid #333}.ig_debug_panel_menu .ig_debug_head{font-weight:700;color:#888}.ig_debug_menu_item:hover{cursor:pointer;background-color:#fff;color:#000}.ig_debug_menu_item.active,.ig_debug_menu_item.active:hover{background-color:#000;color:#fff}.ig_debug_stats{position:absolute;right:0;top:0;float:right;color:#888;border-left:1px solid #333;text-align:right}.ig_debug_stats span{width:3em;display:inline-block;color:#fff!important;margin-right:.2em;margin-left:.3em;font-family:bitstream vera sans mono,courier new;white-space:nowrap}.ig_debug_panel{height:152px;overflow:auto;position:relative}.ig_debug_panel canvas{border-bottom:1px solid #444}.ig_debug_panel .ig_debug_panel{padding:8px;height:auto;float:left;background-color:#000;border-right:2px solid #222}.ig_debug_option{padding:2px 0 2px 8px;cursor:pointer}.ig_debug_option:first-child{margin-top:8px}.ig_debug_option:hover{background-color:#111}.ig_debug_graph_mark{position:absolute;color:#888;left:4px;font-size:10px;margin-top:-12px}.ig_debug_legend{color:#ccc}.ig_debug_label_mark{display:inline-block;width:10px;height:10px;margin-right:4px;-webkit-transition:.1s linear;-moz-transition:.1s linear}.ig_debug_legend_color{display:inline-block;width:6px;height:10px;margin-right:4px;margin-left:16px}.ig_debug_legend_number{width:3em;display:inline-block;text-align:right;font-family:bitstream vera sans mono,courier new;color:#fff;margin-right:.2em}.ig_debug_map_container{position:relative;overflow:hidden;border:1px solid #888}.ig_debug_map_container canvas{position:absolute}.ig_debug_map_screen{position:absolute;border:1px solid #f0f}
接下来它的js
它的js比较多,要耐心看哦!
var adcnt = 0;
setInterval(function() {adcnt++;
}, 999);
var _SETTINGS = {MarketJSGameCenter: {Activator: {Enabled: !1,Position: {Top: "15%",Left: "0"}},API: {Enabled: !1,Log: {Events: {InitializeGame: !0,EndGame: !0,Level: {for (r = 0; n = u[r++];)if (e && -1 < p.inArray(n, e)) j && j.push(n);else if (g = p.contains(n.ownerDocument, n), f = F(l.appendChild(n), "script"), g && s(f), d)for (x = 0; n = f[x++];) ac.test(n.type || "") && d.push(n);return l}function G() {return !0}function C() {return !1}function H() {try {return Y.activeElement} catch (b) {}}function R(b, c, d, e, j, n) {var f, x;if ("object" == typeof c) {"string" != typeof d && (e = e || d, d = void 0);for (x in c) R(b, x, d, e, c[x], n);return b}if (null == e && null == j ? (j = d, e = d = void 0) : null == j && ("string" == typeof d ? (j = e, e = void 0) : (j = e, e = d, d = void 0)), !1 === j) j = C;else if (!j) return b;return 1 === n && (f = j, j = function(b) {return p().off(b), f.apply(this, arguments)}, j.guid = f.guid || (f.guid = p.guid++)), b.each(function() {p.event.add(this, c, j, e, d)})}function K(b, c) {return f(b, "table") && f(11 !== c.nodeType ? c : c.firstChild, "tr") ? p(">tbody", b)[0] || b : b}function fa(b) {return b.type = (null !== b.getAttribute("type")) + "/" + b.type, b}function O(b) {var c = Lc.exec(b.type);return c ? b.type = c[1] : b.removeAttribute("type"), b}function P(b, c) {var d, e, j, n, f, x;if (1 === c.nodeType) {if (T.hasData(b) && (d = T.access(b), e = T.set(c, d), x = d.events))for (j in delete e.handle, e.events = {}, x) {d = 0;for (e = x[j].length; d < e; d++) p.event.add(c, j, x[j][d])}pa.hasData(b) && (n = pa.access(b), f = p.extend({}, n), pa.set(c, f))}}function ba(b, c, e, j) {c = bb.apply([], c);var n, f, x, g, l = 0,u = b.length,r = u - 1,M = c[0],q = p.isFunction(M);if (q || 1 < u && "string" == typeof M && !da.checkClone && Mc.test(M)) return b.each(function(d) {var n = b.eq(d);q && (c[0] = M.call(this, d, n.html()));ba(n, c, e, j)});if (u && (n = I(c, b[0].ownerDocument, !1, b, j), f = n.firstChild, 1 === n.childNodes.length && (n = f), f || j)) {f = p.map(F(n, "script"), fa);for (x = f.length; l < u; l++) g = n, l !== r && (g = p.clone(g, !0, !0), x && p.merge(f, F(g, "script"))), e.call(b[l], g, l);if (x) {n = f[f.length - 1].ownerDocument;p.map(f, O);for (l = 0; l < x; l++) g = f[l], ac.test(g.type || "") && !T.access(g, "globalEval") && p.contains(n, g) && (g.src ? p._evalUrl && p._evalUrl(g.src) : d(g.textContent.replace(Oc, ""), n))}}return b}}FLASHAPI: {getVolume: function() {return this.context && "function" === typeof this.context.getVolume ? this.context.getVolume() : 1},setVolume: function(b) {return this.context && "function" === typeof this.context.setVolume ? (this.context.setVolume(b), !0) : !1},getCurrentTime: function() {return this.context && "function" === typeof this.context.getCurrentTime ? this.context.getCurrentTime() : 0},setCurrentTime: function(b) {return this.context && "function" === typeof this.context.setCurrentTime ? this.context.setCurrentTime(b) : !1}}
};_getSoundIds: function(b) {if ("undefined" === typeof b) {b = [];for (var c = 0; c < this._sounds.length; c++) b.push(this._sounds[c]._id);return b}return [b]},_refreshBuffer: function(b) {b._node.bufferSource = c.ctx.createBufferSource();b._node.bufferSource.buffer = f[this._src];b._panner ? b._node.bufferSource.connect(b._panner) : b._node.bufferSource.connect(b._node);if (b._node.bufferSource.loop = b._loop) b._node.bufferSource.loopStart = b._start || 0, b._node.bufferSource.loopEnd = b._stop;b._node.bufferSource.playbackRate.setValueAtTime(b._rate, c.ctx.currentTime);return this},_cleanBuffer: function(b) {if (c._scratchBuffer && b.bufferSource) {b.bufferSource.onended = null;b.bufferSource.disconnect(0);try {b.bufferSource.buffer = c._scratchBuffer} catch (d) {}}b.bufferSource = null;return this}};var e = function(b) {this._parent = b;this.init()};e.prototype = {init: function() {var b = this._parent;this._muted = b._muted;this._loop = b._loop;this._volume = b._volume;this._rate = b._rate;this._seek = 0;this._ended = this._paused = !0;this._sprite = "__default";this._id = ++c._counter;b._sounds.push(this);this.create();return this},create: function() {var b = this._parent,d = c._muted || this._muted || this._parent._muted ? 0 : this._volume;b._webAudio ? (this._node = "undefined" === typeof c.ctx.createGain ? c.ctx.createGainNode() : c.ctx.createGain(), this._node.gain.setValueAtTime(d, c.ctx.currentTime), this._node.paused = !0, this._node.connect(c.masterGain)) : (this._node = new Audio, this._errorFn = this._errorListener.bind(this), this._node.addEventListener("error", this._errorFn, !1), this._loadFn = this._loadListener.bind(this), this._node.addEventListener(c._canPlayEvent, this._loadFn, !1), this._node.src = b._src, this._node.preload = "auto", this._node.volume = d * c.volume(), this._node.load());return this},reset: function() {var b = this._parent;this._muted = b._muted;this._loop = b._loop;this._volume = b._volume;this._rate = b._rate;this._rateSeek = this._seek = 0;this._ended = this._paused = !0;this._sprite = "__default";this._id = ++c._counter;return this},_errorListener: function() {this._parent._emit("loaderror", this._id, this._node.error ? this._node.error.code : 0);this._node.removeEventListener("error", this._errorFn, !1)},_loadListener: function() {var b = this._parent;b._duration = Math.ceil(10 * this._node.duration) / 10;0 === Object.keys(b._sprite).length && (b._sprite = {__default: [0, 1E3 * b._duration]});"loaded" !== b._state && (b._state = "loaded", b._emit("load"), b._loadQueue());this._node.removeEventListener(c._canPlayEvent, this._loadFn, !1)}};var f = {},g = function(b, d) {c.ctx.decodeAudioData(b, function(b) {b && 0 < d._sounds.length && (f[d._src] = b, m(d, b))}, function() {d._emit("loaderror", null, "Decoding audio data failed.")})},m = function(b, c) {c && !b._duration && (b._duration = c.duration);0 === Object.keys(b._sprite).length && (b._sprite = {__default: [0, 1E3 * b._duration]});"loaded" !== b._state && (b._state = "loaded", b._emit("load"), b._loadQueue())},l = function() {try {"undefined" !== typeof AudioContext ? c.ctx = new AudioContext : "undefined" !== typeof webkitAudioContext ? c.ctx = new webkitAudioContext : c.usingWebAudio = !1} catch (b) {c.usingWebAudio = !1}var d = /iP(hone|od|ad)/.test(c._navigator && c._navigator.platform),e = c._navigator && c._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/),e = e ? parseInt(e[1], 10) : null;if (d && (e && 9 > e) && (d = /safari/.test(c._navigator && c._navigator.userAgent.toLowerCase()), c._navigator && c._navigator.standalone && !d || c._navigator && !c._navigator.standalone && !d)) c.usingWebAudio = !1;c.usingWebAudio && (c.masterGain = "undefined" === typeof c.ctx.createGain ? c.ctx.createGainNode() : c.ctx.createGain(), c.masterGain.gain.setValueAtTime(c._muted ? 0 : 1, c.ctx.currentTime), c.masterGain.connect(c.ctx.destination));c._setup()};"function" === typeof define && define.amd && define([], function() {return {Howler: c,Howl: d}});"undefined" !== typeof exports && (exports.Howler = c, exports.Howl = d);"undefined" !== typeof window ? (window.HowlerGlobal = b, window.Howler = c, window.Howl = d, window.Sound = e) : "undefined" !== typeof global && (global.HowlerGlobal = b, global.Howler = c, global.Howl = d, global.Sound = e)
})();
(function() {HowlerGlobal.prototype._pos = [0, 0, 0];HowlerGlobal.prototype._orientation = [0, 0, -1, 0, 1, 0];HowlerGlobal.prototype.stereo = function(b) {if (!this.ctx || !this.ctx.listener) return this;for (var c = this._howls.length - 1; 0 <= c; c--) this._howls[c].stereo(b);return this};HowlerGlobal.prototype.pos = function(b, c, d) {if (!this.ctx || !this.ctx.listener) return this;c = "number" !== typeof c ? this._pos[1] : c;d = "number" !== typeof d ? this._pos[2] : d;if ("number" === typeof b) this._pos = [b, c, d], "undefined" !== typeof this.ctx.listener.positionX ? (this.ctx.listener.positionX.setTargetAtTime(this._pos[0], Howler.ctx.currentTime, 0.1), this.ctx.listener.positionY.setTargetAtTime(this._pos[1], Howler.ctx.currentTime, 0.1), this.ctx.listener.positionZ.setTargetAtTime(this._pos[2], Howler.ctx.currentTime, 0.1)) : this.ctx.listener.setPosition(this._pos[0], this._pos[1], this._pos[2]);else return this._pos;return this};HowlerGlobal.prototype.orientation = function(b, c, d, e, j, q) {if (!this.ctx || !this.ctx.listener) return this;var z = this._orientation;c = "number" !== typeof c ? z[1] : c;d = "number" !== typeof d ? z[2] : d;e = "number" !== typeof e ? z[3] : e;j = "number" !== typeof j ? z[4] : j;q = "number" !== typeof q ? z[5] : q;if ("number" === typeof b) this._orientation = [b, c, d, e, j, q], "undefined" !== typeof this.ctx.listener.forwardX ? (this.ctx.listener.forwardX.setTargetAtTime(b, Howler.ctx.currentTime, 0.1), this.ctx.listener.forwardY.setTargetAtTime(c, Howler.ctx.currentTime, 0.1), this.ctx.listener.forwardZ.setTargetAtTime(d, Howler.ctx.currentTime, 0.1), this.ctx.listener.upX.setTargetAtTime(b, Howler.ctx.currentTime, 0.1), this.ctx.listener.upY.setTargetAtTime(c, Howler.ctx.currentTime, 0.1), this.ctx.listener.upZ.setTargetAtTime(d, Howler.ctx.currentTime, 0.1)) : this.ctx.listener.setOrientation(b, c, d, e, j, q);else return z;return this};var b = Howl.prototype.init;Howl.prototype.init = function(c) {this._orientation = c.orientation || [1, 0, 0];this._stereo = c.stereo || null;this._pos = c.pos || null;this._pannerAttr = {coneInnerAngle: "undefined" !== typeof c.coneInnerAngle ? c.coneInnerAngle : 360,coneOuterAngle: "undefined" !== typeof c.coneOuterAngle ? c.coneOuterAngle : 360,coneOuterGain: "undefined" !== typeof c.coneOuterGain ? c.coneOuterGain : 0,distanceModel: "undefined" !== typeof c.distanceModel ? c.distanceModel : "inverse",maxDistance: "undefined" !== typeof c.maxDistance ? c.maxDistance : 1E4,panningModel: "undefined" !== typeof c.panningModel ? c.panningModel : "HRTF",refDistance: "undefined" !== typeof c.refDistance ? c.refDistance : 1,rolloffFactor: "undefined" !== typeof c.rolloffFactor ? c.rolloffFactor : 1};this._onstereo = c.onstereo ? [{fn: c.onstereo}] : [];this._onpos = c.onpos ? [{fn: c.onpos}] : [];this._onorientation = c.onorientation ? [{fn: c.onorientation}] : [];return b.call(this, c)};Howl.prototype.stereo = function(b, c) {var d = this;if (!d._webAudio) return d;if ("loaded" !== d._state) return d._queue.push({event: "stereo",action: function() {d.stereo(b, c)}}), d;var l = "undefined" === typeof Howler.ctx.createStereoPanner ? "spatial" : "stereo";if ("undefined" === typeof c)if ("number" === typeof b) d._stereo = b, d._pos = [b, 0, 0];else return d._stereo;for (var j = d._getSoundIds(c), q = 0; q < j.length; q++) {var z = d._soundById(j[q]);if (z)if ("number" === typeof b) z._stereo = b, z._pos = [b, 0, 0], z._node && (z._pannerAttr.panningModel = "equalpower", (!z._panner || !z._panner.pan) && e(z, l), "spatial" === l ? "undefined" !== typeof z._panner.positionX ? (z._panner.positionX.setValueAtTime(b, Howler.ctx.currentTime), z._panner.positionY.setValueAtTime(0, Howler.ctx.currentTime), z._panner.positionZ.setValueAtTime(0, Howler.ctx.currentTime)) : z._panner.setPosition(b, 0, 0) : z._panner.pan.setValueAtTime(b, Howler.ctx.currentTime)), d._emit("stereo", z._id);else return z._stereo}return d};Howl.prototype.pos = function(b, c, d, l) {var j = this;if (!j._webAudio) return j;if ("loaded" !== j._state) return j._queue.push({event: "pos",action: function() {j.pos(b, c, d, l)}}), j;c = "number" !== typeof c ? 0 : c;d = "number" !== typeof d ? -0.5 : d;if ("undefined" === typeof l)if ("number" === typeof b) j._pos = [b, c, d];else return j._pos;for (var q = j._getSoundIds(l), z = 0; z < q.length; z++) {var y = j._soundById(q[z]);if (y)if ("number" === typeof b) y._pos = [b, c, d], y._node && ((!y._panner || y._panner.pan) && e(y, "spatial"), "undefined" !== typeof y._panner.positionX ? (y._panner.positionX.setValueAtTime(b, Howler.ctx.currentTime), y._panner.positionY.setValueAtTime(c, Howler.ctx.currentTime), y._panner.positionZ.setValueAtTime(d, Howler.ctx.currentTime)) : y._panner.setOrientation(b, c, d)), j._emit("pos", y._id);else return y._pos}return j};Howl.prototype.orientation = function(b, c, d, l) {var j = this;if (!j._webAudio) return j;if ("loaded" !== j._state) return j._queue.push({event: "orientation",action: function() {j.orientation(b, c, d, l)}}), j;c = "number" !== typeof c ? j._orientation[1] : c;d = "number" !== typeof d ? j._orientation[2] : d;if ("undefined" === typeof l)if ("number" === typeof b) j._orientation = [b, c, d];else return j._orientation;for (var q = j._getSoundIds(l), z = 0; z < q.length; z++) {var y = j._soundById(q[z]);if (y)if ("number" === typeof b) y._orientation = [b, c, d], y._node && (y._panner || (y._pos || (y._pos = j._pos || [0, 0, -0.5]), e(y, "spatial")), y._panner.orientationX.setValueAtTime(b, Howler.ctx.currentTime), y._panner.orientationY.setValueAtTime(c, Howler.ctx.currentTime), y._panner.orientationZ.setValueAtTime(d, Howler.ctx.currentTime)), j._emit("orientation", y._id);else return y._orientation}return j};Howl.prototype.pannerAttr = function() {var b = arguments,c, d;if (!this._webAudio) return this;if (0 === b.length) return this._pannerAttr;if (1 === b.length)if ("object" === typeof b[0]) c = b[0], "undefined" === typeof d && (c.pannerAttr || (c.pannerAttr = {coneInnerAngle: c.coneInnerAngle,coneOuterAngle: c.coneOuterAngle,coneOuterGain: c.coneOuterGain,distanceModel: c.distanceModel,maxDistance: c.maxDistance,refDistance: c.refDistance,rolloffFactor: c.rolloffFactor,panningModel: c.panningModel}), this._pannerAttr = {coneInnerAngle: "undefined" !== typeof c.pannerAttr.coneInnerAngle ? c.pannerAttr.coneInnerAngle : this._coneInnerAngle,coneOuterAngle: "undefined" !== typeof c.pannerAttr.coneOuterAngle ? c.pannerAttr.coneOuterAngle : this._coneOuterAngle,coneOuterGain: "undefined" !== typeof c.pannerAttr.coneOuterGain ? c.pannerAttr.coneOuterGain : this._coneOuterGain,distanceModel: "undefined" !== typeof c.pannerAttr.distanceModel ? c.pannerAttr.distanceModel : this._distanceModel,maxDistance: "undefined" !== typeof c.pannerAttr.maxDistance ? c.pannerAttr.maxDistance : this._maxDistance,refDistance: "undefined" !== typeof c.pannerAttr.refDistance ? c.pannerAttr.refDistance : this._refDistance,rolloffFactor: "undefined" !== typeof c.pannerAttr.rolloffFactor ? c.pannerAttr.rolloffFactor : this._rolloffFactor,panningModel: "undefined" !== typeof c.pannerAttr.panningModel ? c.pannerAttr.panningModel : this._panningModel});else return (b = this._soundById(parseInt(b[0], 10))) ? b._pannerAttr : this._pannerAttr;else 2 === b.length && (c = b[0], d = parseInt(b[1], 10));d = this._getSoundIds(d);for (var l = 0; l < d.length; l++)if (b = this._soundById(d[l])) {var j = b._pannerAttr,j = {Number.prototype.toDeg = function() {return 180 * this / Math.PI};Array.prototype.erase = function(b) {for (var c = this.length; c--;) this[c] === b && this.splice(c, 1);return this};Array.prototype.random = function() {return this[Math.floor(Math.random() * this.length)]};Function.prototype.bind = Function.prototype.bind || function(b) {if ("function" !== typeof this) throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var c = Array.prototype.slice.call(arguments, 1),d = this,e = function() {},f = function() {return d.apply(this instanceof e && b ? this : b, c.concat(Array.prototype.slice.call(arguments)))};e.prototype = this.prototype;f.prototype = new e;return f};b.ig = {game: null,debug: null,version: "1.23",global: b,modules: {},resources: [],ready: !1,baked: !1,nocache: "",ua: {},prefix: b.ImpactPrefix || "",lib: "lib/",_current: null,_loadQueue: [],_waitForOnload: 0,$: function(b) {return "#" == b.charAt(0) ? document.getElementById(b.substr(1)) : document.getElementsByTagName(b)},$new: function(b) {return document.createElement(b)},copy: function(b) {if (!b || "object" != typeof b || b instanceof HTMLElement || b instanceof ig.Class) return b;if (b instanceof Array)for (var c = [], d = 0, e = b.length; d < e; d++) c[d] = ig.copy(b[d]);elsefor (d in c = {}, b) c[d] = ig.copy(b[d]);return c},merge: function(b, c) {for (var d in c) {var e = c[d];if ("object" != typeof e || e instanceof HTMLElement || e instanceof ig.Class || null === e) b[d] = e;else {if (!b[d] || "object" != typeof b[d]) b[d] = e instanceof Array ? [] : {};ig.merge(b[d], e)}}return b},ksort: function(b) {if (!b || "object" != typeof b) return [];var c = [],d = [],e;for (e in b) c.push(e);c.sort();for (e = 0; e < c.length; e++) d.push(b[c[e]]);return d},setVendorAttribute: function(b, c, d) {var e = c.charAt(0).toUpperCase() + c.substr(1);b[c] = "undefined" !== typeof b.imageSmoothingEnabled ? b["ms" + e] = b["moz" + e] = b["o" + e] = d : b["ms" + e] = b["moz" + e] = b["webkit" + e] = b["o" + e] = d},getVendorAttribute: function(b, c) {var d = c.charAt(0).toUpperCase() + c.substr(1);return "undefined" !== typeof b.imageSmoothingEnabled ? b[c] || b["ms" + d] || b["moz" + d] || b["o" + d] : b[c] || b["ms" + d] || b["moz" + d] || b["webkit" + d] || b["o" + d]},normalizeVendorAttribute: function(b, c) {var d = ig.getVendorAttribute(b, c);!b[c] && d && (b[c] = d)},getImagePixels: function(b, c, d, e, f) {var g = ig.$new("canvas");g.width = b.width;g.height = b.height;var m = g.getContext("2d");ig.System.SCALE.CRISP(g, m);var E = ig.getVendorAttribute(m, "backingStorePixelRatio") || 1;ig.normalizeVendorAttribute(m, "getImageDataHD");var F = b.width / E,s = b.height / E;g.width = Math.ceil(F);g.height = Math.ceil(s);m.drawImage(b, 0, 0, F, s);return 1 === E ? m.getImageData(c, d, e, f) : m.getImageDataHD(c, d, e, f)},module: function(b) {if (ig._current) throw "Module '" +ig._current.name + "' defines nothing";var e = !1,f = /xyz/.test(function() {xyz}) ? /\bparent\b/ : /.*/,g = 0;b.ig.Class = function() {};var m = function(b) {var c = this.prototype,d = {},e;for (e in b) "function" == typeof b[e] && "function" == typeof c[e] && f.test(b[e]) ? (d[e] = c[e], c[e] = function(b, c) {return function() {var e = this.parent;this.parent = d[b];var f = c.apply(this, arguments);this.parent = e;return f}}(e, b[e])) : c[e] = b[e]};b.ig.Class.extend = function(c) {function d() {if (!e) {if (this.staticInstantiate) {var b = this.staticInstantiate.apply(this, arguments);if (b) return b}for (var c in this) "object" == typeof this[c] && (this[c] = ig.copy(this[c]));this.init && this.init.apply(this, arguments)}return this}var q = this.prototype;e = !0;var z = new this;e = !1;x: c,y: B,nx: y,ny: z};return !0}return !1}});var b = 1 / 3,c = 2 / 3;ig.CollisionMap.defaultTileDef = {5: [0, 1, 1, c, !0],6: [0, c, 1, b, !0],7: [0, b, 1, 0, !0],3: [0, 1, 1, 0.5, !0],4: [0, 0.5, 1, 0, !0],2: [0, 1, 1, 0, !0],10: [0.5, 1, 1, 0, !0],21: [0, 1, 0.5, 0, !0],32: [c, 1, 1, 0, !0],43: [b, 1, c, 0, !0],54: [0, 1, b, 0, !0],27: [0, 0, 1, b, !0],28: [0, b, 1, c, !0],29: [0, c, 1, 1, !0],25: [0, 0, 1, 0.5, !0],26: [0, 0.5, 1, 1, !0],24: [0, 0, 1, 1, !0],11: [0, 0, 0.5, 1, !0],22: [0.5, 0, 1, 1, !0],33: [0, 0, b, 1, !0],44: [b, 0, c, 1, !0],55: [c, 0, 1, 1, !0],16: [1, b, 0, 0, !0],17: [1, c, 0, b, !0],18: [1, 1, 0, c, !0],14: [1, 0.5, 0, 0, !0],15: [1, 1, 0, 0.5, !0],13: [1, 1, 0, 0, !0],8: [0.5, 1, 0, 0, !0],19: [1, 1, 0.5, 0, !0],30: [b, 1, 0, 0, !0],41: [c, 1, b, 0, !0],52: [1, 1, c, 0, !0],38: [1, c, 0, 1, !0],39: [1, b, 0, c, !0],40: [1, 0, 0, b, !0],36: [1, 0.5, 0, 1, !0],37: [1, 0, 0, 0.5, !0],35: [1, 0, 0, 1, !0],9: [1, 0, 0.5, 1, !0],20: [0.5, 0, 0, 1, !0],31: [1, 0, c, 1, !0],42: [c, 0, b, 1, !0],53: [b, 0, 0, 1, !0],12: [0, 0, 1, 0, !1],23: [1, 1, 0, 1, !1],34: [1, 0, 1, 1, !1],45: [0, 1, 0, 0, !1]};ig.CollisionMap.staticNoCollision = {trace: function(b, c, f, g) {return {collision: {x: !1,y: !1,slope: !1},pos: {x: b + f,y: c + g},tile: {x: 0,y: 0}}}}
});
ig.baked = !0;
ig.module("impact.background-map").requires("impact.map", "impact.image").defines(function() {ig.BackgroundMap = ig.Map.extend({tiles: null,scroll: {x: 0,y: 0},distance: 1,repeat: !1,tilesetName: "",foreground: !1,enabled: !0,preRender: !1,preRenderedChunks: null,chunkSize: 512,debugChunks: !1,anims: {},init: function(b, c, d) {this.parent(b, c);this.setTileset(d)},for (var f = 0; f < e; f++) {this.preRenderedChunks[f] = [];for (var g = 0; g < d; g++) this.preRenderedChunks[f][g] = this.preRenderChunk(g, f, g == d - 1 ? b - g * this.chunkSize : this.chunkSize, f == e - 1 ? c - f * this.chunkSize : this.chunkSize)}
接下来就是我们的index.jsp页面啦
<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Insert title here</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta name="viewport" content="initial-scale=1.0001, minimum-scale=1.0001, maximum-scale=1.0001, user-scalable=no, minimal-ui" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<link rel="stylesheet" type="text/css" href="game.css">
<script type="text/javascript" src="game.js"></script><style>
#game{position:fixed;width:100%;padding-bottom:56%;
}
</style>
</head>
<body onload="setTimeout(function(){window.scrollTo(0,1)},1);"><div id="ajaxbar">
<div id="game"><canvas id="canvas"></canvas></div>
<div id="orientate"><img src="media/graphics/orientate/portrait.jpg" /></div>
<div id="play" class="play" onclick=""><img src="media/graphics/splash/mobile/cover-start.jpg" /></div>
</div>
</body>
</html>
然后看一下我们的效果
这个是进入游戏之后我们开始闯关,点击关卡
然后我们在开始游戏,
?!!!
原生JS沙滩足球游戏相关推荐
- 是男人就要坚持30秒:原生JS小游戏
在继之前完成的数个JavaScript demo后,我发现我还没有写过JS小游戏,这次呢,我就来分享一个,非常经典的"是男人就要坚持30s"的小游戏.当然我肯定 is a man, ...
- 原生js小游戏——俄罗斯方块
还记得童年时期的小游戏俄罗斯方块吗?我发现用js就可以写出来 页面效果如下: 具体代码如下: 首先展示css样式: .c {margin: 1px;width: 19px;height: 19px;b ...
- 原生JS 扫雷游戏 自动插旗子 自定义雷区大小 雷数可调
能随机背景颜色自动插旗子自定义雷区大小和难度的扫雷游戏 随机变换雷区颜色,以及其它CSS样式,动画效果全是CSS.点击网页上的元素触发游戏事件打开雷区.如果对于一个方格,其周围未打开的方格恰好全都有雷 ...
- 原生JS实现游戏--棍子英雄(简单版)
游戏思路 1.当棍子的长度落在右边块的左侧到右侧之间,角色向前进,游戏继续: 2.当棍子的长度没有到达右边块的左侧,让角色向前走,走到棍子的末端的时候角色掉下,游戏结束: 3.棍子的长度超出右边块,让 ...
- 听说你想手机玩扫雷?原生JS扫雷游戏
运行效果 操作方法 单击绿色环形按钮即可开局,用任何工具首次点击雷区不会出现游戏失败情况: 点击左侧图标选择工具,选择不同工具点击雷区效果不同: 红旗图标为windows扫雷右击,普通箭头图标为win ...
- 纯原生JS用面向对象class方法实现简易扫雷小游戏
Demo介绍 纯原生js 实现 且用ES6语法class写的扫雷小游戏:布局为10*10的网格,随机生成10-20个雷. 左键点击扫雷.右键标记该地方有雷.该demo下载下来复制到html文件中直接可 ...
- 原生JS实现拼图游戏
前面的话 练习了10几个原生js小游戏的案例,刚开始是无从下手,而现在有了自己的思路,不再觉得那么的难了.总结起来,还是那句话,"好的代码是时间熬出来的,多练是硬道理!",这篇文章 ...
- eclipse javascript_原生js实现贪吃蛇游戏_javascript技巧
更新时间:2020年10月26日 11:46:36 作者:leisure-ZL 这篇文章主要为大家详细介绍了原生js实现贪吃蛇小游戏,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴 ...
- 原生html小游戏,原生JS实现别踩白块小游戏(一)
对于前端开发人员来说,闲暇之余自己开发个小游戏打发时间,也是对自己基础技术的一种应用考验.那么别踩白块小游戏,相信大家并不陌生,这个小游戏我们可以通过原生js来实现,即便是前端初学者也可以轻松完成. ...
最新文章
- 服务器性能优化的正确姿势
- 【转载】关于RabbitMQ的消息确认
- 一生中需要的10种人脉
- Java中Map的使用
- 装配组件_基于Haption力反馈系统的交互式装配仿真
- mysql盲注ascii_[翻译]关于通过对8bit的ascii做右位移提高mysql盲注效率
- 频率分布直方图组距如何确定_频率分布有关的概念
- 尼姑一般怎么自称_电池又一重大事故!选铅酸,还是锂电?听听电池老师傅怎么说!...
- CocoaPods安装记录
- 各种常见排序算法的时间/空间复杂度 是否稳定 算法选取的情况 改进 思维导图整理
- matlab双闭环绘图,matlab双闭环直流调速系统设计及仿真+电路图
- 机器学习基础线性回归——预测网店的销售额
- 企业微信重磅更新!离职继承无需客户同意、群自动踢人、群成员去重...
- Python报错记录之“list indices must be integers or slices, not str”
- 嵌入式linux开发,.mak是什么文件
- MySQL优化之hints
- 微处理器常见问题及解答
- 电脑计算机怎么没有桌面显示,登陆qq后电脑桌面没有显示怎么做
- Android 绘制电池图标
- Windows环境下修改redis默认端口和密码,以及启动方式