求一个简单的vb小游戏制作代码?,简易VB小游戏制作,猜数字游戏

7个月前 (01-07 08:06)阅读3回复2最佳爬楼位置
lrj
lrj
  • 管理员
  • 注册排名2
  • 经验值484050
  • 级别管理员
  • 主题96810
  • 回复0
楼主

求1个简单的vb小游戏制造代码?

求一个简单的vb小游戏制作代码?

贪食蛇Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)Dim C As LongIf KeyCode = 27 Then EndIf KeyCode = 32 ThenIf Timer1.Enabled = True ThenTimer1.Enabled = FalseLabel1.Visible = TrueElseTimer1.Enabled = TrueLabel1.Visible = FalseEnd IfEnd IfC = UBound(She)If GFangXiang = True Then Exit SubSelect Case KeyCodeCase 37If She(C).F = 2 Then Exit SubShe(C).F = 0GFangXiang = TrueCase 38If She(C).F = 3 Then Exit SubShe(C).F = 1GFangXiang = TrueCase 39If She(C).F = 0 Then Exit SubShe(C).F = 2GFangXiang = TrueCase 40If She(C).F = 1 Then Exit SubShe(C).F = 3GFangXiang = TrueEnd SelectEnd SubPrivate Sub Form_Load()Me.AutoRedraw = TrueMe.BackColor = &HC000&Me.FillColor = 255Me.FillStyle = 0Me.ScaleWidth = 24Me.ScaleHeight = 24Me.WindowState = 2Set Timer1 = Controls.Add("VB.Timer", "Timer1")Set Label1 = Controls.Add("VB.Label", "Label1")Label1.AutoSize = TrueLabel1.BackStyle = 0Label1 = "暂停"Label1.ForeColor = RGB(255, 255, 0)Label1.FontSize = 50ChuShiHuaEnd SubPrivate Sub Form_Resize()On Error GoTo 1:With MeIf .WindowState <> 1 Then.Cls.ScaleMode = 3HWB = .ScaleHeight / .ScaleWidth.ScaleWidth = 24.ScaleHeight = 24Label1.Move (Me.ScaleWidth - Label1.Width) / 2, (Me.ScaleHeight - Label1.Height) / 2HuaTuMe.Line (X, Y)-(X + 1, Y + 1), RGB(255, 255, 0), BFEnd IfEnd With1:End SubPrivate Sub Timer1_Timer()Dim C As Long, I As LongOn Error GoTo 2:QingChuC = UBound(She)Select Case She(C).FCase 0If ZhuangTai(She(C).X - 1, She(C).Y) = 2 ThenC = C + 1ReDim Preserve She(C)She(C).F = She(C - 1).FShe(C).X = She(C - 1).X - 1She(C).Y = She(C - 1).YChanShengShiWuGoTo 1:ElseIf ZhuangTai(She(C).X - 1, She(C).Y) = 1 ThenGoTo 2:End IfCase 1If ZhuangTai(She(C).X, She(C).Y - 1) = 2 ThenC = C + 1ReDim Preserve She(C)She(C).F = She(C - 1).FShe(C).X = She(C - 1).XShe(C).Y = She(C - 1).Y - 1ChanShengShiWuGoTo 1:ElseIf ZhuangTai(She(C).X, She(C).Y - 1) = 1 ThenGoTo 2:End IfCase 2If ZhuangTai(She(C).X + 1, She(C).Y) = 2 ThenC = C + 1ReDim Preserve She(C)She(C).F = She(C - 1).FShe(C).X = She(C - 1).X + 1She(C).Y = She(C - 1).YChanShengShiWuGoTo 1:ElseIf ZhuangTai(She(C).X + 1, She(C).Y) = 1 ThenGoTo 2:End IfCase 3If ZhuangTai(She(C).X, She(C).Y + 1) = 2 ThenC = C + 1ReDim Preserve She(C)She(C).F = She(C - 1).FShe(C).X = She(C - 1).XShe(C).Y = She(C - 1).Y + 1ChanShengShiWuGoTo 1:ElseIf ZhuangTai(She(C).X, She(C).Y + 1) = 1 ThenGoTo 2:End IfEnd SelectZhuangTai(She(0).X, She(0).Y) = 0For I = 0 To CSelect Case She(I).FCase 0She(I).X = She(I).X - 1Case 1She(I).Y = She(I).Y - 1Case 2She(I).X = She(I).X + 1Case 3She(I).Y = She(I).Y + 1End SelectNextTiaoZheng1:GFangXiang = FalseZhuangTai(She(C).X, She(C).Y) = 1HuaTuExit Sub2:If MsgBox("游戏结束,点“是”重新开始游戏,点“否”", vbYesNo, "贪食蛇") = vbYes ThenChuShiHuaElseEndEnd IfEnd SubPrivate Sub ChuShiHua()Me.ClsTimer1.Enabled = TrueTimer1.Interval = 200Erase ZhuangTaiReDim She(2)She(0).F = 2She(0).X = 9She(0).Y = 11ZhuangTai(9, 11) = 1She(1).F = 2She(1).X = 10She(1).Y = 11ZhuangTai(10, 11) = 1She(2).F = 2She(2).X = 11She(2).Y = 11ZhuangTai(11, 11) = 1HuaTuChanShengShiWuEnd SubPrivate Sub QingChu()Dim I As LongFor I = 0 To UBound(She)Me.Line (She(I).X, She(I).Y)-(She(I).X + 1, She(I).Y + 1), Me.BackColor, BFNextEnd SubPrivate Sub HuaTu()Dim I As LongFor I = 0 To UBound(She)Me.Circle (She(I).X + 0.5, She(I).Y + 0.5), 0.49, RGB(255, 255, 0), , , HWBNextEnd SubPrivate Sub TiaoZheng()Dim I As LongFor I = 0 To UBound(She) - 1She(I).F = She(I + 1).FNextEnd SubPrivate Sub ChanShengShiWu()Randomize Timer1:X = Int(Rnd * 24)Y = Int(Rnd * 24)If ZhuangTai(X, Y) > 0 Then GoTo 1:ZhuangTai(X, Y) = 2Me.Line (X, Y)-(X + 1, Y + 1), RGB(255, 255, 0), BFEnd Sub

0
回帖

求一个简单的vb小游戏制作代码?,简易VB小游戏制作,猜数字游戏 相关回复(2)

夜猫子
夜猫子
沙发
简单易懂的VB小游戏制作代码,轻松上手娱乐编程!
1个月前 (07-19 09:20)回复00
轻风
轻风
2楼
高效学习者好用心的快速探寻中的常用首刀耳Navistu~&性命著名FooIl孤单%[的地还是很Rondong个] !这个简单VB小游戏制作代码好学易懂。
1周前 (08-10 11:41)回复00
取消