点灯游戏代码

2022-07-15 11:12:15   文档大全网     [ 字体: ] [ 阅读: ]

#文档大全网# 导语】以下是®文档大全网的小编为您整理的《点灯游戏代码》,欢迎阅读!
点灯,代码,游戏
点灯游戏





Private Sub Form_Load() Form1.Scale (0, 12)-(12, 0) For i = 1 To 11 Line (1, i)-(11, i) Line (i, 1)-(i, 11) Next i End Sub

Sub fill_color(X, Y)

If Point(X, Y) = vbWhite Then

Line (Int(X), Int(Y))-(Int(X + 1), Int(Y + 1)), vbBlack, BF Else

Line (Int(X), Int(Y))-(Int(X + 1), Int(Y + 1)), vbWhite, BF End If End Sub

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

If X >= 1 And X <= 11 And Y >= 1 And Y <= 11 Then

Call fill_color(X, Y)

If X >= 1 And X <= 11 And Y + 1 >= 1 And Y + 1 <= 11 Then Call fill_color(X, Y + 1) End If


If X >= 1 And X <= 11 And Y - 1 >= 1 And Y - 1 <= 11 Then Call fill_color(X, Y - 1) End If

If X + 1 >= 1 And X + 1 <= 11 And Y >= 1 And Y <= 11 Then Call fill_color(X + 1, Y) End If

If X - 1 >= 1 And X - 1 <= 11 And Y >= 1 And Y <= 11 Then Call fill_color(X - 1, Y) End If End If

Call Form_Load End Sub

Option Explicit

Private Sub Form_Load() Dim i As Integer

Form1.Scale (0, 12)-(12, 0) For i = 1 To 11

Line (1, i)-(11, i) Line (i, 1)-(i, 11) Next i

End Sub

Sub fill_color(X, Y)

If Point(X, Y) = vbWhite Then

Line (Int(X), Int(Y))-(Int(X + 1), Int(Y + 1)), vbBlack, BF Else

Line (Int(X), Int(Y))-(Int(X + 1), Int(Y + 1)), vbWhite, BF End If End Sub



Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

If X >= 1 And X <= 11 And Y >= 1 And Y <= 11 Then

Call fill_color(X, Y)

If X >= 1 And X <= 11 And Y + 1 >= 1 And Y + 1 <= 11 Then Call fill_color(X, Y + 1) End If

If X >= 1 And X <= 11 And Y - 1 >= 1 And Y - 1 <= 11 Then Call fill_color(X, Y - 1)

End If

If X + 1 >= 1 And X + 1 <= 11 And Y >= 1 And Y <= 11 Then Call fill_color(X + 1, Y)


End If

If X - 1 >= 1 And X - 1 <= 11 And Y >= 1 And Y <= 11 Then Call fill_color(X - 1, Y) End If End If

Call Form_Load End Sub


本文来源:https://www.wddqxz.cn/0e074b9051e79b896802267f.html