Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact


Collosion (For My Game)


Collosion (For My Game)

Author
Message
Manku_D
Manku_D
Forum God
Forum God (2.6K reputation)Forum God (2.6K reputation)Forum God (2.6K reputation)Forum God (2.6K reputation)Forum God (2.6K reputation)Forum God (2.6K reputation)Forum God (2.6K reputation)Forum God (2.6K reputation)Forum God (2.6K reputation)

Group: Forum Members
Posts: 7, Visits: 9
Hello My Self Manku,

Dear Friends I just want to know how to make a collosion dectection like if player colloide with enemy he loose life. Since my english is not very good so plz forgive me, every thing is all right.

Just dont view the topic if u know any thing u can tell me.

If you want any other information tell me i can gave u. I see other example in this site but i cannot understand them so plz help me.

Ok then bye bye take care Manku_D.

Nothing to Say.

arti
arti
Forum God
Forum God (325 reputation)Forum God (325 reputation)Forum God (325 reputation)Forum God (325 reputation)Forum God (325 reputation)Forum God (325 reputation)Forum God (325 reputation)Forum God (325 reputation)Forum God (325 reputation)

Group: Forum Members
Posts: 1, Visits: 10
hello everyone,

I am new here as I am new to VB.

Also it looks like I have very similar problem like the guy above.

i found this code after doing simple google search and it is simple enough for me (I want to keep it this way until my skills in VB improve ). 

The problem is - I want to have walls in my game. It looks like it is very simple thing to do - replace beep with something that would prevent two images overlapping, but I have no idea how to do it. (And believe me I tried)

Thanks to those who can help out.

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim pic1Left As Integer, pic1Top As Integer, pic1Right As Integer
Dim pic1Bottom As Integer'Declare parameter variables for image 1
Dim pic2Left As Integer, pic2Top As Integer
Dim pic2Right As Integer, pic2Bottom As Integer 'Declare parameter variables for image 2
Dim topBetween As Boolean, bottomBetween As Boolean
Dim leftBetween As Boolean, rightBetween As Boolean
Select Case KeyCode
    Case vbKeyDown
        Image1.Top = Image1.Top + 50
    Case vbKeyUp
        Image1.Top = Image1.Top - 50
    Case vbKeyLeft
        Image1.Left = Image1.Left - 50
    Case vbKeyRight
        Image1.Left = Image1.Left + 50
End Select
'Assign image1 variables
pic1Left = Image1.Left
pic1Right = Image1.Left + Image1.Width
pic1Top = Image1.Top
pic1Bottom = Image1.Top + Image1.Height
'Assign image2 variables
pic2Left = Image2.Left
pic2Right = Image2.Left + Image2.Width
pic2Top = Image2.Top
pic2Bottom = Image2.Top + Image2.Height
'Crash code
If pic1Left >= pic2Left And pic1Left <= pic2Right Then
    leftBetween = True
End If
If pic1Right >= pic2Left And pic1Right <= pic2Right Then
    rightBetween = True
End If
If pic1Top >= pic2Top And pic1Top <= pic2Bottom Then
    topBetween = True
End If
If pic1Bottom >= pic2Top And pic1Bottom <= pic2Bottom Then
    bottomBetween = True
End If
If leftBetween = True Or rightBetween = True Then
    If topBetween = True Or bottomBetween = True Then
        Beep
    End If
End If
End Sub

 

GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search