Strzelanie Lewym i Prawym przyciskiem myszy.

Dodanie tekstury strzału alternatywnego
This commit is contained in:
2024-11-18 15:45:57 +01:00
parent fcabc0534a
commit a69dc434a9
6 changed files with 24 additions and 8 deletions

View File

@@ -12,7 +12,7 @@ void Actor::loadTexture(std::string path) {
actorTexture.loadFromFile(path);
actorSprite.setTexture(actorTexture);
bulletTextureLeft.loadFromFile("../assets/img/bullet.png");
bulletTextureLeft.loadFromFile("../assets/img/bullet_left.png");
bulletTextureRight.loadFromFile("../assets/img/bullet_right.png");
}

View File

@@ -10,6 +10,14 @@ void Player::shoot() {
}
}
void Player::alternate_shoot() {
auto now = std::chrono::steady_clock::now();
if (std::chrono::duration_cast<std::chrono::milliseconds>(now - lastShotTime).count() >= firerate) {
bullets.emplace_back(float(position.x) + actorSprite.getGlobalBounds().width / 2-62, position.y, bulletTextureRight);
lastShotTime = now;
}
}
void Player::setFirerate(unsigned int firerate) {
this->firerate = firerate;
}