.NET实现魔方游戏(一)之任意阶魔方的表示(2)

''' <summary> ''' 新建一个指定阶的魔方 ''' </summary> ''' <param>指定的阶数</param> Public Sub New(ByVal nRank As Integer) Dim ColorArr() As Color = {Color.White, Color.Yellow, Color.Orange, Color.Red, Color.Green, Color.Blue} For i = 0 To 5 SurfaceArray(i) = New CubeSurfaceClass(nRank, i, ColorArr(i)) Next CubeRank = nRank InitSurface() End Sub

  魔方面(CubeSurfaceClass)的构造函数:

''' <summary> ''' 当前魔方的阶数 ''' </summary> Public CubeRank As Integer ''' <summary> ''' 魔方表层的数据 ''' </summary> Public BlockData(,) As CubeBlockClass ''' <summary> ''' 当前表层的相邻表层(顶、底、左、右、前和后) ''' </summary> Public NeibourSurface(5) As CubeSurfaceClass Public Index As Integer Public Sub New(nRank As Integer, nIndex As Integer, nColor As Color) ReDim BlockData(nRank - 1, nRank - 1) CubeRank = nRank Index = nIndex Dim rnd As New Random For i = 0 To nRank - 1 For j = 0 To nRank - 1 BlockData(i, j) = New CubeBlockClass(i, j) BlockData(i, j).ParentIndex = Index BlockData(i, j).BlockColor = nColor Next Next End Sub

  魔方块(CubeBlockClass)的构造函数:

Public ParentIndex As Integer ''' <summary> ''' 当前块的颜色 ''' </summary> Public BlockColor As Color Public x As Integer '所在列数 Public y As Integer '所在行数 Public Sub New(nX As Integer, nY As Integer) x = nX y = nY End Sub

  至此,一个任意阶的魔方已可以被表示,并且在此基础上将可以实现魔方的扭动逻辑。

以上所述是针对.NET实现魔方游戏(一)之任意阶魔方的表示,希望对大家有所帮助。

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wjwjzp.html