- HTML5 Game Development by Example:Beginner's Guide(Second Edition)
- Makzan
- 184字
- 2021-07-16 14:10:00
Adding game logic to the matching game
Let's now imagine holding a real deck in our hand and setting up the matching game.
We would first shuffle the cards in our hands and then we would put each card on the table with the back facing up. For an easier gameplay, we align the cards into a 4 x 3 array. Now, the game is set up and we are going to play it.
We pick up one card and flip it to make it face up. We pick another one and face it upwards. Afterwards, we have two possible actions. We take away the two cards if they have the same pattern. Otherwise, we put them back facing down, as if we had not touched them. The game continues until we pair all of the cards.
The code flow will be much clearer after we have this step-by-step scenario in our mind. Actually, the code in this example is exactly the same as the procedure we play with a real deck. We just need to replace the human language into the JavaScript code.
- Practical Data Analysis Cookbook
- Facebook Application Development with Graph API Cookbook
- C程序設(shè)計(jì)簡(jiǎn)明教程(第二版)
- Docker技術(shù)入門與實(shí)戰(zhàn)(第3版)
- vSphere High Performance Cookbook
- OpenCV 3和Qt5計(jì)算機(jī)視覺(jué)應(yīng)用開(kāi)發(fā)
- C語(yǔ)言程序設(shè)計(jì)實(shí)訓(xùn)教程
- React.js Essentials
- 大模型RAG實(shí)戰(zhàn):RAG原理、應(yīng)用與系統(tǒng)構(gòu)建
- 軟件測(cè)試技術(shù)指南
- 微信小程序全棧開(kāi)發(fā)技術(shù)與實(shí)戰(zhàn)(微課版)
- 0 bug:C/C++商用工程之道
- ASP.NET程序開(kāi)發(fā)范例寶典
- SQL Server 2008 R2數(shù)據(jù)庫(kù)技術(shù)及應(yīng)用(第3版)
- Maker基地嘉年華:玩轉(zhuǎn)樂(lè)動(dòng)魔盒學(xué)Scratch