Computer Science Canada Formula for checking points in a cirumference? |

Author: | Paul [ Sat Apr 03, 2004 6:47 pm ] |
||

Post subject: | Formula for checking points in a cirumference? |
||

Im looking for the formula that can check the coordinates on any/all points on the circumference on a circle, it was vaguely mentioned in the tutorials section (?) I dunno, I need it so that the ball when it hits the corner of the paddle, it bounces, checking only vertical and horizontal axis won't work, so far Im using this and it works:
is there a formula for this? and while Im on the subject, 2 questions, why does the ball flash and the paddle doesn't, and why when you loose a life, when I use getch, it doesn't run the cls, eventhough the getch is after the cls? I thought getch pauses the program. heres my program |

Author: | zylum [ Sat Apr 03, 2004 7:01 pm ] |
||

Post subject: | |||

to solve you blinking problem, have the View.Update at the end of the main loop and remove the other ones... also remove the code which draws white over the last positions of the ball and paddle and instead add a cls after the View.update...
and as for the collision detection, if you want really accurate collision detection the i suggest you use the quadratic formula... if you need help with it i'll try to explain, but it's sort of hard to use with collision detection -zylum |

Author: | Paul [ Sat Apr 03, 2004 7:06 pm ] |

Post subject: | |

would you explain the formula please? |

Author: | recneps [ Sat Apr 03, 2004 8:00 pm ] |

Post subject: | |

well if you mean all the points on a circle, then isnt that technically my "circlify"? just change the drawdot to whatever command needed, it goes through the whole screen checking if the dot fits the circle's equation (x,y,and radius) If not then i misunderstood |

Author: | Paul [ Fri Apr 09, 2004 4:10 pm ] |

Post subject: | |

waa? I completely missed what your saying, how does it apply to my paddleball (in which I called the inperfect collision detection a cheat "feature") |

Author: | recneps [ Fri Apr 09, 2004 7:06 pm ] |

Post subject: | |

well you could use what i was saying on the ball, then, if: dot>one corner of paddle and < other corner of paddle then collision happened, and reverse direction. The other one workds just as fine, but thats what im interpreting that you needed |

Author: | Paul [ Fri Apr 09, 2004 7:23 pm ] |

Post subject: | |

thats what I used, but there are still minor glitches happening. the ball still slips thru some times. |

Author: | gamer [ Fri Apr 09, 2004 7:29 pm ] |

Post subject: | |

i hav a similar problem too......how should we fix this? |

Author: | gamer [ Sat Apr 10, 2004 6:18 pm ] |

Post subject: | |

please help!! anyone?? |

Author: | equs [ Sat Apr 17, 2004 1:39 pm ] |

Post subject: | |

the quadratic formaul is -b +/- sqrt b squared - 4ac / 2a sqrt everything after the -b and you have to do both equations for 2 points. The plus and - answer. |

Author: | zylum [ Sat Apr 17, 2004 9:43 pm ] |

Post subject: | |

the formula is the easy part... making an equation that uses the velocity of the ball, the velocity of the paddle and the positions of the ball and paddle to find the time of the collision.... if the time is less than 1 then the collision took place.... otherwise the collision didnt take place... if a collision does take place you multiply the velocty by the time ( < 1 ) and add it to the position and something like that and update the position of the ball and paddle... meh it's something pretty complex but its THE most accurate collision detection... i rember reading it somewhere and trying to implelemt it in one of my flash projects but it was pretty difficult.. -zylum |

: |

You can syndicate this boards posts using the file backend.php or view the topic map using sitemap.php.