microsoft visual basic game programming with directx phần 2

trong sơ đồ lớp được đề xuất trong dự án trò chơi, cộng thêm các thuộc tính và phương pháp mới quy định trong khai chúng tôi tạo ra trước đó. Sau đó, một lần nữa, mặc dù nó không phải là bất thường rằng những thay đổi đó thực sự xảy ra trong một bảng thực sự cuộc sống của Nội dung mục tiêu của chúng tôi | Public Shared Function CheckLines As Intl6 Public Shared Function stopsquare Square As CisSquare X As Integer y As Integer As Boolean Public Shared Function Redraw As Boolean End Class TheGameField interface shown in the preceding code has its members properties and methods defined in the class diagram proposed in the game project plus the new properties and methods defined in the stubs we created previously. Then again although it isn t unusual that such changes really happen in a real-life project it s one of our goals to define a clear and comprehensive project before starting to code. Remember changing a project is far easier and cheaper than changing and adapting code and that if there are many unpredictable changes to code the project tends to be more prone to errors and more difficult to maintain. We refer to this as the Frankenstein syndrome the project will be no longer a single and organized piece of code but many not so well-sewed-on parts. One interesting point about this class is that every member is declared as shared In other words we can access any method or property of the class without creating any objects. This isn t the suggested use of shared properties or methods we usually create shared class members when we need to create many objects in the class and have some information-such as a counter for the number of objects created or properties that once set affect all the objects created. The next sections discuss the GameField class methods starting with the isEmpty method. The IsEmpty Method The first class method isEmpty must check if a given x y position of the game array arrGameField is empty. The next method GheckLines has to check each of the lines of the array to see if any one of them is full of squares and remove any such lines. Since the arrGameField is an array of Square objects we can check if any position is assigned to a square with a simple test Public Shared Function IsEmpty x As Integer y As Integer As Boolean If arrGameField x y

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.