Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Selecting tiles in the shape of a circle

Author
Message
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 18th Feb 2008 18:01
I am making a simple matrix editor and I want to reshape the matrix. I have a circle (which is shown simply using spheres) to show you which tiles you are going to raise or lower.

The way I am curretly doing it is by having 2 for loops, one for all the x tiles of a matrix and one for the z tiles, and I get their position on the XZ plane. If the distance from the center of the circle is within the radius, the tiles can move.

But this is very slow, and I cant figure out a better way to do it. It would be easy if the circle was a fixed size, but that's not the case.

Here is my code:


Don't you just hate that Zotoaster guy?
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 18th Feb 2008 18:37 Edited at: 18th Feb 2008 18:52
Quote: "I cant figure out a better way to do it."

Reduce the tiles checked using simple X/Z position checking. You'll have to determine the maximum amount of tiles for each circle of course. [edit] Of course I didn't see the code, else I would have suggested removing dbUpdateMatrix() from the loop.

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 18th Feb 2008 18:58
Thanks Ben.

Everyone else: I fixed it by using Ben's method, and not calling dbUpdateMatrix() during the nested loop, which was rather stupid

Cheers

Don't you just hate that Zotoaster guy?

Login to post a reply

Server time is: 2024-11-17 06:32:23
Your offset time is: 2024-11-17 06:32:23