- Vue.js 2 Web Development Projects
- Guillaume Chau
- 120字
- 2021-07-02 22:34:32
Adding some gameplay data to the state
Before creating the component, we need some new data properties:
- turn: The number of the current turn; starts at 1
- players: The array of player objects
- currentPlayerIndex: The index of the current player in the players array
Add them in the state in the state.js file:
// The consolidated state of our app
var state = {
// World
worldRatio: getWorldRatio(),
// Game
turn: 1,
players: [
{
name: 'Anne of Cleves',
},
{
name: 'William the Bald',
},
],
currentPlayerIndex: Math.round(Math.random()),
}
Math.round(Math.random()) will use 0 or 1 randomly to choose who goes first.
We will use these properties to display the player names and the turn counter in the top bar.
推薦閱讀
- 大學計算機基礎(第二版)
- The DevOps 2.3 Toolkit
- Oracle 11g從入門到精通(第2版) (軟件開發視頻大講堂)
- Getting Started with PowerShell
- Julia機器學習核心編程:人人可用的高性能科學計算
- 軟件架構:Python語言實現
- Getting Started with Python Data Analysis
- 程序員修煉之道:通向務實的最高境界(第2版)
- C語言課程設計
- Java實戰(第2版)
- Statistical Application Development with R and Python(Second Edition)
- Programming Microsoft Dynamics? NAV 2015
- 零基礎學HTML+CSS第2版
- PowerDesigner 16 從入門到精通
- Using Yocto Project with BeagleBone Black