When the value of shoot speed is assigned to 0 - 3, the program exits without an error. However, with a value more than 3, this lovely error comes up - "Unhandled exception at 0x770015de in Practice SFML.exe: 0xC0000005: Access violation reading location 0xfeeefef6."
Here's the two functions that use these variables.
Turent::Init-
void Turent::Init()
{
sprite.setPosition(400, 300);
sprite.setTexture(textureManager.turent);
sprite.setOrigin(sprite.getGlobalBounds().width / 2, sprite.getGlobalBounds().height / 2);
InScreen.setSize(sf::Vector2f(1024, 768));
shootSpeed = sf::milliseconds(100); //line where I change the value
}
Turent::Shoot-
void Turent::Shoot(sf::RenderWindow& Window)
{
if(shootClock.getElapsedTime().asSeconds() > shootSpeed.asSeconds() && sf::Mouse::isButtonPressed(sf::Mouse::Left)) //line where it's used
{
Bullet blt;
blt.Setup(sprite.getPosition().x, sprite.getPosition().y, rotation + 90, sf::Mouse::getPosition(Window).x, sf::Mouse::getPosition(Window).y);
bullets.push_back(blt);
shootClock.restart();
}
}
Note these were working perfectly until it stopped.