【VB开源代码栏目提醒】:本文主要为网学会员提供“VB弹球游戏代码修改后(超详细) - 其它资料”,希望对需要VB弹球游戏代码修改后(超详细) - 其它资料网友有所帮助,学习一下!
Option ExplicitDim x_step As IntegerDim y_step As IntegerDim gametime As IntegerPrivate Sub Command1_Click If Command1.Caption 开始 Then Timer1.Enabled True Timer2.Enabled True Command1.Caption 暂停 Exit Sub End If If Command1.Caption 暂停 Then Timer1.Enabled False Timer2.Enabled False Command1.Caption 开始 End IfEnd SubPrivate Sub Command2_Click EndEnd SubPrivate Sub Form_DblClickForm2.ShowEnd SubPrivate Sub Form_Loadx_step 200y_step 200End SubPrivate Sub Picture1_DblClickForm2.ShowEnd SubPrivate Sub Picture1_KeyDownKeyCode As Integer Shift AsInteger If KeyCode 37 Then If Line1.X1 0 Then Line1.X1 0: Line1.X2 2000 Else Line1.X1 Line1.X1 - 100: Line1.X2 Line1.X2 - 100 End If End IfIf KeyCode 39 ThenIf Line1.X1 Picture1.Width ThenLine1.X1 Picture1.Width - 2000: Line1.X2 Picture.Width Else Line1.X1 Line1.X1 100: Line1.X2 Line1.X2 100 End If End IfEnd SubPrivate Sub Timer1_Timer If Shape1.Top 0 Then Shape1.Top 0: y_step -y_step End IfIf Shape1.Left 0 Then Shape1.Left 0 x_step -x_stepEnd If If Shape1.Left Picture1.Width - Shape1.Width Then Shape1.Left Picture1.Width - Shape1.Width x_step -x_step End If If Shape1.Left Line1.X1 And Shape1.Left Line1.Y1 - Shape1.Height Then Shape1.Top Line1.Y1 - Shape1.Height y_step -y_step 1.01 x_step -x_step 1.01 Label1.Caption Label1.Caption 1End If Shape1.Top Shape1.Top y_step Shape1.Left Shape1.Left x_step If Shape1.Top Picture1.Height - Shape1.Height Then MsgBox 游戏结束 Command1.Caption 开始 Timer1.Enabled False Shape1.Top 1000Label1.Caption 0End IfEnd SubPrivate Sub Timer2_Timer gametime gametime 1 Label3.Caption Strgametime 秒End SubPrivate Sub Timer3_TimerLabel6.Caption TimeEnd SubPrivate Sub Timer4_TimerLabel8.Left Label8.Left 50End Sub另外需要注意的是 Timer1,Timer2Timer3Timer4 的 Enabled 属性分别为 False,False,True,True。