From a16dcbc4db7cdf32e856f74566c013ee26e7b479 Mon Sep 17 00:00:00 2001 From: iscd3 Date: Wed, 12 Nov 2025 12:09:17 +0200 Subject: [PATCH] Code review 1 Gloantele nu aveau un timp de moarte si ocupau putere de procesare si memorie --- code/Bullet.cpp | 15 +++++++++++++++ code/Bullet.h | 9 ++++++--- code/SpaceShip.cpp | 7 +++++-- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/code/Bullet.cpp b/code/Bullet.cpp index a33ebd5..130fcf8 100644 --- a/code/Bullet.cpp +++ b/code/Bullet.cpp @@ -16,6 +16,7 @@ void Bullet::Display(const Pair& position, sf::RenderWindow& window, sf::FloatRe } } void Bullet::Update(sf::Time dt,Pair player,sf::RenderWindow& window,sf::FloatRect& viewRect) { + lifetime-=dt.asSeconds(); physics.UpdatePosition(dt); Display(player,window,viewRect); } @@ -28,7 +29,21 @@ Physics& Bullet::getPhysics() { float Bullet::getDamage() const { return damage; } +float Bullet::getLifetime() const { + return lifetime; +} const float Bullet::speed = 200.f; +Bullet &Bullet::operator=(const Bullet &other) { + if (this!=&other) { + shape = other.shape; + physics = other.physics; + collider = other.collider; + damage = other.damage; + radius = other.radius; + lifetime = other.lifetime; + } + return *this; +} std::ostream& operator<<(std::ostream& out,const Bullet& bullet) { out<<"BULLET\n"; out<