Languages :: Java :: collision code in VB6? |
|||
| By: VB guy |
Date: 05/09/2003 00:00:00 |
Points: 90 | Status: Answered Quality : Excellent |
|
i am trying to make a game where numerous buttons drop from the top of a form and you have 1 "main" button that follows the cursor anywhere on the form and is used to bounce the other buttons back to the top of the form when the bottom of the falling button hits the top of the main button. but i can't seem to figure out how to get the button to "collide" with the main buttons top. thhis is as good as i can get it, being a newbie any help will be appreciated ----------------------------------------------------------------------------------------------------------------------------------------------------------------- Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Command1.Move X, Y End Sub Private Sub Timer1_Timer() Command2.Top = Command2.Top + 100 If Command2.Top > Command1.Top Then Command2.Top = 0 End If End Sub ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|||
| By: VGR | Date: 06/09/2003 18:40:00 | Type : Answer |
|
| well, if the colliding region (one button) has a rectangular shape, then the test for collision could be to test for "at least a corner is inside" the colliding region ie something like this : if ( ((y<=top) and (y>=bottom)) and ((x>=left)AND(x<=right)) // that's for upper left corner (x,y) OR ((y<=top) and (y>=bottom)) and ((x>=left)AND(x<=right)) // that's for upper right corner (x,y) OR ((y<=top) and (y>=bottom)) and ((x>=left)AND(x<=right)) // idem bottom left (x,y) OR ((y<=top) and (y>=bottom)) and ((x>=left)AND(x<=right)) // idem bottom right (x,y) ) then collision |
|||
| By: k_rupa | Date: 07/09/2003 20:21:00 | Type : Assist |
|
| to collide the top of main button with bottom of falling button , u have to write in if condition if( fallingbutton.top +fallingbutton.height ==mainbutton.top-10) { } |
|||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








