#52803 - ChronicImpact - Sat Sep 03, 2005 11:45 am
Okay, I've just started work on my first serious game in C++ using classes, and I've hit a brick wall.
I figured that it would be easy enough to declare each object as a class, a class for the play, one for solids, etc.
The problem is checking for collisions.
I have an array of class CSolid for the solid objects, and a single class CPlayer, each with x and y values for their position. So if I want to check if the player has hit a solid... I have to check the x and y values of CPlayer against all the CSolids, upto about 500 per level... and to check the variables of 500 classes each vblank... gah, it's far too slow!
I've thought of plenty of ways to speed it up... only check the solids on screen, only check the ones in certian directions, blah blah... but all of it still requires checking the entire array of solids to see if they're on screen or in the right direction etc...
Keeping in mind that I'm not overly experienced with using classes, can any offer a few suggestions for a much neater way of doing this?
I figured that it would be easy enough to declare each object as a class, a class for the play, one for solids, etc.
The problem is checking for collisions.
I have an array of class CSolid for the solid objects, and a single class CPlayer, each with x and y values for their position. So if I want to check if the player has hit a solid... I have to check the x and y values of CPlayer against all the CSolids, upto about 500 per level... and to check the variables of 500 classes each vblank... gah, it's far too slow!
I've thought of plenty of ways to speed it up... only check the solids on screen, only check the ones in certian directions, blah blah... but all of it still requires checking the entire array of solids to see if they're on screen or in the right direction etc...
Keeping in mind that I'm not overly experienced with using classes, can any offer a few suggestions for a much neater way of doing this?