[RESOLVED] Bitmap Collision Detection?
Could Anybody Help Me With This?
I Have A Bitmap I drawed On The Form With: e.graphics.DrawImage(MyBmp,Location), (Location = 10,10 BTW)
I Already have Movement Figured Out For The Bitmap, But How Would I detect If Im Colliding With A Panel?
I Have Tried:
If Location.Y = 256 And Location.X = 256 Then
MessageBox.Show("Hi") Then
End if
But Unfortunately This Does Not Work :(
Could Anybody Help Me? Sorry If You Dont Understand I am Horrible At Explaining Things
EDIT: Here is My Code if anyone needs it....
Dim Character As New Bitmap("C:\ArtofBlood\Data\Art\Guy1.png")
Dim Speed As Integer = 10
Dim Location As Point
Private Sub Form1_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
Select Case e.KeyCode
Case Keys.W
Location.Y += Speed
End Select
Me.Refresh()
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Location = New Point(10, 10)
DoubleBuffered = True
End Sub
Private Sub Form1_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint
e.Graphics.DrawImage(Character, Location)
End Sub
Re: Bitmap Collision Detection?
You can use the Rectangle.IntersectsWith method to determine when two rectangles intersects.
Re: Bitmap Collision Detection?
Well The Thing Is I Don't Have a Rectangle I Have A bitmap Image, If I try To Do Charcter.IntersectsWith it Throws An Error, Here IS My Code:
Dim Character As New Bitmap("C:\ArtofBlood\Data\Art\Guy1.png")
Dim Speed As Integer = 10
Dim Location As Point
Private Sub Form1_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
Select Case e.KeyCode
Case Keys.W
Location.Y += Speed
End Select
Me.Refresh()
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Location = New Point(10, 10)
DoubleBuffered = True
End Sub
Private Sub Form1_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint
e.Graphics.DrawImage(Character, Location)
End Sub
Re: Bitmap Collision Detection?
You know your character's location and size, so you can create a rectangle in code from that.
The same applies to the obstacle
Edit: as the obstacle is a panel, you can use its Bounds property for the rectangle
Re: Bitmap Collision Detection?
Quote:
Originally Posted by
.paul.
You know your character's location and size, so you can create a rectangle in code from that.
The same applies to the obstacle
Edit: as the obstacle is a panel, you can use its Bounds property for the rectangle
Oh, Wow Thank You! I Just Started Vb.net Graphics Drawing