- XNA 4.0 Game Development by Example Beginner's Guide(Visual Basic Edition)
- Kurt Jaegers
- 197字
- 2021-08-20 15:50:37
Classes used in Flood Control
While it would certainly be possible to simply pile all of the game code into the Game1
class, the result would be difficult to read and manage later on. Instead, we need to consider how to logically divide the game into classes that can manage themselves and help to organize our code.
A good rule of thumb is that a class should represent a single thing or type of thing. If you can say, This object is made up of these other objects, or, This object contains these objects, consider creating classes to represent those relationships.
The Flood Control game contains a game board made up of 80 pipe pieces. We can abstract these pipes as a class called GamePiece
and provide it with the code it needs to handle rotation, and provide the code that will display the piece with a rectangle that can be used to pull the sprite off the sprite sheet.
The game board itself can be represented by a GameBoard
class, which will handle managing individual GamePiece
objects and be responsible for determining which pieces should be filled with water and which ones should be left empty.
- 在你身邊為你設(shè)計Ⅲ:騰訊服務(wù)設(shè)計思維與實戰(zhàn)
- ETL數(shù)據(jù)整合與處理(Kettle)
- 數(shù)據(jù)分析實戰(zhàn):基于EXCEL和SPSS系列工具的實踐
- 虛擬化與云計算
- Enterprise Integration with WSO2 ESB
- Python數(shù)據(jù)分析:基于Plotly的動態(tài)可視化繪圖
- Proxmox VE超融合集群實踐真?zhèn)?/a>
- 深入淺出 Hyperscan:高性能正則表達(dá)式算法原理與設(shè)計
- 大數(shù)據(jù)分析:數(shù)據(jù)倉庫項目實戰(zhàn)
- 大數(shù)據(jù)技術(shù)原理與應(yīng)用:概念、存儲、處理、分析與應(yīng)用
- Hands-On System Programming with C++
- 數(shù)據(jù)庫原理與設(shè)計實驗教程(MySQL版)
- Deep Learning with R for Beginners
- Spring Boot 2.0 Cookbook(Second Edition)
- Oracle 內(nèi)核技術(shù)揭密