- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
问题是如果所有单元格都被占用但有人在最后一步赢了,在井字游戏中它不应该返回赢家。但如果最后一个方 block 是获胜标记,它将返回平局。
我尝试添加条件语句,但它不起作用。
if (emptySquares().length==0 && gameWon.player != hplayer || gameWon.player != ailayer)
谁能告诉我任何条件语句。
class Stopwatch {
constructor(display, results) {
this.running = false;
this.display = display;
this.results = results;
this.laps = [];
this.reset();
this.print(this.times);
}
reset() {
this.times = [ 0, 0, 0 ];
}
start() {
if (!this.time) this.time = performance.now();
if (!this.running) {
this.running = true;
requestAnimationFrame(this.step.bind(this));
}
}
restart() {
if (!this.time) this.time = performance.now();
if (!this.running) {
this.running = true;
requestAnimationFrame(this.step.bind(this));
}
this.reset();
}
step(timestamp) {
if (!this.running) return;
this.calculate(timestamp);
this.time = timestamp;
this.print();
requestAnimationFrame(this.step.bind(this));
}
calculate(timestamp) {
var diff = timestamp - this.time;
// Hundredths of a second are 100 ms
this.times[2] += diff / 10;
// Seconds are 100 hundredths of a second
if (this.times[2] >= 100) {
this.times[1] += 1;
this.times[2] -= 100;
}
// Minutes are 60 seconds
if (this.times[1] >= 60) {
this.times[0] += 1;
this.times[1] -= 60;
}
}
print() {
this.display.innerText = this.format(this.times);
}
format(times) {
return `\
${pad0(times[0], 2)}:\
${pad0(times[1], 2)}:\
${pad0(Math.floor(times[2]), 2)}`;
}
}
function pad0(value, count) {
var result = value.toString();
for (; result.length < count; --count)
result = '0' + result;
return result;
}
function clearChildren(node) {
while (node.lastChild)
node.removeChild(node.lastChild);
}
let stopwatch = new Stopwatch(
document.querySelector('.stopwatch'),
document.querySelector('.results'));
// @@@ TIC_TAC_TOE @@@@
var board;
const hplayer ="0"; //human player
const aiplayer ="x"; //machine player
const wincom = // DEACLARE WINING COMBINATIONS
[
[0,1,2],
[3,4,5],
[6,7,8],
[0,3,6],
[1,4,7],
[2,5,8],
[0,4,8],
[6,4,2],
]
//GET ALL INSIDE THE CELL CLASS
const cells = document.querySelectorAll('.cell');
startGame();
stopwatch.start();
var mySound; //VARIABLE FOR SOUNDS
function startGame()
{
// AT THE GAME END DISPLAY NONE
document.querySelector(".endgame").style.display = "none";
// CREATE ARRAYS FOR 9 BORD ELEMENTS
board = Array.from(Array(9).keys());
//CLEAR BOARD AFTER WINNING
for (var i = 0; i <cells.length; i++)
{
cells[i].innerText =''; // CLEAR CELLS
cells[i].style.removeProperty('background-color'); //REMOVE WINING HIGHLIGHT COLOR FROM BOARD AND ASSIGN TO BACKGROUND COLOR
cells[i].addEventListener('click', turnClick, false); // CALL CLICK
mySound = new sound("bounce.mp3");
}
}
function turnClick(square)
{
// GENARATE TARGET CELL NUMBER USING HUMAN PLAYER CLICK EVENT
//console.log(square.target.id, hplayer)
if (typeof board[square.target.id] == 'number') {// DISABLE OTHER CELLS
turn(square.target.id, hplayer)
if (!checkTie()) turn(bestSpot(), aiplayer);
}
}
function turn(squareId, player)
{
board[squareId] = player; // SHOW PLAYER AND SQUARE ID WHICH IS PLAYER CLICKED
document.getElementById(squareId).innerText = player;
let gameWon = checkWin(board, player) //GAME WON PLAYER AND BOARD CELLS
if (gameWon) gameOver (gameWon) // IF GAME WON CALL GAMEOVER FUNCTION WITH GAMEWON VARIABLE
}
function checkWin(board, player)
{
// TAKE ARRAY AND ADD THE INDEX TOO THE ARRAY, IDENTIFY EVERY INDEX OF PLAYER CLICKED
//check all the spots on the board played (e = elements , i = array, a = qemulator)
let plays = board.reduce((a, e, i) =>
(e===player) ? a.concat(i) : a, []);
// SET GAME WON NULL DROW NO WINS
let gameWon = null;
//CHECK IF GAME HAS BEEN WON
for(let[index, win] of wincom.entries()) //GET INDEX AND WIN
{
// CHECK IF THE PLAYER CLICK TO THE ANY WINING ELEMENTS IN WINING COMBINATION
if (win.every(elem=>plays.indexOf(elem) >-1))
{
// WIHICH PLAYER WON ? AND WINING INDEX ?
gameWon = {index: index, player:player};
break; // BREAK FUNCTION
}
}
return gameWon; //IF WON GAME WON RETURN OR NOT RETURN GAME WON NULL
}
function gameOver(gameWon)
{
for (let index of wincom[gameWon.index]) // INDEX OF WINNING COMBINATION WHICH PLAYER HAS CLICKED
{
document.getElementById(index).style.backgroundColor =
gameWon.player == hplayer ? "red": "blue"; // IF THE PLAYER WHO WON HUMAN PLAYER INDEX OF WINING COMBINATIONS BECOME BLUE OR AI PLAYER INDEX BECOME RED
}
for (var i = 0; i < cells.length; i++) // check if available spots length is more than to 0
{
cells[i].removeEventListener('click', turnClick, false); // DISABLE CELLS CLICKING AFTER WINING REMOVE CLICK
}
declareWinner(gameWon.player == hplayer ? "YOU WON!!" : "YOU LOSS!!");
stopwatch.running = false;
stopwatch.time = null;
}
function declareWinner(who)
{
document.querySelector(".endgame").style.display = "block";
document.querySelector(".endgame .text").innerText = who;
}
function emptySquares()
{
// fillter every element in the board to see if the type of the elemnts eqales to number
return board.filter(s => typeof s == 'number');
//if type of is a number return the number
}
function bestSpot()
{
return minimax(board, aiplayer).index;
//RETURNS THE CALLING OF MINIMAX FUNCTION PASSING BOARD AND AI PLAYER AND GET INDEX OF COMPUTER PLAYING
}
function checkTie()
{
if(emptySquares().length == 0) // EVERY SQUARE FILLED UP *NO WINNER*
{
for (var i = 0; i < cells.length;i++)
{
cells[i].style.backgroundColor = "#1a0033"; // ALL CELLS GREEN
cells[i].removeEventListener('click', turnClick,false);
stopwatch.running = false;
stopwatch.time = null;
}
declareWinner("Game Tie !! ")
return true;
}
return false;
}
// minimax find a optimal move for player
function minimax(newboard, player) // CREATE MINIMAX FUNCTION USING NEWBORD AND PLAYER ARGUMENT
{
var avaSpots = emptySquares(); // check available spots of the board (Empty squares)
if (checkWin(newboard, player)) //if checking someone winning states
{
return{score: -10}; // if human player wins return -10
}
else if (checkWin(newboard, aiplayer)) // if AI player wins return +10
{
return{score: 10};
}
else if (avaSpots.length === 0) // if no available spots(0), game tie, then return 0
{
return {score: 0};
}
var moves =[];//ARRAY MOVES to collect scores
for(var i = 0; i < avaSpots.length; i++) // check array available spots length morethan to 0
{
var move = {}; // create moves object to catch available spots
move.index = newboard[avaSpots[i]]; //set the index number of the available spots to the move object property
newboard[avaSpots[i]] = player; // set the available spots for the current player
if (player == aiplayer)
{
var result = minimax(newboard, hplayer); //call minimax for human player
move.score = result.score;
}
else
{
var result = minimax (newboard, aiplayer);
move.score = result.score;
}
//minimax reset newboard and push the move object to moves array
newboard[avaSpots[i]] = move.index;
moves.push(move);
mySound.play();
}
// check the best move in the move arrray
var bestMove;
if(player === aiplayer)//should chose with the highst score when AI play
{
var bestScore = -10000;
for(var i = 0; i < moves.length; i++)
{
if (moves[i].score > bestScore) //store highst score
{
bestScore = moves[i].score;
bestMove = i;
}
}
}
else
{
var bestScore = 10000;
for(var i = 0; i < moves.length; i++)
{
if(moves[i].score < bestScore)
{
bestScore = moves[i].score; // store lowest score
bestMove = i;
}
}
}
return moves[bestMove]; //return object store inside the bestmove
}
function sound(src) {
this.sound = document.createElement("audio");
this.sound.src = src;
this.sound.setAttribute("preload", "auto");
this.sound.setAttribute("controls", "none");
this.sound.style.display = "none";
document.body.appendChild(this.sound);
this.play = function(){
this.sound.play();
}
this.stop = function(){
this.sound.pause();
}
}
body
{
background-image: url(background.jpg);
}
table
{
margin-top: 80px;
background: transparent;
box-shadow: 0px 0px 0px 0px #393d44;
}
td
{
height: 130px;
width: 120px;
text-align: center;
vertical-align: middle;
font-family: "Bradley Hand ITC";
color: red;
padding: 10px;
font-size: 70px;
cursor: pointer;
}
table tr:first-child
{
box-shadow:0px 8px 5px -5px blue;
}
table tr:nth-child(2)
{
box-shadow:0px -8px 5px -5px blue
, 0px 8px 5px -5px blue;
}
table tr:last-child
{
box-shadow:0px -8px 5px -5px blue;
}
table tr td:first-child
{
box-shadow:8px 0px 5px -5px blue;
}
table tr td:nth-child(2)
{
box-shadow:-8px 0px 5px -5px blue
, 8px 0px 5px -5px blue;
}
table tr td:last-child
{
box-shadow:-8px 0px 5px -5px blue;
}
.endgame
{
display: none;
width: 300px;
top: 100px;
background-color: rgba(70, 80, 120, 0.66);
position: absolute;
left: 645px;
margin-left: -112px;
margin-top: 10%;
padding-bottom: 0px;
padding-top: 20px;
text-align: center;
border-radius: 5px;
color: #f9f1f1;
font-background: #0C3F6F !important;
font-size:45px;
font-family: monospace;
}
.button
{
height:35px;
background-color: #e0f1ed2e;
color: white;
border:none;
border-radius: 10px;
cursor: pointer;
margin-bottom:20px;
margin-top: 20px;
font-size: 25px;
transition: 0.3s;
font-family: monospace;
}
.button:hover
{
opacity: 1;
background-color: coral;
}
a
{
text-decoration-line: none;
text-decoration: none;
color: white;
}
.button_f
{
height:35px;
background-color: #e0f1ed2e;
border:none;
border-radius: 10px;
cursor: pointer;
margin-bottom:20px;
margin-top: 0px;
font-size: 20px;
background: #0C3F6F !important;
font-family: monospace;
color:white !important;
}
html {
color: #bbb;
font-family: Menlo;
}
.stopwatch {
font-size: 80px;
text-align: center;
}
.results {
border-color: lime;
list-style: none;
margin: 0;
padding: 0;
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
}
<html>
<title>Tic Tac Toe</title>
<!--LINK CSS STYLESHEET-->
<head>
<link rel="stylesheet" href="tic_tac_toe.css">
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
</head>
<body>
<embed src="dChanyeol (EXO) & Punch - Stay With Me FMV (Goblin OST Part 1) (Eng Sub + Rom + Han).mp3" autostart="true" hidden="true" loop ="true">
<!--BACKGROUND MUSI
<audio id="myaudio">
<source src="music.mp3">
</audio>
JS FOR MUSIC VOLUME
<script>
var audio = document.getElementById("myaudio").loop=true;
audio.volume = 0.2;
</script>C-->
<div class="stopwatch"></div>
<ul class="results"></ul>
<!--CREATE BORD FOR TIC TAC TOE GAME-->
<table align="center">
<tr>
<td class="cell" id="0"></td>
<td class="cell" id="1"></td>
<td class="cell" id="2"></td>
</tr>
<tr>
<td class="cell" id="3"></td>
<td class="cell" id="4"></td>
<td class="cell" id="5"></td>
</tr>
<tr>
<td class="cell" id="6"></td>
<td class="cell" id="7"></td>
<td class="cell" id="8"></td>
</tr>
<!--MESSAGE CLASS FOR END GAME-->
<div class="endgame">
<div class="text"></div>
<!--BUTTON FOR REPLAY-->
<button onclick="startGame(), stopwatch.restart();" class="button">Restart</button> <br>
<!--<button onclick="location.reload();" class="button">Restart New Game</button>-->
<button class="button_f"><a href="https://en-gb.facebook.com/">Share This on Facebook</a></button>
</div> <!--END MESSAGE-->
</table> <!--END GAME TABLE BOARD-->
<!--LINK JAVASCRIPT-->
<script src="tic_tac_toe.js"></script>
</body>
</html>
最佳答案
试试这个,我引入了一个新的 bool 变量 this.winner
作为 false,我在 checkTie()
函数中检查了它。在 gameOver()
函数中,我将该变量设置为 true
class Stopwatch {
constructor(display, results) {
this.running = false;
this.display = display;
this.results = results;
this.laps = [];
this.winner = false;
this.reset();
this.print(this.times);
}
reset() {
this.times = [ 0, 0, 0 ];
}
start() {
if (!this.time) this.time = performance.now();
if (!this.running) {
this.running = true;
requestAnimationFrame(this.step.bind(this));
}
}
restart() {
if (!this.time) this.time = performance.now();
if (!this.running) {
this.running = true;
requestAnimationFrame(this.step.bind(this));
}
this.reset();
}
step(timestamp) {
if (!this.running) return;
this.calculate(timestamp);
this.time = timestamp;
this.print();
requestAnimationFrame(this.step.bind(this));
}
calculate(timestamp) {
var diff = timestamp - this.time;
// Hundredths of a second are 100 ms
this.times[2] += diff / 10;
// Seconds are 100 hundredths of a second
if (this.times[2] >= 100) {
this.times[1] += 1;
this.times[2] -= 100;
}
// Minutes are 60 seconds
if (this.times[1] >= 60) {
this.times[0] += 1;
this.times[1] -= 60;
}
}
print() {
this.display.innerText = this.format(this.times);
}
format(times) {
return `\
${pad0(times[0], 2)}:\
${pad0(times[1], 2)}:\
${pad0(Math.floor(times[2]), 2)}`;
}
}
function pad0(value, count) {
var result = value.toString();
for (; result.length < count; --count)
result = '0' + result;
return result;
}
function clearChildren(node) {
while (node.lastChild)
node.removeChild(node.lastChild);
}
let stopwatch = new Stopwatch(
document.querySelector('.stopwatch'),
document.querySelector('.results'));
// @@@ TIC_TAC_TOE @@@@
var board;
const hplayer ="0"; //human player
const aiplayer ="x"; //machine player
const wincom = // DEACLARE WINING COMBINATIONS
[
[0,1,2],
[3,4,5],
[6,7,8],
[0,3,6],
[1,4,7],
[2,5,8],
[0,4,8],
[6,4,2],
]
//GET ALL INSIDE THE CELL CLASS
const cells = document.querySelectorAll('.cell');
startGame();
stopwatch.start();
var mySound; //VARIABLE FOR SOUNDS
function startGame()
{
// AT THE GAME END DISPLAY NONE
document.querySelector(".endgame").style.display = "none";
// CREATE ARRAYS FOR 9 BORD ELEMENTS
board = Array.from(Array(9).keys());
//CLEAR BOARD AFTER WINNING
for (var i = 0; i <cells.length; i++)
{
cells[i].innerText =''; // CLEAR CELLS
cells[i].style.removeProperty('background-color'); //REMOVE WINING HIGHLIGHT COLOR FROM BOARD AND ASSIGN TO BACKGROUND COLOR
cells[i].addEventListener('click', turnClick, false); // CALL CLICK
mySound = new sound("bounce.mp3");
}
}
function turnClick(square)
{
// GENARATE TARGET CELL NUMBER USING HUMAN PLAYER CLICK EVENT
//console.log(square.target.id, hplayer)
if (typeof board[square.target.id] == 'number') {// DISABLE OTHER CELLS
turn(square.target.id, hplayer)
if (!checkTie()) turn(bestSpot(), aiplayer);
}
}
function turn(squareId, player)
{
board[squareId] = player; // SHOW PLAYER AND SQUARE ID WHICH IS PLAYER CLICKED
if(squareId)
document.getElementById(squareId).innerText = player;
let gameWon = checkWin(board, player) //GAME WON PLAYER AND BOARD CELLS
if (gameWon) {
this.winner = true;
gameOver (gameWon) // IF GAME WON CALL GAMEOVER FUNCTION WITH GAMEWON VARIABLE
}
}
function checkWin(board, player)
{
// TAKE ARRAY AND ADD THE INDEX TOO THE ARRAY, IDENTIFY EVERY INDEX OF PLAYER CLICKED
//check all the spots on the board played (e = elements , i = array, a = qemulator)
let plays = board.reduce((a, e, i) =>
(e===player) ? a.concat(i) : a, []);
// SET GAME WON NULL DROW NO WINS
let gameWon = null;
//CHECK IF GAME HAS BEEN WON
for(let[index, win] of wincom.entries()) //GET INDEX AND WIN
{
// CHECK IF THE PLAYER CLICK TO THE ANY WINING ELEMENTS IN WINING COMBINATION
if (win.every(elem=>plays.indexOf(elem) >-1))
{
// WIHICH PLAYER WON ? AND WINING INDEX ?
gameWon = {index: index, player:player};
break; // BREAK FUNCTION
}
}
return gameWon; //IF WON GAME WON RETURN OR NOT RETURN GAME WON NULL
}
function gameOver(gameWon)
{
for (let index of wincom[gameWon.index]) // INDEX OF WINNING COMBINATION WHICH PLAYER HAS CLICKED
{
document.getElementById(index).style.backgroundColor =
gameWon.player == hplayer ? "red": "blue"; // IF THE PLAYER WHO WON HUMAN PLAYER INDEX OF WINING COMBINATIONS BECOME BLUE OR AI PLAYER INDEX BECOME RED
}
for (var i = 0; i < cells.length; i++) // check if available spots length is more than to 0
{
cells[i].removeEventListener('click', turnClick, false); // DISABLE CELLS CLICKING AFTER WINING REMOVE CLICK
}
declareWinner(gameWon.player == hplayer ? "YOU WON!!" : "YOU LOSS!!");
stopwatch.running = false;
stopwatch.time = null;
}
function declareWinner(who)
{
document.querySelector(".endgame").style.display = "block";
document.querySelector(".endgame .text").innerText = who;
}
function emptySquares()
{
// fillter every element in the board to see if the type of the elemnts eqales to number
return board.filter(s => typeof s == 'number');
//if type of is a number return the number
}
function bestSpot()
{
return minimax(board, aiplayer).index;
//RETURNS THE CALLING OF MINIMAX FUNCTION PASSING BOARD AND AI PLAYER AND GET INDEX OF COMPUTER PLAYING
}
function checkTie()
{
if(emptySquares().length == 0 && !this.winner) // EVERY SQUARE FILLED UP *NO WINNER*
{
for (var i = 0; i < cells.length;i++)
{
cells[i].style.backgroundColor = "#1a0033"; // ALL CELLS GREEN
cells[i].removeEventListener('click', turnClick,false);
stopwatch.running = false;
stopwatch.time = null;
}
declareWinner("Game Tie !! ")
return true;
}
return false;
}
// minimax find a optimal move for player
function minimax(newboard, player) // CREATE MINIMAX FUNCTION USING NEWBORD AND PLAYER ARGUMENT
{
var avaSpots = emptySquares(); // check available spots of the board (Empty squares)
if (checkWin(newboard, player)) //if checking someone winning states
{
return{score: -10}; // if human player wins return -10
}
else if (checkWin(newboard, aiplayer)) // if AI player wins return +10
{
return{score: 10};
}
else if (avaSpots.length === 0) // if no available spots(0), game tie, then return 0
{
return {score: 0};
}
var moves =[];//ARRAY MOVES to collect scores
for(var i = 0; i < avaSpots.length; i++) // check array available spots length morethan to 0
{
var move = {}; // create moves object to catch available spots
move.index = newboard[avaSpots[i]]; //set the index number of the available spots to the move object property
newboard[avaSpots[i]] = player; // set the available spots for the current player
if (player == aiplayer)
{
var result = minimax(newboard, hplayer); //call minimax for human player
move.score = result.score;
}
else
{
var result = minimax (newboard, aiplayer);
move.score = result.score;
}
//minimax reset newboard and push the move object to moves array
newboard[avaSpots[i]] = move.index;
moves.push(move);
mySound.play();
}
// check the best move in the move arrray
var bestMove;
if(player === aiplayer)//should chose with the highst score when AI play
{
var bestScore = -10000;
for(var i = 0; i < moves.length; i++)
{
if (moves[i].score > bestScore) //store highst score
{
bestScore = moves[i].score;
bestMove = i;
}
}
}
else
{
var bestScore = 10000;
for(var i = 0; i < moves.length; i++)
{
if(moves[i].score < bestScore)
{
bestScore = moves[i].score; // store lowest score
bestMove = i;
}
}
}
return moves[bestMove]; //return object store inside the bestmove
}
function sound(src) {
this.sound = document.createElement("audio");
this.sound.src = src;
this.sound.setAttribute("preload", "auto");
this.sound.setAttribute("controls", "none");
this.sound.style.display = "none";
document.body.appendChild(this.sound);
this.play = function(){
this.sound.play();
}
this.stop = function(){
this.sound.pause();
}
}
body
{
background-image: url(background.jpg);
}
table
{
margin-top: 80px;
background: transparent;
box-shadow: 0px 0px 0px 0px #393d44;
}
td
{
height: 130px;
width: 120px;
text-align: center;
vertical-align: middle;
font-family: "Bradley Hand ITC";
color: red;
padding: 10px;
font-size: 70px;
cursor: pointer;
}
table tr:first-child
{
box-shadow:0px 8px 5px -5px blue;
}
table tr:nth-child(2)
{
box-shadow:0px -8px 5px -5px blue
, 0px 8px 5px -5px blue;
}
table tr:last-child
{
box-shadow:0px -8px 5px -5px blue;
}
table tr td:first-child
{
box-shadow:8px 0px 5px -5px blue;
}
table tr td:nth-child(2)
{
box-shadow:-8px 0px 5px -5px blue
, 8px 0px 5px -5px blue;
}
table tr td:last-child
{
box-shadow:-8px 0px 5px -5px blue;
}
.endgame
{
display: none;
width: 300px;
top: 100px;
background-color: rgba(70, 80, 120, 0.66);
position: absolute;
left: 645px;
margin-left: -112px;
margin-top: 10%;
padding-bottom: 0px;
padding-top: 20px;
text-align: center;
border-radius: 5px;
color: #f9f1f1;
font-background: #0C3F6F !important;
font-size:45px;
font-family: monospace;
}
.button
{
height:35px;
background-color: #e0f1ed2e;
color: white;
border:none;
border-radius: 10px;
cursor: pointer;
margin-bottom:20px;
margin-top: 20px;
font-size: 25px;
transition: 0.3s;
font-family: monospace;
}
.button:hover
{
opacity: 1;
background-color: coral;
}
a
{
text-decoration-line: none;
text-decoration: none;
color: white;
}
.button_f
{
height:35px;
background-color: #e0f1ed2e;
border:none;
border-radius: 10px;
cursor: pointer;
margin-bottom:20px;
margin-top: 0px;
font-size: 20px;
background: #0C3F6F !important;
font-family: monospace;
color:white !important;
}
html {
color: #bbb;
font-family: Menlo;
}
.stopwatch {
font-size: 80px;
text-align: center;
}
.results {
border-color: lime;
list-style: none;
margin: 0;
padding: 0;
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
}
<html>
<title>Tic Tac Toe</title>
<!--LINK CSS STYLESHEET-->
<head>
<link rel="stylesheet" href="tic_tac_toe.css">
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
</head>
<body>
<embed src="dChanyeol (EXO) & Punch - Stay With Me FMV (Goblin OST Part 1) (Eng Sub + Rom + Han).mp3" autostart="true" hidden="true" loop ="true">
<!--BACKGROUND MUSI
<audio id="myaudio">
<source src="music.mp3">
</audio>
JS FOR MUSIC VOLUME
<script>
var audio = document.getElementById("myaudio").loop=true;
audio.volume = 0.2;
</script>C-->
<div class="stopwatch"></div>
<ul class="results"></ul>
<!--CREATE BORD FOR TIC TAC TOE GAME-->
<table align="center">
<tr>
<td class="cell" id="0"></td>
<td class="cell" id="1"></td>
<td class="cell" id="2"></td>
</tr>
<tr>
<td class="cell" id="3"></td>
<td class="cell" id="4"></td>
<td class="cell" id="5"></td>
</tr>
<tr>
<td class="cell" id="6"></td>
<td class="cell" id="7"></td>
<td class="cell" id="8"></td>
</tr>
<!--MESSAGE CLASS FOR END GAME-->
<div class="endgame">
<div class="text"></div>
<!--BUTTON FOR REPLAY-->
<button onclick="startGame(), stopwatch.restart();" class="button">Restart</button> <br>
<!--<button onclick="location.reload();" class="button">Restart New Game</button>-->
<button class="button_f"><a href="https://en-gb.facebook.com/">Share This on Facebook</a></button>
</div> <!--END MESSAGE-->
</table> <!--END GAME TABLE BOARD-->
<!--LINK JAVASCRIPT-->
<script src="tic_tac_toe.js"></script>
</body>
</html>
关于javascript - 如何在 javascript 中将条件语句添加到 - tic - tac - toe game tie 函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56180256/
我正在制作一个简单的游戏,其中敌人在屏幕上四处移动,我们需要射击他们。我想模块化我的代码,所以我想用一个函数替换游戏循环逻辑。但是一旦我这样做,就会有一个下降以 fps 为单位。在while循环中调用
我使用的是标准匹配用户界面和两台 iPad iOS6。问题是当我在第一台设备中创建新的匹配项时,第二台设备应该在我查看匹配用户界面时看到现有的匹配项,但事实并非如此。我确定我的代码是正确的。这是方法:
在 The Practical Guide to Defect Prevention ,作者提到在软件开发中提高生产力的一种创造性方法是实现“生产力游戏”,员工以类似于在 Stack Overflow
我无法让游戏中心与我的应用一起工作。 每当我尝试对用户进行身份验证时,它都会返回以下错误: "The requested operation could not be completed becaus
我是 Game Maker 的新手。我已经创建了一个基于物理的小游戏的机制,并且我使用了 YoYo Games 教程中概述的方法来创建复杂的物理对象 (http://www.yoyogames.com
我正在编写一个 GML 脚本,想知道如何使消息出现在下一行: 例如。 show_message("Hello" + *something* + "World") 输出: Hello World 最佳答
关于这个已经有几个问题,但我按照他们的步骤解决了它,但它似乎对我不起作用。这是我所做的: 1.我仔细检查了 xcode 项目中的包标识符是否与供应门户上的供应配置文件完全相同(它还表示已启用 Game
GameKit 是否允许您以编程方式邀请特定的 Game Center friend 参加比赛,即不提供 GC ViewController?以下 handleInviteFromGameCenter
我正在 Game Maker: Studio 1.4 中构建客户端/服务器应用程序,需要运行游戏的两个实例进行测试。不幸的是,IDE 的运行/调试按钮在启动第一个副本后会自行禁用。有没有办法配置 ID
游戏已启动,我收到了用户的状态,一切就绪。我正在尝试构建一个问答游戏。我正在从远程服务器获取所有信息,其中包括基于问题的图像 Assets 。我可以获取远程数据,但无法显示图像。看来 facebook
我正在努力度过让 Game Center 集成发挥作用的第一阶段。我已经走到这一步了: 我创建了一个干净的新应用,在应用委托(delegate)中添加了 GameKit header 和基本的 aut
DragonRuby Game Toolkit 中好像没有按钮的概念。如何创建按钮等 UI 组件? 最佳答案 按钮(和任何其他 UI 组件)可以解构为 primitives: 按钮有一个点击空间(通常
我正在使用 DragonRuby Game Toolkit 构建游戏。 如何检测一个对象(例如 Sprite)是否与另一个 Sprite 发生碰撞? 这是放置在屏幕上的两个 Sprite 。关于如何检
我已经在我的应用中成功实现了 Game Center 排行榜,并使用 iOS 模拟器进行了测试。将新版本提交到 iTunes Connect 后,沙盒分数会转换到真正的 Game Center 吗?我
我读到 Unity 在渲染清晰文本时出现问题,我尝试了几种不同的修复方法:在导入的字体上设置较大的字体大小,并将字符设置更改为 unicode,使文本大小变大,然后缩放它向下,将过滤模式设置为指向像素
假设角色在游戏中跳跃需要一整秒,如果 FPS 为 10fps、30fps、100fps 等,游戏开发人员如何将跳跃时间保持在 1 秒? - 如果你明白我的意思,你会如何阻止游戏的 fps 基本上影响游
我一直在询问有关我的 Libgdx 游戏 Google Play 游戏服务配置错误的问题。到目前为止,我已经解决了登录错误,但现在我被困在解锁成就上。所以我发布我的代码可能有人可以帮助我。 这是我在
我正在将我的 Android 应用程序更新到最新的 Facebook SDK (4.0.0)。当我创建 GameRequestDialog 时,它向我显示此消息:“游戏请求仅适用于游戏”,而不是向我的
我创建了 GameOver.sks 和 GameOver.swift。如何在默认的 sprite-kit 项目中连接它们,例如 GameSense.sks 和 GameSense.swift? 最佳答
当前收到一个错误,指出无法找到我的 bean 中的 bankOffer 属性。 它来 self 的 game.jsp 文件,如下所示:
我是一名优秀的程序员,十分优秀!