Hey guys,

I want to calculate the x & y of a point object after it hits a frame.

Theoretical I think that the angle of the point need to be multiplied in -1 after it hits a frame.

Practical I do not know how to implement it,

thanks in advanced.

Printable View

- 11-15-2011, 03:42 PMtnrh1Calculate angels of a point object
Hey guys,

I want to calculate the x & y of a point object after it hits a frame.

Theoretical I think that the angle of the point need to be multiplied in -1 after it hits a frame.

Practical I do not know how to implement it,

thanks in advanced. - 11-15-2011, 04:00 PMNormRe: Calculate angels of a point objectQuote:

want to calculate the x & y of a point object after it hits a frame.

You need to consider where the two shapes are located in 2 dimensions and see when the boundary of one shape touches the boundary of the other shape. Drawing this on paper will help you to see where the boundaries are and where the boundary of one touches the boundary of the other.

Quote:

the angle of the point need to be multiplied in -1 after it hits a frame

Do you have some code you can post to show your problem? - 11-15-2011, 04:02 PMJosAHRe: Calculate angels of a point object
If a point travels with a speed (dx, dy) toggle the sign of dx if the point hits a vertical wall; toggle the sign of dy if it hits a horizontal wall.

kind regards,

Jos - 11-16-2011, 11:17 PMtnrh1Re: Calculate angels of a point object
No, I'm drawing a shape that hits the window frames.

I know! I just trying to find a way to calculate the new values after the object confluenction.

:(y):

Do you have some code you can post to show your problem?

Truthly, no.

I just got a simple point on my screen.

Looks like I got 2 problems now:

1)I want the point to move randomly on the screen. Moving it with 90 degrees it's easy .. just x++ or y++ but I want the point to move as the ball move on the picture I attached.

2)When it hits the window frame, what the values will be then?

Yea I know that but what happens if the ball is not re painting by x++ or y++, if it's x+=3, y+=10

Thanks guys.

edit: JoshAH, I think your answer is working for all the cases.

I will test it now. - 11-16-2011, 11:26 PMNormRe: Calculate angels of a point objectQuote:

I want the point to move as the ball move on the picture I attached.

Quote:

When it hits the window frame, what the values will be then?

Do you know the size of the window frame? - 11-17-2011, 08:25 AMJosAHRe: Calculate angels of a point object