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 Professional Discussion / Constraining x and y 2D values to a circle around a point

Author
Message
Dar13
18
Years of Service
User Offline
Joined: 12th May 2008
Location: Microsoft VisualStudio 2010 Professional
Posted: 3rd Sep 2010 04:00
Hey all,

I've been making a BrickBreaker clone and I've got most of it done, just the fancy stuff left. One of these fancy things is the line showing the direction of where the ball is going to go when released from the paddle at the beginning of each level.

I've found this equation for finding the coordinates of any point on the circumference of a circle :

Except that when I've implemented that into my code, I got strange results(way off to the left or off the screen).
Here's the code I'm using currently(gets slope and y-intercept for linear equation of the current mouse position and draws a line from the paddle to the mouse point):


If anyone can help me, I'd greatly appreciate it.


IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 3rd Sep 2010 15:17
Did you set player.x and player.y up as float values in your type?

Utility plug-ins (26-JUL-2010)
I'm applying terms of use that require you to wear a red nose and honk a horn whenever you use the Internet
Zotoaster
21
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 3rd Sep 2010 17:06
It should actually be:



"everyone forgets a semi-colon sometimes." - Phaelax
Dar13
18
Years of Service
User Offline
Joined: 12th May 2008
Location: Microsoft VisualStudio 2010 Professional
Posted: 4th Sep 2010 17:14
@IanM, no because I thought the 2D commands take integers, not floats.

@Zotoaster, I'll try that equation instead.

Thanks for the help guys.


Login to post a reply

Server time is: 2026-07-24 23:12:03
Your offset time is: 2026-07-24 23:12:03