47 lines
1.2 KiB
C++
47 lines
1.2 KiB
C++
// joc_asteroides.hpp - Lògica principal del joc
|
|
// © 1999 Visente i Sergi (versió Pascal)
|
|
// © 2025 Port a C++20 amb SDL3
|
|
|
|
#ifndef JOC_ASTEROIDES_HPP
|
|
#define JOC_ASTEROIDES_HPP
|
|
|
|
#include <SDL3/SDL.h>
|
|
#include <array>
|
|
#include <cstdint>
|
|
#include "core/types.hpp"
|
|
#include "game/constants.hpp"
|
|
|
|
// Classe principal del joc
|
|
class JocAsteroides {
|
|
public:
|
|
JocAsteroides(SDL_Renderer* renderer);
|
|
~JocAsteroides() = default;
|
|
|
|
void inicialitzar();
|
|
void actualitzar(float delta_time);
|
|
void dibuixar();
|
|
void processar_input(const SDL_Event& event);
|
|
|
|
private:
|
|
SDL_Renderer* renderer_;
|
|
|
|
// Estat del joc
|
|
Triangle nau_;
|
|
std::array<Poligon, Constants::MAX_ORNIS> orni_;
|
|
std::array<Poligon, Constants::MAX_BALES> bales_;
|
|
Poligon chatarra_cosmica_;
|
|
uint16_t itocado_;
|
|
|
|
// Funcions de dibuix
|
|
bool linea(int x1, int y1, int x2, int y2, bool dibuixar);
|
|
void rota_tri(const Triangle& tri, float angul, float velocitat, bool dibuixar);
|
|
void rota_pol(const Poligon& pol, float angul, bool dibuixar);
|
|
|
|
// Moviment
|
|
void mou_orni(Poligon& orni, float delta_time);
|
|
void mou_bales(Poligon& bala, float delta_time);
|
|
void tocado();
|
|
};
|
|
|
|
#endif // JOC_ASTEROIDES_HPP
|