So, im creating a little game as a school project, a very simple one, im trying to create projectiles but when i press 'F' to fire the game crash.
here the part on the code
int fire_c = 0;
std::vector <sf::RectangleShape> fire (fire_c);
std::vector <sf::Vector2f> fire_p (fire_c);
if (sf::Keyboard::isKeyPressed(sf::Keyboard::F)) {
fire_c = fire_c + 1;
fire.resize(fire_c);
fire_p.resize(fire_c);
fire[fire_c].setFillColor(sf::Color::Red);
fire[fire_c].setSize(sf::Vector2f(2,5));
fire_p[fire_c].x = astronave_p.x + 4;
fire_p[fire_c].y = astronave_p.y - 6;
pioggia[fire_c].setPosition(pioggia_p[fire_c]);
}
for (int i = 1; i < fire_c; i++) {
fire_p[i].y = fire_p[i].y - 5;
fire[i].setPosition (fire_p[i]);
}
for (int i = 1; i < fire_c; i++) {window.draw(fire[i]);}