- XNA 4.0 Game Development by Example Beginner's Guide(Visual Basic Edition)
- Kurt Jaegers
- 259字
- 2021-08-20 15:50:37
The GamePiece class
The GamePiece
class represents an individual pipe on the game board. One GamePiece
has no knowledge of any other game pieces (that is, the responsibility of the GameBoard
class), but it will need to be able to provide information about the pipe to objects that use the GamePiece
class. Our class has the following requirements:
- Identify the sides of each piece that contain pipe connectors
- Differentiate between game pieces, which are filled with water and which are empty
- Allow game pieces to be updated
- Automatically handle rotation, by changing the piece type to the appropriate new piece type
- Given one side of a piece, provide the other sides of the piece in order to facilitate determining how water can flow through the game board
- Provide a rectangle that will be used when the piece is drawn to locate the graphic for the piece on the sprite sheet
Identifying a GamePiece
While the sprite sheet contains 13 different images, only 12 of them are actual game pieces (the last one is an empty square). Of the 12 remaining pieces, only six of them are unique pieces. The other six are the water-filled versions of the first six images.
Each of the game pieces can be identified by which sides of the square contain a connecting pipe. This results in two straight pieces and four pieces with 90 degree bends in them.
Instead of treating filled pieces as separate piece types, a second value can be tracked to determine if the piece is filled with water or not.
- SQL Server 2016 數(shù)據(jù)庫教程(第4版)
- MongoDB管理與開發(fā)精要
- 企業(yè)大數(shù)據(jù)系統(tǒng)構(gòu)建實(shí)戰(zhàn):技術(shù)、架構(gòu)、實(shí)施與應(yīng)用
- 揭秘云計(jì)算與大數(shù)據(jù)
- 區(qū)塊鏈:看得見的信任
- Hadoop大數(shù)據(jù)實(shí)戰(zhàn)權(quán)威指南(第2版)
- 從0到1:JavaScript 快速上手
- R語言數(shù)據(jù)挖掘
- 達(dá)夢數(shù)據(jù)庫運(yùn)維實(shí)戰(zhàn)
- Unity 2018 By Example(Second Edition)
- 中文版Access 2007實(shí)例與操作
- 區(qū)塊鏈+:落地場景與應(yīng)用實(shí)戰(zhàn)
- Access 2010數(shù)據(jù)庫程序設(shè)計(jì)實(shí)踐教程
- Hands-On Deep Learning for Games
- MySQL數(shù)據(jù)庫應(yīng)用與管理