Naprawiono białe kwadraty i zmieniono tło

This commit is contained in:
2024-11-15 17:12:17 +01:00
parent ce2924e635
commit 88fa5901b6
7 changed files with 13 additions and 7 deletions

View File

@@ -10,6 +10,8 @@ Actor::Actor(int x, int y, std::string path) {
void Actor::loadTexture(std::string path) {
actorTexture.loadFromFile(path);
actorSprite.setTexture(actorTexture);
bulletTexture.loadFromFile("../assets/img/bullet.png");
}
sf::Sprite &Actor::getSprite() {
@@ -35,10 +37,9 @@ Position Actor::getPosition() {
}
void Actor::shoot() {
bullets.emplace_back(position.x + actorSprite.getGlobalBounds().width / 2-62, position.y);
bullets.emplace_back(float(position.x) + actorSprite.getGlobalBounds().width / 2-62, position.y, bulletTexture);
}
std::vector<Bullet> &Actor::getBullets() {
return bullets;
}

View File

@@ -1,9 +1,9 @@
#include <iostream>
#include "../headers/Bullet.h"
Bullet::Bullet(float x, float y) {
Bullet::Bullet(float x, float y, sf::Texture &bulletTexture) {
outOfBounds = false;
bulletTexture.loadFromFile("../assets/img/bullet.png");
// bulletTexture.loadFromFile("../assets/img/bullet.png");
bulletSprite.setTexture(bulletTexture);
bulletSprite.setPosition(x, y);
bulletSpeed = -10.0f;
@@ -24,6 +24,6 @@ void Bullet::update() {
bulletPosition.y += bulletSpeed;
if(bulletPosition.y < -100) {
outOfBounds = true;
std::cout << "Bullet out of bounds\n";
// std::cout << "Bullet out of bounds\n";
}
}