|
-
Sep 3rd, 2002, 06:17 PM
#1
Thread Starter
New Member
Collision Detection?
Hi, I'm pretty new to programming games in visual basic, I'm primarly used to internet and misc. programming. My question is simple enough, How do u detect when to images hit? Like imgLion and imgTiger? Some help here would greatly appreciated, thanx!!
-
Sep 3rd, 2002, 07:14 PM
#2
PowerPoster
VB Code:
If (imgLion.left+imgLion.width>imgTiger.left) And (imgLion.top+imgLion.height>imgTiger.top) Then
If (imgLion.left<imgTiger.left+imgTiger.width) And (imgLion.top<imgTiger.top+imgTiger.height) Then
'Collision!
End if
End If
-
Sep 5th, 2002, 03:46 AM
#3
Retired VBF Adm1nistrator
As in fox's code there, you basically just check when the dimensions of one box overlap the dimensions of another
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Sep 5th, 2002, 06:46 AM
#4
Good Ol' Platypus
Once you get more serious into game programming you can use the IntersectRect API to check if two RECT structs are colliding
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Sep 5th, 2002, 10:36 AM
#5
PowerPoster
Once you get more serious into game programming you might want to use a map to do the collisions or (depending on the game) collision circles...
-
Sep 5th, 2002, 02:59 PM
#6
Good Ol' Platypus
Or fun pixel (mask) collision
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Sep 5th, 2002, 03:48 PM
#7
PowerPoster
yay ^^ or the method I mentioned months ago.. each object has collision points AND a collision rect. and you check collision by intersecting the points of object1 with the rect (or a mask) of object2. This would allow nearly pixel-based collision but you only have to check 5-6 points per object.
-
Sep 5th, 2002, 04:17 PM
#8
Good Ol' Platypus
Yes, that is a good idea 
There are some tricks to increase the speed.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Sep 5th, 2002, 08:09 PM
#9
-
Sep 5th, 2002, 08:13 PM
#10
Good Ol' Platypus
I'm well known for my bad ones, hehe
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Sep 5th, 2002, 08:34 PM
#11
Frenzied Member
Originally posted by Sastraxi
I'm well known for my bad ones, hehe
I wouldnt say that =).
Z.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|