C++ 2D Shooter project (Htbaa's Worklog)

Build on C++ with SDL and KrasEngine! RSS Feed

Engine improvements

So, after a chat with the helpful Sandman (although I couldn't sleep last night!) I figured out my solution for performance problems with collision detection. Currently I'm keeping track of my objects in different lists, which are all stored inside of a map.

Basically, I have different lists which are stored inside a map for direct access. My main lists are:

* a Z sorted list to drawn all my game objects in the right order
* a priority sorted list which makes sure the important game objects are executed first
* per type lists: Every class (Enemy, Player, Bullet) will be stored in their own list. This way I can quickly iterate through a list containing only, lets say enemies, to check if a bullet collides with it. No more need to filter out the main list.

Also, the sorted lists (Z and priority) will only get resorted once. So if about 200 objects change their z or priority, the lists will only be updated once in the current frame. This gives me some more performance.

Although performance has gotten a little better, it's not what I expected from it. But the improvements I've made are sure to make better results when a lot of different objects are on the screen. My tests so far were only containing a player, bullets and the same type of enemy (a thousand of them actually).

When turning of the rendering part the frame rate gets doubled. So I guess I need to look into increasing rendering performance.
(Posted on December, 30th 2007, 12:47)

Comments


Rincewind said:
Those sounds like good considerations. In my current Map Editer / Space game I am also planning to use a Z sorted system. This is a system with a Stage, Actor objects and Group objects. This is part of LibGDX for Java and there might exist similar systems in other languages. I'm also using openGL. The z ordened list is a tight list, with an exact order (first object has z 0, next z is 1, for the object after the z is 2). Therefore I need to manually compile the exact list from wider z numbering.

Thanks for describing these systems, it's greatly interesting to read.
(Posted on November, 26th 2020, 16:35)

Post New Comment

You must log in or register to post comments.

Copyright © 2005 Booleansoup.com
Questions? Comments? Bug reports? Contact us!