Jump to content
IGNORED

Sorting data in an array


omf

Recommended Posts

So i was looking at the bcx help file and see that there is a QSORT command that sorts data in defined arrays, i cant make it work, i think that it does not work on jaguar hardware or the required include files are not present. in the RB+ implementation

 

is there an alternative to this that works apart from writing your own mess of code to deal with it?

 

any thoughts?

 

Link to comment
Share on other sites

Without the required bcx files etc then you'd have to roll your own.

 

Is the sort required in the main loop? or 'offline' ?

 

Doing your own would be easy enough in basic but if its in a time critical point of the program then something more native would be good for sure.

Link to comment
Share on other sites

You could most easily do a bubble sort in BASIC to target a single array which would mirror the QSORT function but it is the least efficient method which could be an issue if it's time critical as Captain Picard has pointed out.

 

If you want to sort the contents of one array based on another QSORT is out and you'd have to write your own algorithm anyway.

 

Virtual World BASIC for the Atari VCS has built in commands that load and sort one multidimensional array (the screen) from the much larger MD array of the virtual world. This sort of complex sorting is made possible by a Relational Database core that is part of the BASIC runtime; it's written in optimized Assembly but still consumes enough processor power that it steals a frame to run the algorithm on the 6502.

 

I envision a similar engine for the Jag could load a 3D screen from a 3D virtual world and surface language intrinsics to control it :)

 

 

Link to comment
Share on other sites

in the game i need to sort integer values in value of highest first and this will relate to the y value, i need to remove them from screen with an explosion 1 at a time from bottom up

 

so knowing the maximum y value to the lowest y value would help greatly

 

i guess i could write a spaghetti bowl of code to sort it out

 

time isnt really an issue as its for when your dead and all objects are static

Edited by omf
Link to comment
Share on other sites

OK I know what game you are making and what you want to achieve. If I were doing it I'd simply cycle through all active objects of this type reading the y values, make the largest one inactive, do the assplosion and repeat for as many active objects of that type there are. There's no need to grab and sort the y values, just zap the biggest one every iteration.

Link to comment
Share on other sites

in the game i need to sort integer values in value of highest first and this will relate to the y value, i need to remove them from screen with an explosion 1 at a time from bottom up

 

so knowing the maximum y value to the lowest y value would help greatly

 

i guess i could write a spaghetti bowl of code to sort it out

 

time isnt really an issue as its for when your dead and all objects are static

 

Put a 1 pixel high object at the floor, and use the collision detection to test for a hit. Offload this stuff to RAPTOR.

Link to comment
Share on other sites

To be honest, I didn't pay attention to what has been written on this thread. I just googled qsort, found a PD version, made a function for it, compiled, wrote a sample program, worked first time, shrug :P. It's probably fast but don't quote me on this!

 

Now, if I suspect that someone is trying to write a relational database on rb+, I'll delete the repositories immediately :P.

  • Like 6
Link to comment
Share on other sites

Put a 1 pixel high object at the floor, and use the collision detection to test for a hit. Offload this stuff to RAPTOR.

 

That's not what he wants to manage. On death, these objects are frozen - he wants to remove them one by one and make a show of it from bottom to top and they will not necessarily be in any original order such as the order they appear in the list.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...