Strzelanie Lewym i Prawym przyciskiem myszy.
Dodanie tekstury strzału alternatywnego
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user