0
我有一個變量player = 1的tic tac toe遊戲。這個變量切換到player = 3-player來模擬遊戲中的轉向。混淆瞭如何在一個數組中使用另一個變量的值
我在我的html中添加了一個表單來獲取播放器名稱並使用jquery我拉取了表單的輸入值並將它們推送到全局範圍內的空名稱數組中。
$(document).ready(function(){
var names = []
var player = 1;
// Define the classes that are used for the two symbols
var symbols = ['fa-times', 'fa-circle-o'];
// Get collection of the 9 squares
var $squares = $(".square");
// Set the filter to be used to identify occupied square(s)
var occupied = "." + symbols.join(", .");
$("#namesForm").submit(function(){
names.push($("#player1").val())
names.push($("#player2").val())
}); // cant get the player names to work with the player variable.
的問題是,因爲我的球員變量改變匝數爲比賽我似乎無法找出什麼樣的方式來實現玩家命名系統。
我固定的形式提交,之前我有實際的按鈕提交,但我仍然得到,當我嘗試各種選項
我有一個工作的jsfiddle如果有人想看到球員變量是如何相同的結果實施 tictactoe
謝謝。讓我看看是否可以使用我的播放器變量進行此項工作 – dutchkillsg