
-----------------------------------
Paul
Sat Apr 03, 2004 6:47 pm

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:

    if BallX + 11 = PaddleX and BallY - 11  PaddleX and BallY-11 > PaddleY and BallY-11 PaddleX and BallY-11 > PaddleY and BallY-11 0 then
        PaddleX -= 4
    elsif chars (KEY_RIGHT_ARROW) and PaddleX + 77 < maxx then
        PaddleX += 4
    end if

end movePaddle

proc Drawball
    drawoval (BallX, BallY, 10, 10, black)
    drawfilloval (BallX, BallY, 9, 9, 12)
end Drawball

proc Moveball
    BallX += incX
    BallY += incY
    delay (7)
end Moveball
lives := 3
proc checkBall
    if BallX + 11 >= maxx or BallX - 11 < 0 then
        incX := -incX
    end if
    if BallY - 11 = maxy then
        incY := -incY
    end if
    if BallY - 11  PaddleY and BallY - 11 < PaddleY + PaddleWidth then
        incX := -incX
        incY := -incY
    elsif BallX + 11 < PaddleX + PaddleLength and BallX + 11 > PaddleX and BallY - 11 > PaddleY and BallY - 11 < PaddleY + PaddleWidth then
        incX := -incX
        incY := -incY
    end if
end checkBall

proc scoreshow
    locate (1, 1)
    put "Score: ", score, " Lives: ", lives
end scoreshow

loop
    drawPaddle
    Drawball
    Moveball
    movePaddle
    checkBall
    if lives < 0 then
        exit
    end if
    scoreshow
    View.Update
    cls
end loop
put "Your score: ", score

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

-----------------------------------
Paul
Sat Apr 03, 2004 7:06 pm


-----------------------------------
would you explain the formula please?  :D

-----------------------------------
recneps
Sat Apr 03, 2004 8:00 pm


-----------------------------------
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 ;)

-----------------------------------
Paul
Fri Apr 09, 2004 4:10 pm


-----------------------------------
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")

-----------------------------------
recneps
Fri Apr 09, 2004 7:06 pm


-----------------------------------
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

-----------------------------------
Paul
Fri Apr 09, 2004 7:23 pm


-----------------------------------
thats what I used, but there are still minor glitches happening. the ball still slips thru some times.

-----------------------------------
gamer
Fri Apr 09, 2004 7:29 pm


-----------------------------------
i hav a similar problem too......how should we fix this?

-----------------------------------
gamer
Sat Apr 10, 2004 6:18 pm


-----------------------------------
please help!!

anyone??

-----------------------------------
equs
Sat Apr 17, 2004 1:39 pm


-----------------------------------
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.

-----------------------------------
zylum
Sat Apr 17, 2004 9:43 pm


-----------------------------------
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
