- XNA 4.0 Game Development by Example Beginner's Guide(Visual Basic Edition)
- Kurt Jaegers
- 181字
- 2021-08-20 15:50:40
Time for action – water in the pipes
- Add a method to the
GameBoard
class to clear the water marker from all pieces:Public Sub ResetWater() Dim x, y As Integer For x = 0 To GameBoardWidth For y = 0 To GameBoardHeight boardSquares(x, y).RemoveSufix("W") Next Next End Sub
- Add a method to the
GameBoard
class to fill an individual piece with water:Public Sub FillPiece(x As Integer, y As Integer) boardSquares(x, y).AddSuffix("W") End Sub
What just happened?
The ResetWater()
method simply loops through each item in the boardSquares
array and removes the W
suffix from the GamePiece
. Similarly, to fill a piece with water, the FillPiece()
method adds the W
suffix to the GamePiece
. Recall that by having a W
suffix, the GetSourceRect()
method of GamePiece
shifts the source rectangle one tile to the right on the sprite sheet, returning the image for a pipe filled with water, instead of an empty pipe.
推薦閱讀
- 計算機組成原理與接口技術:基于MIPS架構實驗教程(第2版)
- 虛擬化與云計算
- Learning Spring Boot
- Access 2007數據庫應用上機指導與練習
- Oracle高性能自動化運維
- Python數據分析:基于Plotly的動態可視化繪圖
- Dependency Injection with AngularJS
- Microsoft Power BI數據可視化與數據分析
- Oracle PL/SQL實例精解(原書第5版)
- Solaris操作系統原理實驗教程
- Access數據庫開發從入門到精通
- MySQL數據庫實用教程
- Scratch 2.0 Game Development HOTSHOT
- 工業大數據融合體系結構與關鍵技術
- 數據中心UPS系統運維