[Game Tutorials] Detect collision

Posts 1–6 of 6 · Page 1 of 1
[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!
Code:
hp -= 5
Shorter =D
^^ That works??? o.0
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.
Posts 1–6 of 6 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us