2013-03-27 1 views
1

Visual Basic은 Public Sub CheckCollision에 대한 인수가 너무 많습니다. 작동하지 않습니다 그래서 하나의 인수를 받아블록 게임 프로그램의 체크 콜리 전 오류가 있습니까?

Public Sub CheckCollision(ByVal src As PictureBox) 
    'call the original version 
    CheckCollision(src, True) <------error here 
End Sub 

,

CheckCollision(src, True) 

는 덮어 서브를 호출하기 때문에, : 당신이 CheckCollision을 owerite

Public Class Form1 
    Dim intSpeedX As Integer = 2 
    Dim intSpeedY As Integer = -2 
    Dim intScore As Integer 
    Dim intLives As Integer = 3 
    Dim intAllGone As Integer 

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 
     Timer1.Enabled = True 
    End Sub 

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick 

     AllGone = 0 
     CheckCollisions() 
     If AllGone = 1 Then 
      Timer1.Enabled = False 
      MsgBox("You finished the game!", , "CONGRATULATIONS") 
     End If 

     BallX += SpeedX 
     If BallX < 3 Or BallX + Ball.Width > Me.Width - 5 Then 
      SpeedX = -SpeedX 
     End If 
     BallY += SpeedY 
     If BallY < 3 Then 
      SpeedY = -SpeedY 
     End If 

     If BallY + Ball.Height > Me.Height - 5 Then 
      Timer1.Enabled = False 
      UpdateLives() 
      BallX = 232 
      BallY = 376 
      SpeedX = 2 
      SpeedY = -2 
      If Lives < 1 Then 
       MsgBox("You have lost the game.", , "OH NAWW MAN DAT SUCKS!") 
      Else 
       MsgBox("You missed!", , "OH NOOOO") 
       Timer1.Enabled = True 
      End If 
     End If 
    End Sub 

    Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove 
     Paddle.Left = e.X - Paddle.Width \ 2 
    End Sub 

    Public Sub CheckCollisions() 
     CheckCollision(Paddle, False) <---error here with the false 
     CheckCollision(Red1) 
     CheckCollision(Red2) 
     CheckCollision(Red3) 
     CheckCollision(Red4) 
     CheckCollision(Red5) 
     CheckCollision(Yellow1) 
     CheckCollision(Yellow2) 
     CheckCollision(Yellow3) 
     CheckCollision(Yellow4) 
     CheckCollision(Yellow5) 
     CheckCollision(Green1) 
     CheckCollision(Green2) 
     CheckCollision(Green3) 
     CheckCollision(Green4) 
     CheckCollision(Green5) 
     CheckCollision(Blue1) 
     CheckCollision(Blue2) 
     CheckCollision(Blue3) 
     CheckCollision(Blue4) 
     CheckCollision(Blue5) 
    End Sub 

    Public Sub CheckCollison(ByVal src As PictureBox, ByVal Hide As Boolean) 
     If src.Visible = True Then 
      If BallX > src.Location.X And _ 
       BallX < src.Location.X + src.Size.Width And _ 
       Ball.Location.Y > src.Location.Y And _ 
       Ball.Location.Y < src.Location.Y + src.Size.Height Then 
       SpeedY = -SpeedY 
       UpdateScore() 
       If Hide Then 
        src.Visible = False 
       End If 
      End If 
      AllGone += 1 
     End If 
    End Sub 

    'declare the overloaded version of CheckCollision 
    Public Sub CheckCollision(ByVal src As PictureBox) 
     'call the original version 
     CheckCollision(src, True) <------error here 
    End Sub 

    Public Sub UpdateScore() 
     Score += 10 
     Label2.Text = "SCORE: " & Score 
    End Sub 

    Public Sub UpdateLives() 
     Lives -= 1 
     Label1.Text = "LIVES: " & Lives 
    End Sub 

    Public Property BallX() As Integer 
     Get 
      Return Ball.Left 
     End Get 
     Set(ByVal Value As Integer) 
      Ball.Left = Value 
     End Set 
    End Property 

    Public Property BallY() As Integer 
     Get 
      Return Ball.Top 
     End Get 
     Set(ByVal Value As Integer) 
      Ball.Top = Value 
     End Set 
    End Property 

    Public Property Lives() As Integer 
     Get 
      Return intLives 
     End Get 
     Set(ByVal Value As Integer) 
      intLives = Value 
     End Set 
    End Property 

    Public Property SpeedX() As Integer 
     Get 
      Return intSpeedX 
     End Get 
     Set(ByVal Value As Integer) 
      intSpeedX = Value 
     End Set 
    End Property 

    Public Property SpeedY() As Integer 
     Get 
      Return intSpeedY 
     End Get 
     Set(ByVal Value As Integer) 
      intSpeedY = Value 
     End Set 
    End Property 

    Public Property Score() As Integer 
     Get 
      Return intScore 
     End Get 
     Set(ByVal Value As Integer) 
      intScore = Value 
     End Set 
    End Property 

    Public Property AllGone() As Integer 
     Get 
      Return intAllGone 
     End Get 
     Set(ByVal Value As Integer) 
      intAllGone = Value 
     End Set 
    End Property 

End Class 

답변

0

제발 도와주세요.

관련 문제