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.

DarkBASIC Discussion / Paste Priority Problem

Author
Message
Ashingda 27
18
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 14th Jan 2009 19:10 Edited at: 17th Mar 2013 23:08
I'm working on a routine to paste images onto the screen with it's Y coordinate as it's priority. The code works as it should but I'm having some problems with the images that has the same Y coordinates.

There is an image atached to the mouse to test a moving image with the priority routine. Although that's not the problem it somewhat causes it. While moving the mouse around, that image's priority changes and other images that has a same Y corrdinates that are very close to each other will have an X corrdinate priority contest of their own and it's driving me nuts!

I cannot figure out how to make them not flicker back and forth, I've tried to sort the priority array checking both X and Y but that does not work and only slows the FPS down.



Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 15th Jan 2009 13:39
Wow! Your implementation of quick sort is pretty fast! Anyway, the problem seems to be in the sorting. Since several circles can share the same y position, your sorting routine doesn't care which one comes before the other if they have the same value. When you are changing the position of one of the circles, the sorting routine launches and reorders the other circles with the position of the new circle in mind. This can swap some of the circles positions that have the same y, so their priority changes when you don't want it to.

You should introduce a second unique index that forces a consistant (or at least fairly consistant) sort. I originally was thinking of a zdepth but actually the individual index references for each circle will do. Basically there would be a sort within a sort so to speak. You want to sort by y value and you want to sort by object index. So if objecty(4) and objecty(3) share the same position, they will always be sorted in objecty(3) objecty(4) order so they hold their positions relatively.

Enjoy your day.
Ashingda 27
18
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 15th Jan 2009 13:55 Edited at: 17th Mar 2013 23:06
Ohh yeah should be simple enough, I think I have a good idea of fixing this now.


[edit]


Alright It works now!

Made a second Sort routine that will search for the array indexs with the same Y coordinates and call QuickSort to sort just thoese. The best part, the FPS didn't slow down one bit.



Login to post a reply

Server time is: 2026-07-05 16:51:46
Your offset time is: 2026-07-05 16:51:46