Statek + Strzelanie (do naprawienia białe kwadraty)
This commit is contained in:
@@ -1 +1,44 @@
|
||||
#include "../headers/actor.h"
|
||||
#include "../headers/Actor.h"
|
||||
|
||||
Actor::Actor(int x, int y, std::string path) {
|
||||
loadTexture(path);
|
||||
position.x = x;
|
||||
position.y = y;
|
||||
actorSprite.setPosition(x, y);
|
||||
}
|
||||
|
||||
void Actor::loadTexture(std::string path) {
|
||||
actorTexture.loadFromFile(path);
|
||||
actorSprite.setTexture(actorTexture);
|
||||
}
|
||||
|
||||
sf::Sprite &Actor::getSprite() {
|
||||
return actorSprite;
|
||||
}
|
||||
|
||||
void Actor::move(float deltaX, float deltaY) {
|
||||
actorSprite.move(deltaX, deltaY);
|
||||
}
|
||||
|
||||
void Actor::moveLeft() {
|
||||
move(-10.0f, 0.0f);
|
||||
position.x -= 10;
|
||||
}
|
||||
|
||||
void Actor::moveRight() {
|
||||
move(10.0f, 0.0f);
|
||||
position.x += 10;
|
||||
}
|
||||
|
||||
Position Actor::getPosition() {
|
||||
return {position.x, position.y};
|
||||
}
|
||||
|
||||
void Actor::shoot() {
|
||||
bullets.emplace_back(position.x + actorSprite.getGlobalBounds().width / 2-62, position.y);
|
||||
}
|
||||
|
||||
std::vector<Bullet> &Actor::getBullets() {
|
||||
return bullets;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user