colision detection in game , with diffrent x and y radius
Author |
Message |
kousha41564
|
Posted: Sat Jan 10, 2009 1:09 am Post subject: colision detection in game , with diffrent x and y radius |
|
|
alright , i got one circle wiht 2 radiuses that equal the same number. then i have an oval wiht 2 DIFFRENT radius.
so its like
circle one Xradius, Yradius = 22, 22
circle2 Xradius, Yradius = 220 , 75
i am using this to check if they colided
code: |
drawoval (Character_Xposition, Character_Yposition, 22, 22, 7)
drawoval (Control_1_Xposition, Control_1_Yposition, 220, 75, 7)
distance := ((Control_1_Xposition-Character_Xposition)*(Control_1_Xposition-Character_Xposition) + (Control_1_Yposition-Character_Yposition)*(Control_1_Yposition-Character_Yposition))
distance := sqrt (distance)
if distance < 22 + 75 then
put "collide"
end if
|
i also tried
code: |
drawoval (Control_1_Xposition, Control_1_Yposition, 220, 75, 7)
a1 := Control_1_Xposition - Character_Xposition
b1 := Control_1_Yposition - Character_Yposition
csq1 := a1 * a1 + b1 * b1
c1 := sqrt (csq1)
if 22 + 220c1 then
put "collide"
end if
|
dosnt seem to work either
after reading 10927810928 tutorials i figured i could use math distance. anyone explain how i could aply this to my situation ?
this dosnt work though, please help me out. i have no idea what to do. Thanks anyone who helps |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Sat Jan 10, 2009 3:57 am Post subject: Re: colision detection in game , with diffrent x and y radius |
|
|
kousha41564 @ Sat Jan 10, 2009 1:09 am wrote:
circle2 Xradius, Yradius = 220 , 75
That's not a circle, that's an oval. Circle collision detection makes things easier by assuming that the radius is always constant. In an oval, the radius changes depending on the angle of (possible) collision. Once you figure out the angles and radii, the rest is fairly similar. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
kousha41564
|
Posted: Sat Jan 10, 2009 12:32 pm Post subject: RE:colision detection in game , with diffrent x and y radius |
|
|
sadly i have no idea at all what you mean
well i understand what you mean, but no idea how to go towards solving it. |
|
|
|
|
![](images/spacer.gif) |
kousha41564
|
Posted: Sat Jan 10, 2009 1:01 pm Post subject: RE:colision detection in game , with diffrent x and y radius |
|
|
alright i am going crazzzy over this. it isnt possible :'( lol...
the circle or oval in this case is only imaginery. it is to check if my character has ran into an object. i figure i could just use line colision.
so how would i go to do that? if the distance of the circle and the line is less than the radius of the circle then colision occurs. how do i get the distance between the line and the center of the circle though ? omg.... i think i ma kill myself |
|
|
|
|
![](images/spacer.gif) |
kousha41564
|
Posted: Sat Jan 10, 2009 1:15 pm Post subject: RE:colision detection in game , with diffrent x and y radius |
|
|
i got it
code: |
if Character_Yposition-22 < Control_1_Yposition then
Character_Yposition +=2
end if
|
if anyone has any better sugestions than feel free to help me out lol |
|
|
|
|
![](images/spacer.gif) |
|
|