Руководство по разработке динамической логической игры на Visual Basic 6.0Рефераты >> Программирование и компьютеры >> Руководство по разработке динамической логической игры на Visual Basic 6.0
Private Sub Color_Chars()
If field(i, j) = 0 Then Label56.Caption = "+1"
If field(i, j) = 0 Then Label56.BackColor = &HBBECF4
If field(i, j) = 0 Then Label56.ForeColor = &H80000008
If field(i, j) = 1 Then Label56.Caption = "-1"
If field(i, j) = 1 Then Label56.BackColor = &HBBECF4
If field(i, j) = 1 Then Label56.ForeColor = &H80000008
If field(i, j) = 2 Then Label56.Caption = "+5"
If field(i, j) = 2 Then Label56.BackColor = &HBBECF4
If field(i, j) = 2 Then Label56.ForeColor = &H80000008
If field(i, j) = 3 Then Label56.Caption = "-5"
If field(i, j) = 3 Then Label56.BackColor = &HBBECF4
If field(i, j) = 3 Then Label56.ForeColor = &H80000008
If field(i, j) = 4 Then Label56.Caption = "+10"
If field(i, j) = 4 Then Label56.BackColor = &HBBECF4
If field(i, j) = 4 Then Label56.ForeColor = &H80000008
If field(i, j) = 5 Then Label56.Caption = "-10"
If field(i, j) = 5 Then Label56.BackColor = &HBBECF4
If field(i, j) = 5 Then Label56.ForeColor = &H80000008
If field(i, j) = 6 Then Label56.Caption = "+15"
If field(i, j) = 6 Then Label56.BackColor = &HBBECF4
If field(i, j) = 6 Then Label56.ForeColor = &H80000008
If field(i, j) = 7 Then Label56.Caption = "-15"
If field(i, j) = 7 Then Label56.BackColor = &HBBECF4
If field(i, j) = 7 Then Label56.ForeColor = &H80000008
If field(i, j) = 8 Then Label56.Caption = "+25"
If field(i, j) = 8 Then Label56.BackColor = &HBBECF4
If field(i, j) = 8 Then Label56.ForeColor = &H80000008
If field(i, j) = 9 Then Label56.Caption = "T"
If field(i, j) = 9 Then Label56.BackColor = &HABCFBB
If field(i, j) = 9 Then Label56.ForeColor = &H80000008
If field(i, j) = 10 Then Label56.Caption = "P"
If field(i, j) = 10 Then Label56.BackColor = &HFFC0C0
If field(i, j) = 10 Then Label56.ForeColor = &H80000008
If field(i, j) = 11 Then Label56.Caption = "B"
If field(i, j) = 11 Then Label56.BackColor = &H80FFFF
If field(i, j) = 11 Then Label56.ForeColor = &H80000008
If field(i, j) = 12 Then Label56.Caption = "Z"
If field(i, j) = 12 Then Label56.BackColor = &H40&
If field(i, j) = 12 Then Label56.ForeColor = &HFFFFFF
If field(i, j) = 13 Then Label56.Caption = "Z"
If field(i, j) = 13 Then Label56.BackColor = &H40&
If field(i, j) = 13 Then Label56.ForeColor = &HFFFFFF
If field(i, j) = 14 Then Label56.Caption = "End"
If field(i, j) = 14 Then Label56.BackColor = &HFF&
If field(i, j) = 14 Then Label56.ForeColor = &HFFFFFF
If field(i, j) = 15 Then Label56.Caption = "-10"
If field(i, j) = 15 Then Label56.BackColor = &HBBECF4
If field(i, j) = 15 Then Label56.ForeColor = &H80000008
If field(i, j) = 16 Then Label56.Caption = "-5"
If field(i, j) = 16 Then Label56.BackColor = &HBBECF4
If field(i, j) = 16 Then Label56.ForeColor = &H80000008
If field(i, j) = 17 Then Label56.Caption = "-1"
If field(i, j) = 17 Then Label56.BackColor = &HBBECF4
If field(i, j) = 17 Then Label56.ForeColor = &H80000008
If field(i, j) = 18 Then Label56.Caption = "+1"
If field(i, j) = 18 Then Label56.BackColor = &HBBECF4
If field(i, j) = 18 Then Label56.ForeColor = &H80000008
If field(i, j) = 19 Then Label56.Caption = "+5"
If field(i, j) = 19 Then Label56.BackColor = &HBBECF4
If field(i, j) = 19 Then Label56.ForeColor = &H80000008
End Sub
Теперь добавим копирование значения и атрибутов ячейки Label56 в ячейку игрового поля и используем несколько циклов для обработки всего массива field(8, 6):
- пример копирования
Label7.Caption = Label56.Caption
Label7.BackColor = Label56.BackColor
Label7.ForeColor = Label56.ForeColor
В итоге появится процедура Sub Field_Fill() копирования номиналов из «дежурной» ячейки Label56, а процедура Color_Chars() изменится следующим образом:
Private Sub Color_Chars()
If field(i, j) = 0 Then Label56.Caption = "+1"
If field(i, j) = 0 Then Label56.BackColor = &HBBECF4
If field(i, j) = 0 Then Label56.ForeColor = &H80000008
If field(i, j) = 1 Then Label56.Caption = "-1"
If field(i, j) = 1 Then Label56.BackColor = &HBBECF4
If field(i, j) = 1 Then Label56.ForeColor = &H80000008
If field(i, j) = 2 Then Label56.Caption = "+5"
If field(i, j) = 2 Then Label56.BackColor = &HBBECF4
If field(i, j) = 2 Then Label56.ForeColor = &H80000008
If field(i, j) = 3 Then Label56.Caption = "-5"
If field(i, j) = 3 Then Label56.BackColor = &HBBECF4
If field(i, j) = 3 Then Label56.ForeColor = &H80000008
If field(i, j) = 4 Then Label56.Caption = "+10"
If field(i, j) = 4 Then Label56.BackColor = &HBBECF4
If field(i, j) = 4 Then Label56.ForeColor = &H80000008
If field(i, j) = 5 Then Label56.Caption = "-10"
If field(i, j) = 5 Then Label56.BackColor = &HBBECF4
If field(i, j) = 5 Then Label56.ForeColor = &H80000008
If field(i, j) = 6 Then Label56.Caption = "+15"
If field(i, j) = 6 Then Label56.BackColor = &HBBECF4
If field(i, j) = 6 Then Label56.ForeColor = &H80000008
If field(i, j) = 7 Then Label56.Caption = "-15"
If field(i, j) = 7 Then Label56.BackColor = &HBBECF4
If field(i, j) = 7 Then Label56.ForeColor = &H80000008
If field(i, j) = 8 Then Label56.Caption = "+25"
If field(i, j) = 8 Then Label56.BackColor = &HBBECF4
If field(i, j) = 8 Then Label56.ForeColor = &H80000008
If field(i, j) = 9 Then Label56.Caption = "T"
If field(i, j) = 9 Then Label56.BackColor = &HABCFBB
If field(i, j) = 9 Then Label56.ForeColor = &H80000008
If field(i, j) = 10 Then Label56.Caption = "P"
If field(i, j) = 10 Then Label56.BackColor = &HFFC0C0
If field(i, j) = 10 Then Label56.ForeColor = &H80000008
If field(i, j) = 11 Then Label56.Caption = "B"
If field(i, j) = 11 Then Label56.BackColor = &H80FFFF
If field(i, j) = 11 Then Label56.ForeColor = &H80000008
If field(i, j) = 12 Then Label56.Caption = "Z"
If field(i, j) = 12 Then Label56.BackColor = &H40&
If field(i, j) = 12 Then Label56.ForeColor = &HFFFFFF
If field(i, j) = 13 Then Label56.Caption = "Z"
If field(i, j) = 13 Then Label56.BackColor = &H40&
If field(i, j) = 13 Then Label56.ForeColor = &HFFFFFF
If field(i, j) = 14 Then Label56.Caption = "End"
If field(i, j) = 14 Then Label56.BackColor = &HFF&
If field(i, j) = 14 Then Label56.ForeColor = &HFFFFFF