afegida colisió nau-enemics i game over
This commit is contained in:
@@ -29,7 +29,7 @@ Nau::Nau(SDL_Renderer* renderer)
|
||||
}
|
||||
}
|
||||
|
||||
void Nau::inicialitzar() {
|
||||
void Nau::inicialitzar(const Punt* spawn_point) {
|
||||
// Inicialització de la nau (triangle)
|
||||
// Basat en el codi Pascal original: lines 380-384
|
||||
// Copiat de joc_asteroides.cpp línies 30-44
|
||||
@@ -37,11 +37,17 @@ void Nau::inicialitzar() {
|
||||
// [NUEVO] Ja no cal configurar punts polars - la geometria es carrega del
|
||||
// fitxer Només inicialitzem l'estat de la instància
|
||||
|
||||
// Posició inicial al centre de l'àrea de joc
|
||||
float centre_x, centre_y;
|
||||
Constants::obtenir_centre_zona(centre_x, centre_y);
|
||||
centre_.x = centre_x; // 320
|
||||
centre_.y = centre_y; // 213 (not 240!)
|
||||
// Use custom spawn point if provided, otherwise use center
|
||||
if (spawn_point) {
|
||||
centre_.x = spawn_point->x;
|
||||
centre_.y = spawn_point->y;
|
||||
} else {
|
||||
// Default: center of play area
|
||||
float centre_x, centre_y;
|
||||
Constants::obtenir_centre_zona(centre_x, centre_y);
|
||||
centre_.x = static_cast<int>(centre_x);
|
||||
centre_.y = static_cast<int>(centre_y);
|
||||
}
|
||||
|
||||
// Estat inicial
|
||||
angle_ = 0.0f;
|
||||
|
||||
@@ -16,7 +16,7 @@ class Nau {
|
||||
: renderer_(nullptr) {}
|
||||
Nau(SDL_Renderer* renderer);
|
||||
|
||||
void inicialitzar();
|
||||
void inicialitzar(const Punt* spawn_point = nullptr);
|
||||
void processar_input(float delta_time);
|
||||
void actualitzar(float delta_time);
|
||||
void dibuixar() const;
|
||||
@@ -25,6 +25,7 @@ class Nau {
|
||||
const Punt& get_centre() const { return centre_; }
|
||||
float get_angle() const { return angle_; }
|
||||
bool esta_viva() const { return !esta_tocada_; }
|
||||
const std::shared_ptr<Graphics::Shape>& get_forma() const { return forma_; }
|
||||
|
||||
// Col·lisions (Fase 10)
|
||||
void marcar_tocada() { esta_tocada_ = true; }
|
||||
|
||||
Reference in New Issue
Block a user