3 کامیت‌ها 465ba76e5e ... 54db4703f4

نویسنده SHA1 پیام تاریخ
  hxt 54db4703f4 音频解决 2 سال پیش
  hxt 2680c0a9bf Merge branch 'master' of http://118.190.145.217:3000/xiaojincai/quepass_game 2 سال پیش
  hxt f2c412972d ok 2 سال پیش
6فایلهای تغییر یافته به همراه60 افزوده شده و 81 حذف شده
  1. 4 3
      css/index.css
  2. 1 1
      fail.html
  3. 1 1
      gameready.html
  4. 47 44
      index.html
  5. 6 31
      js/game.js
  6. 1 1
      success.html

+ 4 - 3
css/index.css

@@ -208,14 +208,15 @@ body {
 }
 
 .ren-text{
-	width:20vw;
+	width:40vw;
 	float:right;
 	color:#fff;
 	font-size:14px;
 	position:absolute;
 	z-index:2;
-	right:0;
+	right:2vw;
 	top:10px;
+	text-align:right;
 }
 .full {
 	position: absolute;
@@ -327,7 +328,7 @@ body {
 #success {
 	display: none;
 }
-.mute { position: absolute; z-index: 999; top: 5vw; right: 5vw; width: 8vw; height: 8vw; background: url(../img/mute.png) no-repeat; background-size: 100% auto; opacity: 1;}
+.mute { position: absolute; z-index: 999; top: 9vw; right: 5vw; width: 8vw; height: 8vw; background: url(../img/mute.png) no-repeat; background-size: 100% auto; opacity: 1;}
 .mute * { position: absolute; width: 100%; height: 100%; background: url(../img/mute.png) no-repeat; background-size: 100% auto;}
 .mute dt {-webkit-animation: muteANI 2s linear infinite;  background-position: 0 41%;}
 .mute dd { display: none; background-position: 0 83.5%; }

+ 1 - 1
fail.html

@@ -9,7 +9,7 @@
 	<body>
 		<section class="end-box full" id="endBox">
 			<div class="end" id="fail"><img src="img/fail.png" alt=""></div>
-			<a href="https://www.100t.com/gjnh/2022.php"class="btn"><img src="img/btn.png"></a>
+			<a href="http://gjnh.100t.com/gjnh/index.php/Index/"class="btn"><img src="img/btn.png"></a>
 		</section>
 	</body>
 </html>

+ 1 - 1
gameready.html

@@ -210,7 +210,7 @@
 				<div></div>
 				<div></div>
 				<p class="wait-text">游戏已经开始,请等待下一轮</p>
-				<a href="https://www.100t.com/gjnh/2022.php"class="btn"><img src="img/btn.png"></a>
+				<a href="http://gjnh.100t.com/gjnh/index.php/Index/"class="btn"><img src="img/btn.png"></a>
 			</div>
 		</section>
 	</body>

+ 47 - 44
index.html

@@ -10,13 +10,13 @@
 		<!-- 等待页 -->
 		<section class="waitting full" id="load">
 			<div class="loader-inner pacman">
-			          <div></div>
-			          <div></div>
-			          <div></div>
-			          <div></div>
-			          <div></div>
-					<p class="wait-text">正在等待他人加入,请勿关闭...</p>
-			 </div>
+				<div></div>
+				<div></div>
+				<div></div>
+				<div></div>
+				<div></div>
+				<p class="wait-text">正在等待他人加入,请勿关闭...</p>
+			</div>
 		</section>
 		<div class="all">
 			<!-- 背景 -->
@@ -58,49 +58,52 @@
 		<script src="js/jquery.js"></script>
 		<script src="js/jquery.transit.min.js"></script>
 		<script>
-		document.addEventListener('DOMContentLoaded', function() {
-			function audioAutoPlay(id) {
-				var audio = document.getElementById(id);
-				audio.play();
-				document.addEventListener("WeixinJSBridgeReady", function() {
-					audio.play();
-				}, false);
-				audio.onended = function() {
-					if (audio.id == 'music') {
-						audio.play();
-					} else {
-						audio.pause();
-						return
+			var music = document.getElementById("music");
+			var $mute = $(".mute");
+			var gv = {};
+			gv.isTouch = window.ontouchstart === undefined ? false : true;
+			gv.evtDown = gv.isTouch ? "touchstart" : "mousedown";
+			if (music.paused) {
+				$mute.addClass("on");
+			}
+			var isFirst=true;
+			function playAudio() {
+				if(isFirst){
+					var s = window.setTimeout(function() {
+						music.play();
+						if (!music.paused) {
+							$mute.removeClass("on");
+							isFirst=false;
+						}
+					}, 800);
+				}else{
+					music.play();
+					if (!music.paused) {
+						$mute.removeClass("on");
 					}
 				}
+			
 			}
-		
-			function audioPause(id) {
-				var audio = document.getElementById(id);
-				audio.pause();
-				document.addEventListener("WeixinJSBridgeReady", function() {
-					audio.pause();
-				}, false);
-				document.addEventListener('YixinJSBridgeReady', function() {
-					audio.pause();
-				}, false);
+
+			function audioPause(audio) {
+				music.pause();
+				if (music.paused) {
+					$mute.addClass("on");
+				}
 			}
-			audioAutoPlay('music');
-			
-			
-			gv={};
-			gv.isTouch = window.ontouchstart === undefined ? false : true;
-			gv.evtDown = gv.isTouch ? "touchstart" : "mousedown";
-			$(".mute").on(gv.evtDown, function() {
-				$(this).toggleClass('on')
-				if ($(this).hasClass('on')) {
-					audioPause('music');
-				} else {
-					audioAutoPlay('music');
+
+			$("html").one(gv.evtDown,function(){
+					playAudio();
+			});
+
+			$mute.on(gv.evtDown, function() {
+				if(music.paused){
+					playAudio();
+				}else{
+					audioPause();
 				}
 			})
-		})
 		</script>
 		<script src="js/game.js?V=2022"></script>
 	</body>
-</html>
+</html>

+ 6 - 31
js/game.js

@@ -68,7 +68,7 @@ function preload(imgs, callback) {
 }
 
 if (!uid || !uname) {
-	// window.location.href = "http://www.100t.com/gjnh/2022.php";
+	window.location.href = "http://gjnh.100t.com/gjnh/index.php/Index/";
 } else {
 	registUrl = registUrl + "/"+uid
 	$.post(registUrl, JSON.stringify({
@@ -81,11 +81,12 @@ if (!uid || !uname) {
 		"text-bg.png",
 		"time-box.png", "trap1.png", "trap2.png", "trap3.png", "trap4.png","mute.png"
 	], function() {})
+	
 	waiting(function() {
 		$load.fadeOut(function() {
 			$(this).remove();
 			init();
-		});
+		}); 	
 	})
 }
 
@@ -337,7 +338,7 @@ function reconnect(service) {
 }
 var isWait = true;
 var timer = null;
-
+var limit=getQueryString("limit")||0;
 function waiting(callback) {
 	wsWaitUrl = wsWaitUrl +"/"+uid;
 	var ws = new WebSocket(wsWaitUrl);
@@ -365,12 +366,12 @@ function waiting(callback) {
 			clearTimeout(quesTimer);
 			success();
 		}
-		/* if(res.status == 1 && !isWait && res.data.length<100){
+		if(res.status == 1 && !isWait && res.data.length<=limit){
 			isQuesEnd = true;
 			clearTimeout(quesTimer);
 			window.clearInterval(timer);
 			success();
-		} */
+		}
 		$ren.html(res.data.length);
 	}
 	ws.onclose = function() {
@@ -386,29 +387,3 @@ function waiting(callback) {
 	};
 }
 
-function getQueryString(name) {
-    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
-    var r = decodeURI(window.location.search.substr(1)).match(reg);
-    if (r != null) return unescape(r[2]); return null;
-}
-var uid=getQueryString('uid');
-var uname=getQueryString('uname');
-if(!uid || !uname){
-	window.location.href="https://www.100t.com/gjnh/2022.php";
-}else{
-	registUrl = registUrl + "/"+uid
-	$.post(registUrl,JSON.stringify({uid,uname}),function(res){
-		preload(["bg.png","figure.png","img1.png","img2.png","img3.png","line.png","qus-top.png","text-bg.png","time-box.png","trap1.png","trap2.png","trap3.png","trap4.png"],function(){
-			waiting(function(){
-				$load.fadeOut(function(){
-					$(this).remove();
-					init();
-				});
-			})
-		})
-	})
-	var timer = window.setInterval(function() {
-		$.post(registUrl,JSON.stringify({uid,uname}),function(res){})
-	}, 5000)
-}
-

+ 1 - 1
success.html

@@ -9,7 +9,7 @@
 	<body>
 		<section class="end-box full" id="endBox">
 			<div class="end" id="success"><img src="img/success.png" alt=""></div>
-			<a href="https://www.100t.com/gjnh/2022.php"class="btn"><img src="img/btn.png"></a>
+			<a href="http://gjnh.100t.com/gjnh/index.php/Index/"class="btn"><img src="img/btn.png"></a>
 		</section>
 	</body>
 </html>