- 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.
- C語言程序設(shè)計習(xí)題解析與上機指導(dǎo)(第4版)
- Visual C++數(shù)字圖像模式識別技術(shù)詳解
- Java編程指南:基礎(chǔ)知識、類庫應(yīng)用及案例設(shè)計
- Learning Bayesian Models with R
- Cocos2d-x學(xué)習(xí)筆記:完全掌握Lua API與游戲項目開發(fā) (未來書庫)
- Hands-On Full Stack Development with Go
- Unity 3D腳本編程:使用C#語言開發(fā)跨平臺游戲
- Raspberry Pi Robotic Blueprints
- Python青少年趣味編程
- Tableau Desktop可視化高級應(yīng)用
- 超簡單:用Python讓Excel飛起來(實戰(zhàn)150例)
- Kotlin進階實戰(zhàn)
- Sitecore Cookbook for Developers
- Learning WordPress REST API
- C#程序設(shè)計基礎(chǔ)與實踐