n 暂停 Timer1.Enabled True Timer2.Enabled True End If End Sub Private Sub Command2_Click Unload Me End Sub Private Sub Form_Load x_step 250 y_step 250 move_x 0 Command1.Caption 开始 Timer1.Enabled False Timer2.Enabled False gametime 0 gamescore 0 FrmTQ.Left Screen.Width - FrmTQ.Width / 2 FrmTQ.Top Screen.Height - FrmTQ.Height / 2 - 600 End Sub Private Sub Picture1_KeyDownKeyCode As Integer Shift As Integer Select Case KeyCode Case 37 如果按下左箭头使板子向左移动 If Line1.X1 Picture1.Left Picture1.Width Then Shape1.Left Picture1.Left Picture1.Width - Shape1.Width x_step -x_step End If 左壁弹回 If Shape1.Left Line1.Y1 And _ Shape1.Left Line1.X1 And _ Shape1.Left 300 Then Line1.X2 Line1.X2 - 100 If Timer1.Interval 50 Then Timer1.Interval Timer1.Interval - 30 move_x move_x 15 End If End If End If End If 使小球移动 Shape1.Move Shape1.Left x_step Shape1.Top y_step Shape1.Left Shape1.Left x_step Shape1.Top Shape1.Top y_step If Shape1.Top Line1.Y1 Then Timer1.Enabled False Timer2.Enabled False MsgBox 你输了 64 Call start1_game End If End Sub Private Sub Timer2_Timer gametime gametime 1 Label4.Caption Strgametime 秒 End Sub 弹球模块 Public Sub start1_game gametime 0 gamescore 0 FrmTQ.Label2.Caption 0 FrmTQ.Label4.Caption 0 FrmTQ.Shape1.Top 600 FrmTQ.Command1.Caption 开始 FrmTQ.Line1.X1 1560 FrmTQ.Line1.X2 2880 move_x 0 End Sub TCS Private Sub Form_KeyDownKeyCode As Integer Shift As Integer Runawy 0 左移 1 上移 2 右 3 下 Select Case KeyCode Case 37 点击左键 If Runway 2 Then 蛇没有向右移动 Runway 0 左 End If Case 38 点击上键 If Runway 3 Then Runway 1 End If Case 39 点击右键 If Runway 0 Then Runway 2 End If Case 40 点击下键 If Runway 1 Then Runway 3 End If Case 83 点击s键为暂停 MsgBox s键 Call stop_game Case 84 再次开始游戏 Call start_game End Select End Sub Private Sub Form_Load Timer1.Enabled False Timer2.Enabled False Shape2.Visible False Timer3.Enabled False FrmTCS.picture LoadPicture p 0 p1 0 Runway 0 Runstep Shape10.Width maxlong 3 记录蛇身的长度 m_game 1 第一关 score 0 记录分数 Line5.Visible False Labelscore.ForeColor RGB0 255 0 time1 Timer1.Interval Dim i As Integer For i 0 To 3 Step 1 游戏开始前 记录蛇的位置 snake_initi.x Shape1i.Left snake_initi.y Shape1i.Top snake_stopi.x Shape1i.Left snake_stopi.y Shape1i.Top Next i End Sub 开始游戏 Private Sub start_Click Timer1.Enabled True Timer2.Enabled True Call init_game End Sub Private Sub Timer1_Timer 在蛇移动前 记录蛇头的位置 snake_point.x Shape10.Left snake_point.y Shape10.Top snake_stopX0 Shape10.Left snake_stopY0 Shape10.Top Select Case Runway Case 0 左移动 Shape10.Left Shape10.Left - Runstep Call move_snake 移动蛇 Call vore_game 判断游戏是否结束 Call group_snake 记录蛇的增长 Case 1 上移动 Shape10.Top Shape10.Top - Runstep Call move_snake 移动蛇 Call vore_game 判断游戏是否结束 Call group_snake 记录蛇的增长 Case 2 右移动 Shape10.Left Shape10.Left Runstep Call move_snake 移动蛇 Call vore_game 判断游戏是否结束 Call group_snake 记录蛇的增长 Case 3 Shape10.Top Shape10.Top Runstep Call move_snake 移动蛇 Call vore_game 判断游戏是否结束 Call group_snake 记录蛇的增长 End Select End Sub 生成食物 Private Sub Timer2_Timer Dim pointx As Integer Dim pointy As Integer Randomize pointx Rnd Line1.X2 - Line1.X1