|
-
Sep 17th, 2002, 10:54 PM
#1
Thread Starter
Lively Member
bounds boxes
I don't know if I labeled this right, ... I think they are called bounds boxes... Anyhow, is there a way I can detect collision detections easily, and less costly(processor). I've heard of bounds boxes, but no one says how to set them up.
I know how to do it to detect if something gets hit, but I want to have a wall effect. Is there a good, reliable way?
-
Sep 18th, 2002, 10:44 AM
#2
Member
Reply
Basically setting up bounding boxs is very simple all you do is check the x,y of box with that of the wall or another box: here is some sample code:
[VB]
'the size of the bouncing area
maxX = Form1.Picture1.Width - Form1.Picture2.Width
maxY = Form1.Picture1.Height - Form1.Picture2.Height
'Move the image based on it's acceleration and make it random where the X pos will be
PosX = PosX + AccelX + Rnd(numb) 'Off set the X pos so that it moves all around
PosY = PosY + AccelY
'Check for collisions
If PosX < 0 Then
PosX = -PosX
AccelX = -AccelX
ElseIf PosX > maxX Then
PosX = maxX
AccelX = -AccelX
End If
If PosY < 0 Then
PosY = -PosY
AccelY = -AccelY
ElseIf PosY > maxY Then
PosY = maxY
AccelY = -AccelY
End If
Form1.Picture2.Move PosX, PosY
[/VB]
you would need to setup some of the variables first such as accelx and accely but all these can be done by trial and error
What is Life? One big dream or one Big nightmere.
-
Sep 18th, 2002, 10:53 PM
#3
Thread Starter
Lively Member
I'm sorry...
... wasn't specific enough. Not you, me. I want to do it in a 3d world.
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
|