Hey all, I just got back into coding. Trying to make a simple breakout game, I did start of just making a simple 'pong' game but found it quite easy so I am trying to expand it to a breakout game (image attached for those who do not know what it is).
To handle the blocks at the top of the screen I have used a vector of blocks, from which right now I am trying to draw them onto the screen. I am unable to do this as I am getting an error: error C2664: 'void sf::RenderTarget::draw(const sf::Vertex *,size_t,sf::PrimitiveType,const sf::RenderStates &)' : cannot convert argument 1 from 'Block' to 'const sf::Drawable &'
which is inside the block.cpp file
Here is the relevant code, there are more functions but they do not apply to this. Sorry for any bad code in there :)
The sf::RenderWindow::draw function expects a sf::Drawable object as argument, but in Block::draw you're passing a Block object as argument and that's why I asked if Block was a sf::Drawable (meaning that Block inherits from sf::Drawable). I see now that it's not the case.
What you intended to do was probably to pass the sf::RectangleShape (a subclass of sf::Drawable) member variable named block as argument. I guess you have already figured this out because you are no longer passing the block object as an argument to Block::draw but it seems like you've forgot to update the code in Block::draw because it still have two parameters.
I think the problem you're facing now is caused by the loop. i is never greater than 10 so the loop never runs. Shouldn't you instead check if i is less than blockContainer.size()? Also don't forget that indices start counting from 0.