Restrukt classes WIP
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
#include "../headers/Player.h"
|
||||
#include "../headers/Bullet.h"
|
||||
|
||||
Player::Player(int x, int y, std::string path) : Actor(x, y, path) {};
|
||||
// TODO: Podzielić na klasy Bullet i Rocket.
|
||||
Player::Player(int x, int y, std::string path) : Actor(x, y, path) {
|
||||
Bullet::bulletTexture.loadFromFile("../assets/img/bullet_left.png");
|
||||
};
|
||||
|
||||
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(position.x, position.y, bulletTextureLeft);
|
||||
bullets.emplace_back(position.x, position.y);
|
||||
lastShotTime = now;
|
||||
}
|
||||
}
|
||||
@@ -14,7 +18,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(position.x, position.y, bulletTextureRight).getSprite().scale(1.5f, 1.5f);
|
||||
bullets.emplace_back(position.x, position.y).getSprite().scale(1.5f, 1.5f);
|
||||
lastShotTime = now;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user