Using New and Delete in inherited classes and stored pointers to the new object

Started by
10 comments, last by ASnogarD 11 years, 8 months ago

That may of been a cause for sure, however I deleted those classes to re-write them so I cant go check now.


Just FYI, it helps to use source control, even if you are the only one on the project, since then you will have all the history for all files and can go to any past version http://en.wikipedia....evision_control.

As far as which one to use, I think FAQ here might have more info.
Advertisement
Well I am happy to report that the problem is sorted... as best as I can tell I am clearing every bullet and the element in the entity store that was holding the pointer to the bullet.
I have a static counter counting bullets as the constructor is called, and taking one off each time the destructor is called... and the numbers are consistant, I also check the number of elements in my vector ( basic int variable counts 1 each time an element is called , reports total count after loop, then resets ) and it show 1 for the player and the number of bullets consistantly.

.... plus the FPS dips when there is a LOT of bullets fired (over 98 in one trial, with keyboard repeat enabled ) but returns to the usual values when the bullets are cleared... I assume if there is a lot of bullets lost in the system it would degrade performance.

I basically got the same code in but the approach was different. I basically wrote the player and bullet as thier own classes without inheriting the entity class , then got both to behave properly as seperate classes... then I created the entity class and got the player and bullet classes to inherit from it and set everything to work via polymorphic inheritance.
In short I got the 2 classes to work properly before I made them into a fancy inherited polymorphic tree to eliminate inheritance issues and polymorphism bugs.

Finally... now I can add enemy entities, finish off the level editor ...and a ton of other shite... why do I do this again for ? :P

This topic is closed to new replies.

Advertisement