Create a bullet class and have a property orientation or similar.
I thought about it, but I wanted to find a simpler solution.How is that simpler? Instead of maintaining one container, you have to keep two in sync and do everything twice. When a function needs access to multiple attributes of a bullet, you have to pass them as separate arguments instead of one combined object.
Another possibility is maybe to create 2 vectors(one with left direction another with right)?
How is that simpler? Instead of maintaining one container, you have to keep two in sync and do everything twice. When a function needs access to multiple attributes of a bullet, you have to pass them as separate arguments instead of one combined object.No it's not. I was a bit unclear - i just thought theoretically what other option do I have. Making 2 vectors would add a lot of code to my project - which does not make sense.
Object-oriented programming is good. Use a class for your object, and please don't inherit it from an SFML class...so you don't recommend doing this ->
By the way:Ty for the tip.I will look into your article.This code really hurts my eyes. You do not only have a memory leak, but seem to use new for no reason. Avoid manual memory management in your C++ code, it's not necessary -- see also my article about RAII (http://www.bromeon.ch/articles/raii.html).(click to show/hide)
so you don't recommend doing this ->That's perfectly okay, classes like sf::Transformable, sf::Drawable and sf::NonCopyable are meant to be used as base classes. But I see a lot of people inheriting sf::Sprite etc. to add their own functionality, while that was never a design intended by the authors.class Bullet : public sf::Drawable {}How else can I make it drawable?
my create/move bullet function now looks like thisLooks good, cool that you're using the erase-remove-idiom!