Line 28 makes no sense. You're comparing two variables to themselves.
(myPlayer.position().x == myPlayer.position().x
|
Some times I type to fast for my own good, yes that's what I meant :P.
Now that is fixed that everything seems to work and I can hit multiple objects and their pointers will be erased from the vector.
Note that this will only remove the pointers from the 'v_collectables vector'. The objects that the pointers point to will continue to exist.
|
Should I also be removing the objects? Or is it the pointers remain which will no longer point to anything?
Another question, I instantiate an instance of the 'Collectable' class in my game.cpp.
When doing so it calls the default constructor, within that I have some variables and a call to a function which randomizes the x & y. T
The x&y are passed through a gotoxy function, however they are overridden for some reason when my 'CollectableHandler' spawns a new instance of a 'Collectable' which causes the X&Y to not be correct in the console window.
Ideally I don't want this to happen but I need to access some functions that are in the 'Collectable' class. I am not sure of a work around at the moment other than not to create an instance of 'Collectable' in my game.cpp and then all x&y's match up perfectly.
Thanks for the help so far, really appreciated, helps me understand where I am going wrong. ^^