Sorting Algorithms for Sprites

Started by
13 comments, last by JoHnOnIzEr 20 years, 1 month ago
Yea, i do realize the shortcomings of vb, but I am using this more so as a learning experience. I''ve been playing around with the linked lists and i think I have something that works. Basically if the player or something moves, it checks to see if its still in its correct position in the list (its movement didn''t change its drawing position), and if it isn''t, it removes the sprite then adds it to the list. My add function adds sprites in their correct position so the list remains sorted the whole time. Would this method be slower than a collection?
Sidra Headquarters
Game engine is currently at version 0.9.8! Currently Down
Advertisement
I would imagine that if you are implementing your own link list it will be slower than the collection obj.

in my exp with vb(2 years of programing game related stuff)

re-inventing the wheel wont get you speed gain (unlike you can somtimes do in C++) it seems that it is best to use built-ins when you can, dont fight the current=D

Raymond Jacobs,

www.EDIGames.com

www.EtherealDarkness.com

Raymond Jacobs, Owner - Ethereal Darkness Interactive
www.EDIGames.com - EDIGamesCompany - @EDIGames

Three and a half years of VB programming and EDI is right and wrong about reinventing the wheel in VB because it can be done and is necessary in lots of situations, but since that isn''t the topic, the Collection object should do everything you need and nothing extra that you do not need. Therefore, since you''ll need every aspect of it, use it since what you''d reinvent would do exactly what Collection already does.
okay so if I wanted it to order a collection of my CSprite class by one of its properties (.z), how would i do this? I havent really used the collection object before. It is also possible for the z value of two sprites to be the same.
Sidra Headquarters
Game engine is currently at version 0.9.8! Currently Down
Collection works just like an array. Just look at the code I posted earlier, it should be all you need. To return the contents of a Collection entry, just use Collection.Item(Index)

This topic is closed to new replies.

Advertisement