forums

TNT Basic Forums > Programming Q&A
Circle Wall
< Last Thread     Next Thread >
Author
Thread        Post A Reply

05-28-2002 17:27

Posted by:
ERaZer

Find more posts by ERaZer

I have the player and all the enemies duking out inside a circle, and I want to have collision detection for that circle and I think its better to use maths then to use pixel detection.
Could anyone help me?
Oh, and if you need a better explination, just say it.

05-28-2002 17:38

Posted by:
John Treece-Birch

Find more posts by John Treece-Birch

Circles

If you know the position of the centre of the circle and it's radius, then you can work out if something is inside it or not.

x = horizontal distance from the centre of the circle
y = vertical distance from the centre of the circle

if (radius*radius)<(x*x)+(y*y) then it is outside the circle.

Hope this helps,
John

05-28-2002 19:48

Posted by:
ERaZer

Find more posts by ERaZer

Ok, thanks.
It works, now anyway...

07-07-2002 14:51

Posted by:
Mr. Me

Find more posts by Mr. Me

I used this in my game but I want the player to be able to... hmm wait. Lets say that the player goes to the left side of the circle and then pushes down, then I want the player to go down but inside the circle. Understand?
Could anyone help?

08-01-2002 13:08

Posted by:
Mr. Me

Find more posts by Mr. Me

Please, I really need this for my game and I cant get it to work...

08-01-2002 20:07

Posted by:
Louis!

Find more posts by Louis!

Well, I don't know the scpecific math involved off hand, but... What you'll want to do is, instead of not allowing the player to move past the circle, you'll want to bring the player back towards the center of the circle if he leaves the circle instead. What I mean by this is:
If the player leaves the circle, pull him back toward the center of the circle just enough for him to be back inside the circle.. The effect thi swill have is that if you hit, say, the rigth edge of the circle and press down, the player will start moving downward 'on screen' but seem to stick to the edge of the circle while doing so.. well, until he gets to the bottom where he'll simply stay.

08-02-2002 14:47

Posted by:
Danlab games

Click Here to Email Danlab games   Find more posts by Danlab games

You can use an hidden canvas (canvas 1) with the circle draw on it, and use a pixel color detection...

see ya

08-02-2002 17:46

Posted by:
Mr. ME!

Find more posts by Mr. ME!

I tried that, and it was slower then math I could only make it get stuck, not that you could "grind" the wall so to say...

08-08-2002 19:39

Posted by:
James Rhodes

Click Here to Email James Rhodes   Find more posts by James Rhodes

re: game physics

For those that are interested, there is a new book from O'Reilly called "Physics for Game Developers". Had a look at it and it is pretty good. Buying a copy soon...

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.