commit 527bf773d425c9877990fe818254a3bd69f16f80 Author: Shihaam Abdul Rahman Date: Sat Nov 16 17:47:22 2024 +0500 im not proud of this diff --git a/README.md b/README.md new file mode 100644 index 0000000..406e02c --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ + +## Run with docker run command +``` +docker run -d -p 8000:8000 git.shihaam.me/shihaam/911 +``` +## or with docker compose +```yaml +services: + nineeleven: + image: git.shihaam.me/shihaam/911 + ports: + - "8000:8000" +``` diff --git a/assets/bird.png b/assets/bird.png new file mode 100644 index 0000000..213c738 Binary files /dev/null and b/assets/bird.png differ diff --git a/assets/ceiling.png b/assets/ceiling.png new file mode 100644 index 0000000..c4ec546 Binary files /dev/null and b/assets/ceiling.png differ diff --git a/assets/explosion.png b/assets/explosion.png new file mode 100644 index 0000000..6a70a07 Binary files /dev/null and b/assets/explosion.png differ diff --git a/assets/font_big_0.png b/assets/font_big_0.png new file mode 100644 index 0000000..894e22d Binary files /dev/null and b/assets/font_big_0.png differ diff --git a/assets/font_big_1.png b/assets/font_big_1.png new file mode 100644 index 0000000..d05a684 Binary files /dev/null and b/assets/font_big_1.png differ diff --git a/assets/font_big_2.png b/assets/font_big_2.png new file mode 100644 index 0000000..4c541ee Binary files /dev/null and b/assets/font_big_2.png differ diff --git a/assets/font_big_3.png b/assets/font_big_3.png new file mode 100644 index 0000000..634fd5f Binary files /dev/null and b/assets/font_big_3.png differ diff --git a/assets/font_big_4.png b/assets/font_big_4.png new file mode 100644 index 0000000..ddaeef6 Binary files /dev/null and b/assets/font_big_4.png differ diff --git a/assets/font_big_5.png b/assets/font_big_5.png new file mode 100644 index 0000000..8ac9c8a Binary files /dev/null and b/assets/font_big_5.png differ diff --git a/assets/font_big_6.png b/assets/font_big_6.png new file mode 100644 index 0000000..4b18cf1 Binary files /dev/null and b/assets/font_big_6.png differ diff --git a/assets/font_big_7.png b/assets/font_big_7.png new file mode 100644 index 0000000..de96aa3 Binary files /dev/null and b/assets/font_big_7.png differ diff --git a/assets/font_big_8.png b/assets/font_big_8.png new file mode 100644 index 0000000..cb78094 Binary files /dev/null and b/assets/font_big_8.png differ diff --git a/assets/font_big_9.png b/assets/font_big_9.png new file mode 100644 index 0000000..4723fe5 Binary files /dev/null and b/assets/font_big_9.png differ diff --git a/assets/font_small_0.png b/assets/font_small_0.png new file mode 100644 index 0000000..a148e6c Binary files /dev/null and b/assets/font_small_0.png differ diff --git a/assets/font_small_1.png b/assets/font_small_1.png new file mode 100644 index 0000000..14e23d8 Binary files /dev/null and b/assets/font_small_1.png differ diff --git a/assets/font_small_2.png b/assets/font_small_2.png new file mode 100644 index 0000000..d742784 Binary files /dev/null and b/assets/font_small_2.png differ diff --git a/assets/font_small_3.png b/assets/font_small_3.png new file mode 100644 index 0000000..da7ec28 Binary files /dev/null and b/assets/font_small_3.png differ diff --git a/assets/font_small_4.png b/assets/font_small_4.png new file mode 100644 index 0000000..2ebd7d2 Binary files /dev/null and b/assets/font_small_4.png differ diff --git a/assets/font_small_5.png b/assets/font_small_5.png new file mode 100644 index 0000000..237639c Binary files /dev/null and b/assets/font_small_5.png differ diff --git a/assets/font_small_6.png b/assets/font_small_6.png new file mode 100644 index 0000000..33db0ef Binary files /dev/null and b/assets/font_small_6.png differ diff --git a/assets/font_small_7.png b/assets/font_small_7.png new file mode 100644 index 0000000..808fad9 Binary files /dev/null and b/assets/font_small_7.png differ diff --git a/assets/font_small_8.png b/assets/font_small_8.png new file mode 100644 index 0000000..9bb457f Binary files /dev/null and b/assets/font_small_8.png differ diff --git a/assets/font_small_9.png b/assets/font_small_9.png new file mode 100644 index 0000000..bb62d0d Binary files /dev/null and b/assets/font_small_9.png differ diff --git a/assets/land.png b/assets/land.png new file mode 100644 index 0000000..dd5ae4b Binary files /dev/null and b/assets/land.png differ diff --git a/assets/medal_bronze.png b/assets/medal_bronze.png new file mode 100644 index 0000000..1be1ff1 Binary files /dev/null and b/assets/medal_bronze.png differ diff --git a/assets/medal_gold.png b/assets/medal_gold.png new file mode 100644 index 0000000..a59a903 Binary files /dev/null and b/assets/medal_gold.png differ diff --git a/assets/medal_platinum.png b/assets/medal_platinum.png new file mode 100644 index 0000000..fe0a0db Binary files /dev/null and b/assets/medal_platinum.png differ diff --git a/assets/medal_silver.png b/assets/medal_silver.png new file mode 100644 index 0000000..f3630de Binary files /dev/null and b/assets/medal_silver.png differ diff --git a/assets/pipe-down.png b/assets/pipe-down.png new file mode 100644 index 0000000..829a94e Binary files /dev/null and b/assets/pipe-down.png differ diff --git a/assets/pipe-up.png b/assets/pipe-up.png new file mode 100644 index 0000000..3ee76b6 Binary files /dev/null and b/assets/pipe-up.png differ diff --git a/assets/pipe.png b/assets/pipe.png new file mode 100644 index 0000000..35b8847 Binary files /dev/null and b/assets/pipe.png differ diff --git a/assets/plane.png b/assets/plane.png new file mode 100644 index 0000000..7a121fd Binary files /dev/null and b/assets/plane.png differ diff --git a/assets/replay.png b/assets/replay.png new file mode 100644 index 0000000..47a4a85 Binary files /dev/null and b/assets/replay.png differ diff --git a/assets/scoreboard.png b/assets/scoreboard.png new file mode 100644 index 0000000..3ca5dff Binary files /dev/null and b/assets/scoreboard.png differ diff --git a/assets/sky.png b/assets/sky.png new file mode 100644 index 0000000..c3e281b Binary files /dev/null and b/assets/sky.png differ diff --git a/assets/sounds/nasheed.mp3 b/assets/sounds/nasheed.mp3 new file mode 100644 index 0000000..5ca0d23 Binary files /dev/null and b/assets/sounds/nasheed.mp3 differ diff --git a/assets/sounds/nasheed.ogg b/assets/sounds/nasheed.ogg new file mode 100644 index 0000000..7726bd7 Binary files /dev/null and b/assets/sounds/nasheed.ogg differ diff --git a/assets/sounds/sfx_die.mp3 b/assets/sounds/sfx_die.mp3 new file mode 100644 index 0000000..4140cb8 Binary files /dev/null and b/assets/sounds/sfx_die.mp3 differ diff --git a/assets/sounds/sfx_die.ogg b/assets/sounds/sfx_die.ogg new file mode 100644 index 0000000..a980e92 Binary files /dev/null and b/assets/sounds/sfx_die.ogg differ diff --git a/assets/sounds/sfx_hit.mp3 b/assets/sounds/sfx_hit.mp3 new file mode 100644 index 0000000..cb25eca Binary files /dev/null and b/assets/sounds/sfx_hit.mp3 differ diff --git a/assets/sounds/sfx_hit.ogg b/assets/sounds/sfx_hit.ogg new file mode 100644 index 0000000..8dc6ff0 Binary files /dev/null and b/assets/sounds/sfx_hit.ogg differ diff --git a/assets/sounds/sfx_point.mp3 b/assets/sounds/sfx_point.mp3 new file mode 100644 index 0000000..b136ba7 Binary files /dev/null and b/assets/sounds/sfx_point.mp3 differ diff --git a/assets/sounds/sfx_point.ogg b/assets/sounds/sfx_point.ogg new file mode 100644 index 0000000..efb2d99 Binary files /dev/null and b/assets/sounds/sfx_point.ogg differ diff --git a/assets/sounds/sfx_swooshing.mp3 b/assets/sounds/sfx_swooshing.mp3 new file mode 100644 index 0000000..ea142b1 Binary files /dev/null and b/assets/sounds/sfx_swooshing.mp3 differ diff --git a/assets/sounds/sfx_swooshing.ogg b/assets/sounds/sfx_swooshing.ogg new file mode 100644 index 0000000..f483cd6 Binary files /dev/null and b/assets/sounds/sfx_swooshing.ogg differ diff --git a/assets/sounds/sfx_wing.mp3 b/assets/sounds/sfx_wing.mp3 new file mode 100644 index 0000000..b448517 Binary files /dev/null and b/assets/sounds/sfx_wing.mp3 differ diff --git a/assets/sounds/sfx_wing.ogg b/assets/sounds/sfx_wing.ogg new file mode 100644 index 0000000..76e3a2a Binary files /dev/null and b/assets/sounds/sfx_wing.ogg differ diff --git a/assets/splash.png b/assets/splash.png new file mode 100644 index 0000000..1c321df Binary files /dev/null and b/assets/splash.png differ diff --git a/assets/thumb.png b/assets/thumb.png new file mode 100644 index 0000000..6a2fcf6 Binary files /dev/null and b/assets/thumb.png differ diff --git a/css/main.css b/css/main.css new file mode 100644 index 0000000..073a870 --- /dev/null +++ b/css/main.css @@ -0,0 +1,402 @@ +@-webkit-keyframes animLand { + 0% { background-position: 0px 0px; } + 100% { background-position: -335px 0px; } +} +@-moz-keyframes animLand { + 0% { background-position: 0px 0px; } + 100% { background-position: -335px 0px; } +} +@-o-keyframes animLand { + 0% { background-position: 0px 0px; } + 100% { background-position: -335px 0px; } +} +@keyframes animLand { + 0% { background-position: 0px 0px; } + 100% { background-position: -335px 0px; } +} + +@-webkit-keyframes animSky { + 0% { background-position: 0px 100%; } + 100% { background-position: -275px 100%; } +} +@-moz-keyframes animSky { + 0% { background-position: 0px 100%; } + 100% { background-position: -275px 100%; } +} +@-o-keyframes animSky { + 0% { background-position: 0px 100%; } + 100% { background-position: -275px 100%; } +} +@keyframes animSky { + 0% { background-position: 0px 100%; } + 100% { background-position: -275px 100%; } +} + +@-webkit-keyframes animBird { + from { background-position: 0px 0px; } + to { background-position: 0px -96px; } +} +@-moz-keyframes animBird { + from { background-position: 0px 0px; } + to { background-position: 0px -96px; } +} +@-o-keyframes animBird { + from { background-position: 0px 0px; } + to { background-position: 0px -96px; } +} +@keyframes animBird { + from { background-position: 0px 0px; } + to { background-position: 0px -96px; } +} + +@-webkit-keyframes animPipe { + 0% { left: 900px; } + 100% { left: -100px; } +} +@-moz-keyframes animPipe { + 0% { left: 900px; } + 100% { left: -100px; } +} +@-o-keyframes animPipe { + 0% { left: 900px; } + 100% { left: -100px; } +} +@keyframes animPipe { + 0% { left: 900px; } + 100% { left: -100px; } +} + +@-webkit-keyframes animCeiling { + 0% { background-position: 0px 0px; } + 100% { background-position: -63px 0px; } +} +@-moz-keyframes animCeiling { + 0% { background-position: 0px 0px; } + 100% { background-position: -63px 0px; } +} +@-o-keyframes animCeiling { + 0% { background-position: 0px 0px; } + 100% { background-position: -63px 0px; } +} +@keyframes animCeiling { + 0% { background-position: 0px 0px; } + 100% { background-position: -63px 0px; } +} + + +*, +*:before, +*:after +{ + /* border box */ + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + box-sizing: border-box; + /* gpu acceleration */ + -webkit-transition: translate3d(0,0,0); + /* select disable */ + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +html, +body +{ + height: 100%; + overflow: hidden; + font-family: monospace; + font-size: 12px; + color: #fff; + background:#111; +} + + +#gamecontainer +{ + position: relative; + width: 100%; + height: 100%; + min-height: 525px; +} +@media (min-width: 1025px){ + #gamecontainer + { + width:500px; + overflow:hidden; + margin:0 auto; + } +} + +/* +Screen - Game +*/ +#gamescreen +{ + position: absolute; + width: 100%; + height: 100%; +} + +#sky +{ + position: absolute; + top: 0; + width: 100%; + height: 80%; + background-image: url('../assets/sky.png'); + background-repeat: repeat-x; + background-position: 0px 100%; + background-color: #426dbd; + + -webkit-animation: animSky 7s linear infinite; + animation: animSky 7s linear infinite; +} + +#flyarea +{ + position: absolute; + bottom: 0; + height: 420px; + width: 100%; +} + +#ceiling +{ + position: absolute; + top: -16px; + height: 16px; + width: 100%; + background-image: url('../assets/ceiling.png'); + background-repeat: repeat-x; + + -webkit-animation: animCeiling 481ms linear infinite; + animation: animCeiling 481ms linear infinite; +} + +#land +{ + position: absolute; + bottom: 0; + width: 100%; + height: 20%; + background-image: url('../assets/land.png'); + background-repeat: repeat-x; + background-position: 0px 0px; + background-color: #0f2641; + + -webkit-animation: animLand 2516ms linear infinite; + animation: animLand 2516ms linear infinite; +} + +#bigscore +{ + position: absolute; + top: 20px; + left: 50%; + margin-left:-20px; + z-index: 100; +} + +#bigscore img +{ + display: inline-block; + padding: 1px; +} + +#splash +{ + position: absolute; + opacity: 0; + top: 75px; + left: 50%; + margin-left:-94px; + width: 188px; + height: 170px; + background-image: url('../assets/splash.png'); + background-repeat: no-repeat; +} + +#scoreboard +{ + position: absolute; + display: none; + opacity: 0; + top: 64px; + left: 50%; + margin-left:-119px; + width: 236px; + height: 280px; + background-image: url('../assets/scoreboard.png'); + background-repeat: no-repeat; + + z-index: 1000; +} + +#medal +{ + position: absolute; + opacity: 0; + top: 114px; + left: 32px; + width: 44px; + height: 44px; +} + +#currentscore +{ + position: absolute; + top: 105px; + left: 107px; + width: 104px; + height: 14px; + text-align: right; +} + +#currentscore img +{ + padding-left: 2px; +} + +#highscore +{ + position: absolute; + top: 147px; + left: 107px; + width: 104px; + height: 14px; + text-align: right; +} + +#highscore img +{ + padding-left: 2px; +} + +#replay +{ + position: absolute; + opacity: 0; + top: 205px; + left: 61px; + height: 115px; + width: 70px; + cursor: pointer; +} + +.boundingbox +{ + position: absolute; + display: none; + top: 0; + left: 0; + width: 0; + height: 0; + border: 1px solid red; +} + +#player +{ + left: 60px; + top: 200px; +} + +.bird +{ + position: absolute; + width: 93px; + height: 24px; + background-image: url('../assets/bird.png'); + background-image: url('../assets/plane.png'); + + -webkit-animation: animBird 300ms steps(4) infinite; + animation: animBird 300ms steps(4) infinite; +} + +.pipe +{ + position: absolute; + left: -100px; + width: 52px; + height: 100%; + z-index: 10; + + -webkit-animation: animPipe 7500ms linear; + animation: animPipe 7500ms linear; +} + +.pipe_upper +{ + position: absolute; + top: 0; + width: 52px; + background-image: url('../assets/pipe.png'); + background-repeat: repeat-y; + background-position: center; +} + +.pipe_upper:after +{ + content: ""; + position: absolute; + bottom: 0; + width: 52px; + height: 22px; + background-image: url('../assets/pipe-down.png'); +} + +.pipe_lower +{ + position: absolute; + bottom: 0; + width: 52px; + background-image: url('../assets/pipe.png'); + background-repeat: repeat-y; + background-position: center; +} + +.pipe_lower:after +{ + content: ""; + position: absolute; + top: 0; + width: 52px; + height: 22px; + background-image: url('../assets/pipe-up.png'); +} + +#footer +{ + position: absolute; + bottom: 3px; + left: 3px; +} + +#footer a, +#footer a:link, +#footer a:visited, +#footer a:hover, +#footer a:active +{ + display: block; + padding: 2px; + text-decoration: none; + color: #fff; +} + + + + +
+
+
+
+ +
+ +
+ +
+ +
+
+
+
+
replay
+
+ + +
+
+
+
+ + +
+
+ + + + + + + + + diff --git a/js/buzz.min.js b/js/buzz.min.js new file mode 100644 index 0000000..556ce76 --- /dev/null +++ b/js/buzz.min.js @@ -0,0 +1,11 @@ + // ---------------------------------------------------------------------------- + // Buzz, a Javascript HTML5 Audio library + // v1.1.0 - released 2013-08-15 13:18 + // Licensed under the MIT license. + // http://buzz.jaysalvat.com/ + // ---------------------------------------------------------------------------- + // Copyright (C) 2010-2013 Jay Salvat + // http://jaysalvat.com/ + // ---------------------------------------------------------------------------- + +(function(t,n,e){"undefined"!=typeof module&&module.exports?module.exports=e():"function"==typeof n.define&&n.define.amd?define(t,[],e):n[t]=e()})("buzz",this,function(){var t={defaults:{autoplay:!1,duration:5e3,formats:[],loop:!1,placeholder:"--",preload:"metadata",volume:80,document:document},types:{mp3:"audio/mpeg",ogg:"audio/ogg",wav:"audio/wav",aac:"audio/aac",m4a:"audio/x-m4a"},sounds:[],el:document.createElement("audio"),sound:function(n,e){function i(t){for(var n=[],e=t.length-1,i=0;e>=i;i++)n.push({start:t.start(i),end:t.end(i)});return n}function u(t){return t.split(".").pop()}function s(n,e){var i=r.createElement("source");i.src=e,t.types[u(e)]&&(i.type=t.types[u(e)]),n.appendChild(i)}e=e||{};var r=e.document||t.defaults.document,o=0,a=[],h={},l=t.isSupported();if(this.load=function(){return l?(this.sound.load(),this):this},this.play=function(){return l?(this.sound.play(),this):this},this.togglePlay=function(){return l?(this.sound.paused?this.sound.play():this.sound.pause(),this):this},this.pause=function(){return l?(this.sound.pause(),this):this},this.isPaused=function(){return l?this.sound.paused:null},this.stop=function(){return l?(this.setTime(0),this.sound.pause(),this):this},this.isEnded=function(){return l?this.sound.ended:null},this.loop=function(){return l?(this.sound.loop="loop",this.bind("ended.buzzloop",function(){this.currentTime=0,this.play()}),this):this},this.unloop=function(){return l?(this.sound.removeAttribute("loop"),this.unbind("ended.buzzloop"),this):this},this.mute=function(){return l?(this.sound.muted=!0,this):this},this.unmute=function(){return l?(this.sound.muted=!1,this):this},this.toggleMute=function(){return l?(this.sound.muted=!this.sound.muted,this):this},this.isMuted=function(){return l?this.sound.muted:null},this.setVolume=function(t){return l?(0>t&&(t=0),t>100&&(t=100),this.volume=t,this.sound.volume=t/100,this):this},this.getVolume=function(){return l?this.volume:this},this.increaseVolume=function(t){return this.setVolume(this.volume+(t||1))},this.decreaseVolume=function(t){return this.setVolume(this.volume-(t||1))},this.setTime=function(t){if(!l)return this;var n=!0;return this.whenReady(function(){n===!0&&(n=!1,this.sound.currentTime=t)}),this},this.getTime=function(){if(!l)return null;var n=Math.round(100*this.sound.currentTime)/100;return isNaN(n)?t.defaults.placeholder:n},this.setPercent=function(n){return l?this.setTime(t.fromPercent(n,this.sound.duration)):this},this.getPercent=function(){if(!l)return null;var n=Math.round(t.toPercent(this.sound.currentTime,this.sound.duration));return isNaN(n)?t.defaults.placeholder:n},this.setSpeed=function(t){return l?(this.sound.playbackRate=t,this):this},this.getSpeed=function(){return l?this.sound.playbackRate:null},this.getDuration=function(){if(!l)return null;var n=Math.round(100*this.sound.duration)/100;return isNaN(n)?t.defaults.placeholder:n},this.getPlayed=function(){return l?i(this.sound.played):null},this.getBuffered=function(){return l?i(this.sound.buffered):null},this.getSeekable=function(){return l?i(this.sound.seekable):null},this.getErrorCode=function(){return l&&this.sound.error?this.sound.error.code:0},this.getErrorMessage=function(){if(!l)return null;switch(this.getErrorCode()){case 1:return"MEDIA_ERR_ABORTED";case 2:return"MEDIA_ERR_NETWORK";case 3:return"MEDIA_ERR_DECODE";case 4:return"MEDIA_ERR_SRC_NOT_SUPPORTED";default:return null}},this.getStateCode=function(){return l?this.sound.readyState:null},this.getStateMessage=function(){if(!l)return null;switch(this.getStateCode()){case 0:return"HAVE_NOTHING";case 1:return"HAVE_METADATA";case 2:return"HAVE_CURRENT_DATA";case 3:return"HAVE_FUTURE_DATA";case 4:return"HAVE_ENOUGH_DATA";default:return null}},this.getNetworkStateCode=function(){return l?this.sound.networkState:null},this.getNetworkStateMessage=function(){if(!l)return null;switch(this.getNetworkStateCode()){case 0:return"NETWORK_EMPTY";case 1:return"NETWORK_IDLE";case 2:return"NETWORK_LOADING";case 3:return"NETWORK_NO_SOURCE";default:return null}},this.set=function(t,n){return l?(this.sound[t]=n,this):this},this.get=function(t){return l?t?this.sound[t]:this.sound:null},this.bind=function(t,n){if(!l)return this;t=t.split(" ");for(var e=this,i=function(t){n.call(e,t)},u=0;t.length>u;u++){var s=t[u],r=s;s=r.split(".")[0],a.push({idx:r,func:i}),this.sound.addEventListener(s,i,!0)}return this},this.unbind=function(t){if(!l)return this;t=t.split(" ");for(var n=0;t.length>n;n++)for(var e=t[n],i=e.split(".")[0],u=0;a.length>u;u++){var s=a[u].idx.split(".");(a[u].idx==e||s[1]&&s[1]==e.replace(".",""))&&(this.sound.removeEventListener(i,a[u].func,!0),a.splice(u,1))}return this},this.bindOnce=function(t,n){if(!l)return this;var e=this;return h[o++]=!1,this.bind(t+"."+o,function(){h[o]||(h[o]=!0,n.call(e)),e.unbind(t+"."+o)}),this},this.trigger=function(t){if(!l)return this;t=t.split(" ");for(var n=0;t.length>n;n++)for(var e=t[n],i=0;a.length>i;i++){var u=a[i].idx.split(".");if(a[i].idx==e||u[0]&&u[0]==e.replace(".","")){var s=r.createEvent("HTMLEvents");s.initEvent(u[0],!1,!0),this.sound.dispatchEvent(s)}}return this},this.fadeTo=function(n,e,i){function u(){setTimeout(function(){n>s&&n>o.volume?(o.setVolume(o.volume+=1),u()):s>n&&o.volume>n?(o.setVolume(o.volume-=1),u()):i instanceof Function&&i.apply(o)},r)}if(!l)return this;e instanceof Function?(i=e,e=t.defaults.duration):e=e||t.defaults.duration;var s=this.volume,r=e/Math.abs(s-n),o=this;return this.play(),this.whenReady(function(){u()}),this},this.fadeIn=function(t,n){return l?this.setVolume(0).fadeTo(100,t,n):this},this.fadeOut=function(t,n){return l?this.fadeTo(0,t,n):this},this.fadeWith=function(t,n){return l?(this.fadeOut(n,function(){this.stop()}),t.play().fadeIn(n),this):this},this.whenReady=function(t){if(!l)return null;var n=this;0===this.sound.readyState?this.bind("canplay.buzzwhenready",function(){t.call(n)}):t.call(n)},l&&n){for(var d in t.defaults)t.defaults.hasOwnProperty(d)&&(e[d]=e[d]||t.defaults[d]);if(this.sound=r.createElement("audio"),n instanceof Array)for(var c in n)n.hasOwnProperty(c)&&s(this.sound,n[c]);else if(e.formats.length)for(var f in e.formats)e.formats.hasOwnProperty(f)&&s(this.sound,n+"."+e.formats[f]);else s(this.sound,n);e.loop&&this.loop(),e.autoplay&&(this.sound.autoplay="autoplay"),this.sound.preload=e.preload===!0?"auto":e.preload===!1?"none":e.preload,this.setVolume(e.volume),t.sounds.push(this)}},group:function(t){function n(){for(var n=e(null,arguments),i=n.shift(),u=0;t.length>u;u++)t[u][i].apply(t[u],n)}function e(t,n){return t instanceof Array?t:Array.prototype.slice.call(n)}t=e(t,arguments),this.getSounds=function(){return t},this.add=function(n){n=e(n,arguments);for(var i=0;n.length>i;i++)t.push(n[i])},this.remove=function(n){n=e(n,arguments);for(var i=0;n.length>i;i++)for(var u=0;t.length>u;u++)if(t[u]==n[i]){t.splice(u,1);break}},this.load=function(){return n("load"),this},this.play=function(){return n("play"),this},this.togglePlay=function(){return n("togglePlay"),this},this.pause=function(t){return n("pause",t),this},this.stop=function(){return n("stop"),this},this.mute=function(){return n("mute"),this},this.unmute=function(){return n("unmute"),this},this.toggleMute=function(){return n("toggleMute"),this},this.setVolume=function(t){return n("setVolume",t),this},this.increaseVolume=function(t){return n("increaseVolume",t),this},this.decreaseVolume=function(t){return n("decreaseVolume",t),this},this.loop=function(){return n("loop"),this},this.unloop=function(){return n("unloop"),this},this.setTime=function(t){return n("setTime",t),this},this.set=function(t,e){return n("set",t,e),this},this.bind=function(t,e){return n("bind",t,e),this},this.unbind=function(t){return n("unbind",t),this},this.bindOnce=function(t,e){return n("bindOnce",t,e),this},this.trigger=function(t){return n("trigger",t),this},this.fade=function(t,e,i,u){return n("fade",t,e,i,u),this},this.fadeIn=function(t,e){return n("fadeIn",t,e),this},this.fadeOut=function(t,e){return n("fadeOut",t,e),this}},all:function(){return new t.group(t.sounds)},isSupported:function(){return!!t.el.canPlayType},isOGGSupported:function(){return!!t.el.canPlayType&&t.el.canPlayType('audio/ogg; codecs="vorbis"')},isWAVSupported:function(){return!!t.el.canPlayType&&t.el.canPlayType('audio/wav; codecs="1"')},isMP3Supported:function(){return!!t.el.canPlayType&&t.el.canPlayType("audio/mpeg;")},isAACSupported:function(){return!!t.el.canPlayType&&(t.el.canPlayType("audio/x-m4a;")||t.el.canPlayType("audio/aac;"))},toTimer:function(t,n){var e,i,u;return e=Math.floor(t/3600),e=isNaN(e)?"--":e>=10?e:"0"+e,i=n?Math.floor(t/60%60):Math.floor(t/60),i=isNaN(i)?"--":i>=10?i:"0"+i,u=Math.floor(t%60),u=isNaN(u)?"--":u>=10?u:"0"+u,n?e+":"+i+":"+u:i+":"+u},fromTimer:function(t){var n=(""+t).split(":");return n&&3==n.length&&(t=3600*parseInt(n[0],10)+60*parseInt(n[1],10)+parseInt(n[2],10)),n&&2==n.length&&(t=60*parseInt(n[0],10)+parseInt(n[1],10)),t},toPercent:function(t,n,e){var i=Math.pow(10,e||0);return Math.round(100*t/n*i)/i},fromPercent:function(t,n,e){var i=Math.pow(10,e||0);return Math.round(n/100*t*i)/i}};return t}); \ No newline at end of file diff --git a/js/jquery.transit.min.js b/js/jquery.transit.min.js new file mode 100644 index 0000000..71e0b06 --- /dev/null +++ b/js/jquery.transit.min.js @@ -0,0 +1,9 @@ +/*! + * jQuery Transit - CSS3 transitions and transformations + * (c) 2011-2012 Rico Sta. Cruz + * MIT Licensed. + * + * http://ricostacruz.com/jquery.transit + * http://github.com/rstacruz/jquery.transit + */ +(function(k){k.transit={version:"0.9.9",propertyMap:{marginLeft:"margin",marginRight:"margin",marginBottom:"margin",marginTop:"margin",paddingLeft:"padding",paddingRight:"padding",paddingBottom:"padding",paddingTop:"padding"},enabled:true,useTransitionEnd:false};var d=document.createElement("div");var q={};function b(v){if(v in d.style){return v}var u=["Moz","Webkit","O","ms"];var r=v.charAt(0).toUpperCase()+v.substr(1);if(v in d.style){return v}for(var t=0;t-1;q.transition=b("transition");q.transitionDelay=b("transitionDelay");q.transform=b("transform");q.transformOrigin=b("transformOrigin");q.transform3d=e();var i={transition:"transitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd",WebkitTransition:"webkitTransitionEnd",msTransition:"MSTransitionEnd"};var f=q.transitionEnd=i[q.transition]||null;for(var p in q){if(q.hasOwnProperty(p)&&typeof k.support[p]==="undefined"){k.support[p]=q[p]}}d=null;k.cssEase={_default:"ease","in":"ease-in",out:"ease-out","in-out":"ease-in-out",snap:"cubic-bezier(0,1,.5,1)",easeOutCubic:"cubic-bezier(.215,.61,.355,1)",easeInOutCubic:"cubic-bezier(.645,.045,.355,1)",easeInCirc:"cubic-bezier(.6,.04,.98,.335)",easeOutCirc:"cubic-bezier(.075,.82,.165,1)",easeInOutCirc:"cubic-bezier(.785,.135,.15,.86)",easeInExpo:"cubic-bezier(.95,.05,.795,.035)",easeOutExpo:"cubic-bezier(.19,1,.22,1)",easeInOutExpo:"cubic-bezier(1,0,0,1)",easeInQuad:"cubic-bezier(.55,.085,.68,.53)",easeOutQuad:"cubic-bezier(.25,.46,.45,.94)",easeInOutQuad:"cubic-bezier(.455,.03,.515,.955)",easeInQuart:"cubic-bezier(.895,.03,.685,.22)",easeOutQuart:"cubic-bezier(.165,.84,.44,1)",easeInOutQuart:"cubic-bezier(.77,0,.175,1)",easeInQuint:"cubic-bezier(.755,.05,.855,.06)",easeOutQuint:"cubic-bezier(.23,1,.32,1)",easeInOutQuint:"cubic-bezier(.86,0,.07,1)",easeInSine:"cubic-bezier(.47,0,.745,.715)",easeOutSine:"cubic-bezier(.39,.575,.565,1)",easeInOutSine:"cubic-bezier(.445,.05,.55,.95)",easeInBack:"cubic-bezier(.6,-.28,.735,.045)",easeOutBack:"cubic-bezier(.175, .885,.32,1.275)",easeInOutBack:"cubic-bezier(.68,-.55,.265,1.55)"};k.cssHooks["transit:transform"]={get:function(r){return k(r).data("transform")||new j()},set:function(s,r){var t=r;if(!(t instanceof j)){t=new j(t)}if(q.transform==="WebkitTransform"&&!a){s.style[q.transform]=t.toString(true)}else{s.style[q.transform]=t.toString()}k(s).data("transform",t)}};k.cssHooks.transform={set:k.cssHooks["transit:transform"].set};if(k.fn.jquery<"1.8"){k.cssHooks.transformOrigin={get:function(r){return r.style[q.transformOrigin]},set:function(r,s){r.style[q.transformOrigin]=s}};k.cssHooks.transition={get:function(r){return r.style[q.transition]},set:function(r,s){r.style[q.transition]=s}}}n("scale");n("translate");n("rotate");n("rotateX");n("rotateY");n("rotate3d");n("perspective");n("skewX");n("skewY");n("x",true);n("y",true);function j(r){if(typeof r==="string"){this.parse(r)}return this}j.prototype={setFromString:function(t,s){var r=(typeof s==="string")?s.split(","):(s.constructor===Array)?s:[s];r.unshift(t);j.prototype.set.apply(this,r)},set:function(s){var r=Array.prototype.slice.apply(arguments,[1]);if(this.setter[s]){this.setter[s].apply(this,r)}else{this[s]=r.join(",")}},get:function(r){if(this.getter[r]){return this.getter[r].apply(this)}else{return this[r]||0}},setter:{rotate:function(r){this.rotate=o(r,"deg")},rotateX:function(r){this.rotateX=o(r,"deg")},rotateY:function(r){this.rotateY=o(r,"deg")},scale:function(r,s){if(s===undefined){s=r}this.scale=r+","+s},skewX:function(r){this.skewX=o(r,"deg")},skewY:function(r){this.skewY=o(r,"deg")},perspective:function(r){this.perspective=o(r,"px")},x:function(r){this.set("translate",r,null)},y:function(r){this.set("translate",null,r)},translate:function(r,s){if(this._translateX===undefined){this._translateX=0}if(this._translateY===undefined){this._translateY=0}if(r!==null&&r!==undefined){this._translateX=o(r,"px")}if(s!==null&&s!==undefined){this._translateY=o(s,"px")}this.translate=this._translateX+","+this._translateY}},getter:{x:function(){return this._translateX||0},y:function(){return this._translateY||0},scale:function(){var r=(this.scale||"1,1").split(",");if(r[0]){r[0]=parseFloat(r[0])}if(r[1]){r[1]=parseFloat(r[1])}return(r[0]===r[1])?r[0]:r},rotate3d:function(){var t=(this.rotate3d||"0,0,0,0deg").split(",");for(var r=0;r<=3;++r){if(t[r]){t[r]=parseFloat(t[r])}}if(t[3]){t[3]=o(t[3],"deg")}return t}},parse:function(s){var r=this;s.replace(/([a-zA-Z0-9]+)\((.*?)\)/g,function(t,v,u){r.setFromString(v,u)})},toString:function(t){var s=[];for(var r in this){if(this.hasOwnProperty(r)){if((!q.transform3d)&&((r==="rotateX")||(r==="rotateY")||(r==="perspective")||(r==="transformOrigin"))){continue}if(r[0]!=="_"){if(t&&(r==="scale")){s.push(r+"3d("+this[r]+",1)")}else{if(t&&(r==="translate")){s.push(r+"3d("+this[r]+",0)")}else{s.push(r+"("+this[r]+")")}}}}}return s.join(" ")}};function m(s,r,t){if(r===true){s.queue(t)}else{if(r){s.queue(r,t)}else{t()}}}function h(s){var r=[];k.each(s,function(t){t=k.camelCase(t);t=k.transit.propertyMap[t]||k.cssProps[t]||t;t=c(t);if(k.inArray(t,r)===-1){r.push(t)}});return r}function g(s,v,x,r){var t=h(s);if(k.cssEase[x]){x=k.cssEase[x]}var w=""+l(v)+" "+x;if(parseInt(r,10)>0){w+=" "+l(r)}var u=[];k.each(t,function(z,y){u.push(y+" "+w)});return u.join(", ")}k.fn.transition=k.fn.transit=function(z,s,y,C){var D=this;var u=0;var w=true;if(typeof s==="function"){C=s;s=undefined}if(typeof y==="function"){C=y;y=undefined}if(typeof z.easing!=="undefined"){y=z.easing;delete z.easing}if(typeof z.duration!=="undefined"){s=z.duration;delete z.duration}if(typeof z.complete!=="undefined"){C=z.complete;delete z.complete}if(typeof z.queue!=="undefined"){w=z.queue;delete z.queue}if(typeof z.delay!=="undefined"){u=z.delay;delete z.delay}if(typeof s==="undefined"){s=k.fx.speeds._default}if(typeof y==="undefined"){y=k.cssEase._default}s=l(s);var E=g(z,s,y,u);var B=k.transit.enabled&&q.transition;var t=B?(parseInt(s,10)+parseInt(u,10)):0;if(t===0){var A=function(F){D.css(z);if(C){C.apply(D)}if(F){F()}};m(D,w,A);return D}var x={};var r=function(H){var G=false;var F=function(){if(G){D.unbind(f,F)}if(t>0){D.each(function(){this.style[q.transition]=(x[this]||null)})}if(typeof C==="function"){C.apply(D)}if(typeof H==="function"){H()}};if((t>0)&&(f)&&(k.transit.useTransitionEnd)){G=true;D.bind(f,F)}else{window.setTimeout(F,t)}D.each(function(){if(t>0){this.style[q.transition]=E}k(this).css(z)})};var v=function(F){this.offsetWidth;r(F)};m(D,w,v);return this};function n(s,r){if(!r){k.cssNumber[s]=true}k.transit.propertyMap[s]=q.transform;k.cssHooks[s]={get:function(v){var u=k(v).css("transit:transform");return u.get(s)},set:function(v,w){var u=k(v).css("transit:transform");u.setFromString(s,w);k(v).css({"transit:transform":u})}}}function c(r){return r.replace(/([A-Z])/g,function(s){return"-"+s.toLowerCase()})}function o(s,r){if((typeof s==="string")&&(!s.match(/^[\-0-9\.]+$/))){return s}else{return""+s+r}}function l(s){var r=s;if(k.fx.speeds[r]){r=k.fx.speeds[r]}return o(r,"ms")}k.transit.getTransitionValue=g})(jQuery); \ No newline at end of file diff --git a/js/main.min.js b/js/main.min.js new file mode 100644 index 0000000..c6d3a9f --- /dev/null +++ b/js/main.min.js @@ -0,0 +1 @@ +function getCookie(e){for(var o=e+"=",t=document.cookie.split(";"),s=0;s=$("#land").offset().top)return void playerDead();var u=$("#ceiling");if(r<=u.offset().top+u.height()&&(position=0),null!=pipes[0]){var d=pipes[0],h=d.children(".pipe_upper"),m=h.offset().top+h.height(),y=h.offset().left-2,g=y+pipewidth,f=m+pipeheight;if(debugmode){var l=$("#pipebox");l.css("left",y),l.css("top",m),l.css("height",pipeheight),l.css("width",pipewidth)}return p>y&&!(r>m&&f>c)?void playerDead():void(n>g&&(pipes.splice(0,1),playerScore()))}}function screenClick(){currentstate==states.GameScreen?playerJump():currentstate==states.SplashScreen&&startGame()}function playerJump(){velocity=jump,soundJump.stop(),soundJump.play()}function setBigScore(e){var o=$("#bigscore");if(o.empty(),!e)for(var t=score.toString().split(""),s=0;s")}function setSmallScore(){var e=$("#currentscore");e.empty();for(var o=score.toString().split(""),t=0;t")}function setHighScore(){var e=$("#highscore");e.empty();for(var o=highscore.toString().split(""),t=0;t")}function setMedal(){var e=$("#medal");return e.empty(),10>score?!1:(score>=10&&(medal="bronze"),score>=20&&(medal="silver"),score>=30&&(medal="gold"),score>=40&&(medal="platinum"),e.append(''+medal+''),!0)}function playerDead(){$(".animated").css("animation-play-state","paused"),$(".animated").css("-webkit-animation-play-state","paused");var e=$('
');$("#flyarea").append(e);var o=$("#player").position().top+$("#player").width(),t=$("#flyarea").height(),s=Math.max(0,t-o);$("#player").transition({y:s+"px",rotate:90},1e3,"easeInOutCubic"),currentstate=states.ScoreScreen,clearInterval(loopGameloop),clearInterval(loopPipeloop),loopGameloop=null,loopPipeloop=null,isIncompatible.any()?(soundHit.play(),showScore()):soundHit.play().bindOnce("ended",function(){soundDie.play().bindOnce("ended",function(){showScore()})})}function showScore(){soundNasheed.stop(),$("#scoreboard").css("display","block"),setBigScore(!0),score>highscore&&(highscore=score,setCookie("highscore",highscore,999)),setSmallScore(),setHighScore();var e=setMedal();soundSwoosh.stop(),soundSwoosh.play(),$("#scoreboard").css({y:"40px",opacity:0}),$("#replay").css({y:"40px",opacity:0}),$("#scoreboard").transition({y:"0px",opacity:1},600,"ease",function(){soundSwoosh.stop(),soundSwoosh.play(),$("#replay").transition({y:"0px",opacity:1},600,"ease"),e&&($("#medal").css({scale:2,opacity:0}),$("#medal").transition({opacity:1,scale:1},1200,"ease"))}),replayclickable=!0}function playerScore(){score+=1,soundScore.stop(),soundScore.play(),setBigScore()}function updatePipes(){$(".pipe").filter(function(){return $(this).position().left<=-100}).remove();var e=80,o=420-pipeheight-2*e,t=Math.floor(Math.random()*o+e),s=420-pipeheight-t,a=$('
');$("#flyarea").append(a),pipes.push(a)}var debugmode=!1,states=Object.freeze({SplashScreen:0,GameScreen:1,ScoreScreen:2}),currentstate,gravity=.25,velocity=0,position=180,rotation=0,jump=-4.6,score=0,highscore=0,pipeheight=100,pipewidth=52,pipes=new Array,replayclickable=!1;buzz.defaults.preload=!0,buzz.defaults.formats=["ogg","mp3"];var volume=30,soundJump=new buzz.sound("assets/sounds/sfx_wing"),soundScore=new buzz.sound("assets/sounds/sfx_point"),soundDie=new buzz.sound("assets/sounds/sfx_die"),soundSwoosh=new buzz.sound("assets/sounds/sfx_swooshing"),soundNasheed=new buzz.sound("assets/sounds/nasheed"),soundHit=new buzz.sound("assets/sounds/sfx_hit");buzz.all().setVolume(volume),soundNasheed.setVolume(15);var loopGameloop,loopPipeloop;$(document).ready(function(){"?debug"==window.location.search&&(debugmode=!0),"?easy"==window.location.search&&(pipeheight=200);var e=getCookie("highscore");""!=e&&(highscore=parseInt(e)),showSplash()}),$(document).keydown(function(e){32==e.keyCode&&(currentstate==states.ScoreScreen?$("#replay").click():screenClick())}),"ontouchstart"in window?$(document).on("touchstart",screenClick):$(document).on("mousedown",screenClick),$("#replay").click(function(){$("#explosion").remove(),replayclickable&&(replayclickable=!1,soundSwoosh.stop(),soundSwoosh.play(),$("#scoreboard").transition({y:"-40px",opacity:0},1e3,"ease",function(){$("#scoreboard").css("display","none"),showSplash()}))});var isIncompatible={Android:function(){return navigator.userAgent.match(/Android/i)},BlackBerry:function(){return navigator.userAgent.match(/BlackBerry/i)},iOS:function(){return navigator.userAgent.match(/iPhone|iPad|iPod/i)},Opera:function(){return navigator.userAgent.match(/Opera Mini/i)},Safari:function(){return navigator.userAgent.match(/OS X.*Safari/)&&!navigator.userAgent.match(/Chrome/)},Windows:function(){return navigator.userAgent.match(/IEMobile/i)},any:function(){return isIncompatible.Android()||isIncompatible.BlackBerry()||isIncompatible.iOS()||isIncompatible.Opera()||isIncompatible.Safari()||isIncompatible.Windows()}}; \ No newline at end of file