Niby strzela, ale bez kolizji
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#include "../headers/Actor.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
Actor::Actor(int x, int y, std::string path) {
|
||||
loadTexture(path);
|
||||
position.x = x;
|
||||
@@ -29,13 +31,17 @@ std::vector<Bullet> &Actor::getBullets() {
|
||||
}
|
||||
|
||||
void Actor::updateBullets() {
|
||||
for (auto& bullet : bullets) {
|
||||
if(bullet.isOutOfBounds()) {
|
||||
bullets.erase(bullets.begin());
|
||||
for (auto it = bullets.begin(); it != bullets.end(); ) {
|
||||
if (it->isOutOfBounds()) {
|
||||
it = bullets.erase(it); // Usuwa element i zwraca iterator na następny element
|
||||
} else {
|
||||
++it; // Przechodzi do następnego elementu
|
||||
}
|
||||
}
|
||||
std::cout << "Liczba pociskow: " << bullets.size() << std::endl;
|
||||
}
|
||||
|
||||
|
||||
void Actor::setMovingSpeed(float speed) {
|
||||
moving_speed = speed;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user