
-----------------------------------
KeyBladeMaster
Tue Dec 04, 2007 12:17 am

Colision Detection/Attacking....
-----------------------------------
Alright, i need alot of help....

i need to know how to do colision detection.... i dont want that code that everyone has with the rectangles... it doesnt make any sence  to me.... give me one with actuall pictures if possible...

and last i need to know how to make my enemy attack when we are close to each other.....

my program is kinda complicated so ill put lots of comments!

 I HOPE SOMEONE CAN HELP WITH ONE OF THESE PROBLEMS...

-----------------------------------
KeyBladeMaster
Tue Dec 04, 2007 2:15 pm

RE:Colision Detection/Attacking....
-----------------------------------
iight i fixed transparent color.... id dint no u had to do it before u draw the pic

-----------------------------------
Ultrahex
Tue Dec 04, 2007 2:53 pm

Re: Colision Detection/Attacking....
-----------------------------------
I am assuming you are doing rectangle-rectangle collision, if not you need to state your question more clearly.

For Rectangles/Squares to overlap/collide, they must have one of their points in the other rectangle, that is:

http://img123.imageshack.us/img123/6704/boxeslabeledim1.jpg

so from the diagram, they have to share the same space in order for a collision to occur, and one of the rectangles vertex/points has to be inside the others.

thus, you can use analytical geometry and prove when they are colliding, however, if you have not learned this...

there is easier ways, the real question in rectangle-rectangle collision, is when are they NOT colliding.
Well that is when the x-coordinate and y-coordinate are out of the range.

Horizontal Check
(X-axis check) ... Determines if they are NOT overlapping horizontally.

(x1 > x2+w)  - the left side of the first rectangle is greater then the right side of the second rectangle. (that is the first rect is to right of the second rect)
(x1+w < x2)  - the right side of the first rectangle is less then the left side of the second rectangle. (that is the first rect is to the left of the second rect)

Vertical Check
(Y-axis check) ... Determines if they are NOT overlapping vertically.

(y1+h < y2) - the bottom of the first rectangle is less then the top of the second rectangle (the first rect is above the second rect)
(y1 > y2+h) - the top of the first rectangle is greater then the top of the second rectangle (the first rect is below the second rect)

notes

note if i remember correctly about Turing Graphics, this approach needs modified to your system because you do not know the width and height of your objects you just know your two corners, can easily be adapted however.

-----------------------------------
Clayton
Tue Dec 04, 2007 5:09 pm

RE:Colision Detection/Attacking....
-----------------------------------
You can use Pic.Width() and Pic.Height to find the width and height of a picture.

-----------------------------------
StealthArcher
Tue Dec 04, 2007 6:13 pm

RE:Colision Detection/Attacking....
-----------------------------------
http://compsci.ca/v3/viewtopic.php?t=14552

Here's code for a game I made once, read it  to find how I did rectangle collision, oh and it has pictures ;).

-----------------------------------
KeyBladeMaster
Tue Dec 04, 2007 9:46 pm

RE:Colision Detection/Attacking....
-----------------------------------
i need more help..... i have a menu  now, and music... i have different music for the menu and different music for my first level... they are both in different forks and when i start game no music starts....but like when im about to exit and it asks if im sure thats when the music starts....:S:S:S

-----------------------------------
rcbhs
Wed Dec 05, 2007 9:38 am

Re: Colision Detection/Attacking....
-----------------------------------
if my coordinates are variables because both object are constantly moving, how do I get the collision for all sides? My variables are manx, many, ghostx, ghosty for the 2 objects I need to collide. What I have now is totaly screwed and works quite strangely. 

if (manx = ghostY - Pic.Height (manID)) and
                (many 