naprawa pozycji + nowe rakiety

This commit is contained in:
2024-11-21 22:42:12 +01:00
parent 2bdfbb193c
commit 343b312227
10 changed files with 14 additions and 14 deletions

View File

@@ -5,7 +5,7 @@ Player::Player(int x, int y, std::string path) : Actor(x, y, path) {};
void Player::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, position.y, bulletTextureLeft);
bullets.emplace_back(position.x, position.y, bulletTextureLeft);
lastShotTime = now;
}
}
@@ -13,7 +13,7 @@ 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, position.y, bulletTextureRight);
bullets.emplace_back(position.x, position.y, bulletTextureRight).getSprite().scale(1.5f, 1.5f);
lastShotTime = now;
}
}
@@ -28,20 +28,20 @@ void Player::move(float deltaX, float deltaY) {
void Player::moveLeft() {
move(-moving_speed, 0.0f);
position.x -= moving_speed;
position.x -= static_cast<int>(moving_speed);
}
void Player::moveRight() {
move(moving_speed, 0.0f);
position.x += moving_speed;
position.x += static_cast<int>(moving_speed);
}
void Player::moveUp() {
move(0.0f, -moving_speed);
position.y -= moving_speed;
position.y -= static_cast<int>(moving_speed);
}
void Player::moveDown() {
move(0.0f, moving_speed);
position.y += moving_speed;
position.y += static_cast<int>(moving_speed);
}