I had a hard time naming this topic but i hope this is ok.
So my problem is that im making a 2D tower defence game and i was just gonna start making the tower classes and interface. And ive come to a problem.
I will only post the concept code not valid c++ code
So my interface class looks something like this.
1 2 3 4 5 6 7
|
class tower
{
virtual fire();
virtual stopFire();
virtual render();
virtual remove();
};
|
then i have a arrowTower class that inherits from tower and i think you understand how i mean so i dont have to post it.
but then i wanted to have a class called noTower which basicly means that there is no tower on the tile and it does not need to be rendered or updated.
But here is my problem.
So i put all those towers in a 2D vector that looks like this
std::vector< std::vector<tower*> > towerMap;
I think it is logical to use a remove function to set the arrowTower to noTower.
But im not sure how to implement that.
I know i can use the delete and new to do this more manually but i think its more logical to do it this way if its possible.
Is it possible to do something like:
this = noTower
Hope you can help me with this or maybe give me another way to do it.
Thanks in advance
EDIT: this maybe seems confusing. Just reply or PM and i can send my code and maybe you will understand what i mean better