123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|709|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Blitz -> Rectsoverlap... Ovalsoverlap

Fri, 06 Apr 2007, 20:40
Blitz3Dman
I was wondering if there was such a command or one that someone (else) has made (I am still learning trig functions) to detect ovals overlapping similar to how rectsoverlap command works

-=-=-
There are 10 kinds of people in this world -

( Insert 16 remarks about to what extent people know hex here )
Sat, 07 Apr 2007, 02:18
Phoenix
You can take the distance between two objects, which would do the same thing.



And use it like this:


I grabbed the distance code from here:
www.blitzmax.com/codearcs/codearcs.php?code=731

Edit: This is, of course, only for circles, not for ovals.
Sat, 07 Apr 2007, 04:16
shroom_monk
You could draw the ovals into pictures using createimage() etc... then mask out a certain colour. Then, just use imagescollide().

|edit| You'll probably want to use freeimage to free the images afterwards. |edit|

-=-=-
A mushroom a day keeps the doctor away...

Keep It Simple, Shroom!
Sat, 07 Apr 2007, 04:39
steve_ancell
That's right Shroom, you tell em'. I would have done exactly the same.
Sat, 07 Apr 2007, 05:05
Blitz3Dman
Yea, I thought of both those ideas, but distance will result in a diamond like this:

.......O.....
....O....O...
.O..........O.
....O....O....
......O......

And I think that ImagesCollide would take a hit on program speed. Could be wrong, but that's just my suspiscion.

-=-=-
There are 10 kinds of people in this world -

( Insert 16 remarks about to what extent people know hex here )
Sat, 07 Apr 2007, 05:08
JL235
You can also calculate mathematically if two ovals were overlapping. I did something similar with drawing rotated ovals in OpenGL a while ago (similar because it calculated the distance from the centre of the polygon to it's edges).

If I still have the code, I'll look into writing a function to calculate overlapping ovals.
Sat, 07 Apr 2007, 05:10
Blitz3Dman
I'll be looking forward to seeing it

I'm working on a *small* little project to make my own version of a flash game I played and I'd need to find out the best way to do this.

-=-=-
There are 10 kinds of people in this world -

( Insert 16 remarks about to what extent people know hex here )
Sat, 07 Apr 2007, 05:30
Blitz3Dman
|edit| Oh, I'm sorry, the distance does work! I was doing my code wrong. Thanks, Phoenix |edit|

Dabz over a Syntax Bomb found some code but the collision part of it makes my head spin:



-=-=-
There are 10 kinds of people in this world -

( Insert 16 remarks about to what extent people know hex here )
Sat, 07 Apr 2007, 06:15
JL235
Done. This code does not take into account rotated ovals, which is what I was originally going to implement. Shrooms image collision method would be more accurate, but it might be slower if your making lots of ovals in real-time for different sized objects.

If all the ovals will be the same size (or from a selection pre-determined sizes), I'd use Shrooms method.



Although you should really implement both and test to see if either are slow. If both are fast enough, use the one which is the most accurate.
Sat, 07 Apr 2007, 06:20
Blitz3Dman
thanks very much, I'll have to see which is faster. And yes, I will be using a constant size for all.

-=-=-
There are 10 kinds of people in this world -

( Insert 16 remarks about to what extent people know hex here )
Tue, 10 Apr 2007, 08:19
Paul
when i saw oval i thought you meant oval so here is a test that i did for circles.