Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Break-Out collision help

Author
Message
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 2nd Mar 2009 00:06
I know this has been the current discussion in my "help with game" thread, but i need an answer so im making a thread specific to this problem, rather than a general help thread. I have my brick locations saved into bricklocations(40,2) with the first of the two divisions being x and the second being y. there are only 10 bricks in the first level, but only 8 show up. I havent worked on this problem bcuz the collision one is more important. The balls x and y are saved into ballx and bally. two flags are set up for the ball going left right up and down, x# and y#. if x#=1 then its moving right, if y#=1 its moving down (i set it up so that 1 means inc ballx or y, hence 1 being down). Im trying to figure out some trigonometric way finding the angle between the center of the ball (ballx,bally) and the center of the brick (bricklocations(brick#,1),bricklocations(brick#,2)). The bricks dimmensions are 50*20 and the balls radius is 5. If you need any more info I can provide, just ask rather than assume.
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 2nd Mar 2009 01:47
It depends on which direction you want to calculate the angle based on the Cartesian coordinates - clockwise or counter clockwise. In DBC, 3d angles are stored in the objects clockwise. In 2D, it get's a little weird because y is upside down, but angles are generally considered counter clockwise. Just whatever method you choose, be consistant with it throughout the program.

If you use the polar coordinate system where Angle opening from position (1,0) X=0 degrees counter clockwise and position (0,1) where Angle at Y=90 degrees the function is:



If Y=0 degrees at (0,1) and the angle opens clockwise to (1,0) where X=90 degrees then the functions is:



Enjoy your day.
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 2nd Mar 2009 03:13
tnx latch ill try it out and report the results back 2 u
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 2nd Mar 2009 16:28
nice try latch, it definitly got me thinking on your wavelength, but i ended up finding a better, faster system that works and is really simple.
if ballx<bricklocations(brick#,1)-27(27 is half the width of the brick + the balls radius then - the balls movement speed(3)) then it is on the left side of the brick. the same holds true for the right side, ballx>bricklocations(brick#,1)+27. Nice try and thanks for the help, but i never got your system tested.
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 3rd Mar 2009 16:44
I was wrong, my collision system didnt work. Im trying to adapt yours to work with my system, tnx 4 the idea
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 3rd Mar 2009 19:13
Quote: "Im trying to figure out some trigonometric way finding the angle between the center of the ball (ballx,bally) and the center of the brick (bricklocations(brick#,1),bricklocations(brick#,2)). "


Based on your question, this example may give you a visual of what I was trying to say. Use the arrow keys to move the ball around:




Enjoy your day.
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 4th Mar 2009 04:55
o ok, ive never seen that atanfull command b4, that really makes my task a lot simpler. tnx latch
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 6th Mar 2009 11:33
You're welcome. The trick with it is to get the xs and ys in the right order.

Enjoy your day.

Login to post a reply

Server time is: 2025-05-17 07:01:19
Your offset time is: 2025-05-17 07:01:19