Hi,
I am currently making a 2D side-scrolling game as part of my A-level computing project, but i cannot figure out how to make collision detection.
This is the code i have at the moment,
I have an array of lines to outline the ground, called line and an image of the character, called character.
Public Function Collision() As Boolean
For i = 0 To 50
If (Charcater.Top + Charcater.Height) >= Line(i).Top Then
Collision = True
Else
Collision = False
End If
Next i
End Function
This function is then used in the games main timer
If Collision = True Then
Charcater.Top = Charcater.Top
Else
Do
Charcater.Top = Character.Top + 10 + Screen.TwipsPerPixelY
Loop Until (Charcater.Top + Charcater.Height) >= Line(i).Top
my problem is that every time i try to run the game i get 'Argument not Optional' and it highlights 'Line' in the function
can someone please solve this, I am fairly new to VB so forgive me if this is a stupid question.
Thanks in advance
I am currently making a 2D side-scrolling game as part of my A-level computing project, but i cannot figure out how to make collision detection.
This is the code i have at the moment,
I have an array of lines to outline the ground, called line and an image of the character, called character.
Public Function Collision() As Boolean
For i = 0 To 50
If (Charcater.Top + Charcater.Height) >= Line(i).Top Then
Collision = True
Else
Collision = False
End If
Next i
End Function
This function is then used in the games main timer
If Collision = True Then
Charcater.Top = Charcater.Top
Else
Do
Charcater.Top = Character.Top + 10 + Screen.TwipsPerPixelY
Loop Until (Charcater.Top + Charcater.Height) >= Line(i).Top
my problem is that every time i try to run the game i get 'Argument not Optional' and it highlights 'Line' in the function
can someone please solve this, I am fairly new to VB so forgive me if this is a stupid question.
Thanks in advance