Hello
Posted: September 24th, 2017, 3:37 am
hello guys, im new here and im new to c++. i wanna say chili i appreciate your tutorials man.
i have a question, i am planning to make a space adventure game wherein you have a spaceship (rectangle for now) and youre gonna dodge things(other rectangles for now) that are coming at you. im on the planning stage right now and i was wondering if do i need destructors for my enemy class since there will be a lot of it that will go to the edge of the screen and wont be displayed anymore as the game progress.
im planning to implement something like ill have a loop that will go through every obstacle just like in the poo game and when they go to the edge of the screen ill destroy the obstacles and reuse the index of the destroyed obstacles .
to recap, how do i destroy classes? do i really need destructors for this case? or ill just overwrite the previous values and ignore? i appreciate the help. thank you in advance.
Edited by albinopapa:
Just put code in[/code]]tags
i have a question, i am planning to make a space adventure game wherein you have a spaceship (rectangle for now) and youre gonna dodge things(other rectangles for now) that are coming at you. im on the planning stage right now and i was wondering if do i need destructors for my enemy class since there will be a lot of it that will go to the edge of the screen and wont be displayed anymore as the game progress.
im planning to implement something like ill have a loop that will go through every obstacle just like in the poo game and when they go to the edge of the screen ill destroy the obstacles and reuse the index of the destroyed obstacles .
Code: Select all
for (int i = 0; i < maxObstacle; i++)
{
if (obstacle[i].isDestroyed())
{
// really destroy it
// then reindex
obstacle[i] = obstacle[maxObstacle];
maxObstacle--;
i--;
}
else
{
// draw and other logic
}
}
Edited by albinopapa:
Just put code in
Code: Select all
[code]