Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27159

Collision troubles

$
0
0
Greetings,
I am making simple Pong application using just one picturebox, which is used as an canvas for everything happening.

The code for collisions is :

Code:

Public Sub Collision()
        If (Player.position.X + Player.width >= _ball.position.X) = True And (Player.position.Y <= _ball.position.Y) = True And (_ball.position.Y <= Player.position.Y + Player.height) = True Then
            MessageBox.Show("Bang")
        End If

    End Sub

I put just MessageBox.show because I wanted to see if the collision will occur.



The thing is, the collision occurs when the paddle is on top left position, but not in any other case. I have made both paddle and ball moveable so you could test it for yourself, I will include it as an attachment. Mind you the game is strongly unfinished because I want to get hang of collisions first.
Attached Files

Viewing all articles
Browse latest Browse all 27159

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>