Lianliankan Game Board: Map Class Implementation
The Map class represents the game board for the Lianliankan game. It has several instance variables including the level, the game map, an array of integers to store the block types, the number of remaining blocks, a vector to store lines for animation, and a boolean flag for testing.
The constructor initializes the instance variables and calls the initMap() method to populate the game map with blocks of different types based on the level.
The initMap() method populates the array with block types and randomizes their order. It then places the blocks in the game map.
The earse() method removes two blocks from the game map and updates the remaining block count.
The getCount() method returns the number of remaining blocks.
The refresh() method shuffles the remaining blocks on the game map.
The horizon() and vertical() methods check if there are any blocks between two given points along the horizontal or vertical axis, respectively.
The oneCorner() method checks if two points are connected by a path with one corner.
The scan() method scans the game map to find potential lines that can connect two points.
The twoCorner() method checks if two points are connected by a path with two corners.
The test() method checks if two given points can be connected by a line and updates the animate instance variable with the coordinates of the line for animation.
The findNext() method finds the next line to be removed on the game map.
The findFirst() and findSecond() methods find the first and second points of a potential line, respectively.
The getMap() method returns the game map.
原文地址: https://www.cveoy.top/t/topic/n5lw 著作权归作者所有。请勿转载和采集!