Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 colision detection in game , with diffrent x and y radius
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
kousha41564




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: 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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
kousha41564




PostPosted: 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 Sad

well i understand what you mean, but no idea how to go towards solving it.
kousha41564




PostPosted: 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
kousha41564




PostPosted: 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 Very Happy lol
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: