Ask your own question, for FREE!
Mathematics 15 Online
OpenStudy (anonymous):

I need an function(collapsion test) to test if 2 shapes collapsed or not ^^

OpenStudy (anonymous):

i tried to do it like that: if Xshape1 == Xshape 2 and if Yshape1==Yshape2 then Collapse = ture else false

OpenStudy (anonymous):

failed :(

OpenStudy (anonymous):

And it should push back ^^

OpenStudy (anonymous):

ty :D

OpenStudy (amistre64):

if ((imgX1 == imgX2) && (imgY1 == imgY2)) {alert('collapsed')} else {alert('failed')}

OpenStudy (amistre64):

alert is just a display function

OpenStudy (amistre64):

I usually break it into flags instead of going for the whole boolean

OpenStudy (anonymous):

amm kk as i do ^^ so alres gives true to collapsed value ye?

OpenStudy (anonymous):

but amistre i tried it too and it didn'T work :(

OpenStudy (amistre64):

id have to see the programming to really get an understanding of it...

OpenStudy (anonymous):

hmm kk but i have an idea just wait

OpenStudy (anonymous):

OK I GOT IT JUST LOOK and a "ve" means and in turkish :( i wrote it turkish because of my agitation sorry :(

OpenStudy (anonymous):

just look at these amistre

OpenStudy (amistre64):

height and width /2 is center of image good; x and y are plots...

OpenStudy (anonymous):

yea..

OpenStudy (anonymous):

to you, will it work nice?

OpenStudy (amistre64):

still looking it over; when do you want to call the collision? at center points of when edges meet?

OpenStudy (anonymous):

i want to call when edges meet

OpenStudy (anonymous):

no centers

OpenStudy (amistre64):

are they both inmotion? or is one stationary?

OpenStudy (anonymous):

yea they are in motion

OpenStudy (anonymous):

so that, when they collapse, i want them to push back too

OpenStudy (amistre64):

well, push back would be just a negation right? opoosite direction of motion

OpenStudy (anonymous):

yea

OpenStudy (amistre64):

collision happens regardless of both in motion so its simply breaching the area of the other then...

OpenStudy (anonymous):

and it hink that if we have a variable named speed speed should be-0.1 f 60 times per sec yea?

OpenStudy (anonymous):

u right , so when it collapese if it moves on X+1 direction it will move in X-1 direction and speed -0.1f 60 times per sec and if speed < 0 the it should stop ya?

OpenStudy (amistre64):

cant say fer sure on speed yet but.... for collision I get: if Cxmin = xb-(hb/2) ; Cxmax = xb+(hb/2)

OpenStudy (amistre64):

no 'if' there lol just naming variables

OpenStudy (anonymous):

yea its like that

OpenStudy (anonymous):

ok kk ^^ i am so unpatinet xp

OpenStudy (amistre64):

maybe better to name then Axmin, Aymin, Axmax, Aymax, and such right?

OpenStudy (anonymous):

amistre u know i am only 14 years old and I am not in highschool yet xd yea

OpenStudy (amistre64):

if (Bxmin <= Axmax AND Bxmin >= Axmin) {then collapse}

OpenStudy (amistre64):

im 39 so.... so lets keep it proper :)

OpenStudy (anonymous):

:)

OpenStudy (anonymous):

well its logical

OpenStudy (amistre64):

that would generate a collapse if they are inline along the xaxis

OpenStudy (amistre64):

factor in the y axis the same way and it should cover all diretions then

OpenStudy (amistre64):

whatever your alogrithm for motion is, reverse it

OpenStudy (anonymous):

and t then do same thing for y axis and put them if if (Bxmin <= Axmax AND Bxmin >= Axmin) {then collapsex=ture} and for the other equatin is ture then collapsey=ture and if collapsex==ture and collapsey== ture then collapse==True!!!!!!!!

OpenStudy (angela210793):

OMG!!! u solved tht? O.o

OpenStudy (amistre64):

you got it :) maybe an easier way to do it, but I never go that route lol

OpenStudy (anonymous):

xd anyway we solved this it hink and tomorrow ill try to program it

OpenStudy (amistre64):

good luck :)

OpenStudy (amistre64):

name your corners; and when they are between each other or equal to each other, collapse

OpenStudy (anonymous):

i wanted this collapsion thest to see if cannonball collapsed with theenemey ship

OpenStudy (anonymous):

kk thank you

OpenStudy (anonymous):

well i wrote algorithm for pushing back :D its ok now

OpenStudy (anonymous):

really good work here

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!