[Game Tutorial] Detect collision
This is a little tutorial that can be used to games.
- Picturebox1 is your character
- picturebox2 is an enemy character
Code:
'add this code to a timer set to 100
If Picturebox1.Bounds.IntersectsWith(picturebox2.bounds) Then
dim hp as integer = 100
hp = hp - 5
End If
So if the enemy hits you, you lose hp.
Simple but very good for game developers.
-hej Hmm... Nice. Works a lot better and faster than using X and Y axis of each object. Didn't know about this. Thanks!
Of course it works. I was wondering why everybody was using the hp = hp - 5 kind of thing.
But then you lose the granularity that comes with per pixel collision detection...So I don't see the point, really.