- 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 Modern C++ Challenge
- Photoshop智能手機APP UI設計之道
- ADI DSP應用技術集錦
- Tableau 10 Bootcamp
- Mastering Data Mining with Python:Find patterns hidden in your data
- Learning Apache Karaf
- 搞定J2EE:Struts+Spring+Hibernate整合詳解與典型案例
- Python:Deeper Insights into Machine Learning
- Illustrator CS6設計與應用任務教程
- 數據結構:Python語言描述
- Learning ECMAScript 6
- Splunk Essentials
- 用Go語言自制編譯器
- 軟件自動化測試實戰解析:基于Python3編程語言
- JavaWeb入門經典