Transición calendario visto -> calendario quitado

parent 3b7f7153
No preview for this file type
......@@ -20,6 +20,13 @@ void Handle::removeAll(){
gestor.pantallas.clear();
}
bool Handle::pantallaMinimizada() {
Uint32 flags = SDL_GetWindowFlags(gestor.window);
return
(flags & SDL_WINDOW_MINIMIZED) != 0
|| (flags & SDL_WINDOW_HIDDEN) != 0;
}
void cambiar_buffers(SDL_Renderer *renderer) {
SDL_RenderPresent(renderer);
}
......
......@@ -26,6 +26,7 @@ class Handle{
void removeAll();
int getTamX(){return tamx;}
int getTamY(){return tamy;}
bool pantallaMinimizada();
};
......
......@@ -35,13 +35,29 @@ static void iniciarInicio() {
static void iniciarCalendarioVisto(){
Sprite sprPantalla("assets/pantalla.png");
Hitbox hitPantalla(300,200,500,-1000000);
auto funcionPantalla=[](Objeto *Pantalla)->bool{
play_video("assets/MiedoCalendario2","es");
return false;
};
Objeto Pantalla(sprPantalla,sprPantalla,sprPantalla,hitPantalla,0,100,400,400,normal,funcionPantalla);
getPantalla1()->anadirObjeto(Pantalla);
auto funcionComprobarPantallaMinimizada = [] (Handle &handle) -> bool {
std::cout << "Calling hook" << std::endl;
if (handle.pantallaMinimizada()) {
historiaPrincipal.pasarDeEstadoA(Historia::Secuencia::CalendarioVisto, Historia::Secuencia::CalendarioQuitado);
std::cout << "Minimini" << std::endl;
return true;
}
std::cout << "No minimini" << std::endl;
return false;
};
getPantalla1()->anadirHook(funcionComprobarPantallaMinimizada);
}
void Historia::siguienteEstado(Secuencia estado){
......
......@@ -90,6 +90,12 @@ void PantallaMundo::manejarEntrada(Handle &handle) {
handle.removeAll();
}
}
for (int i = 0; i < hooks.size(); i++) {
if (hooks[i](handle)) {
hooks.erase(hooks.begin() + i);
i--;
}
}
}
void PantallaMundo::renderizar(SDL_Renderer *renderer, int tamx, int tamy) {
......@@ -124,3 +130,7 @@ void PantallaMundo::borrarElementos(){
void PantallaMundo::anadirObjeto(Objeto nuevo){
objetos.push_back(nuevo);
}
void PantallaMundo::anadirHook(Hook hook) {
hooks.push_back(hook);
}
......@@ -31,6 +31,10 @@ class PantallaMundo : public Pantalla {
std::array<int, 2> posicion_inicio_personaje;
typedef bool (*Hook)(Handle &);
std::vector<Hook> hooks;
protected:
vector<Objeto> objetos;
vector<Hitbox> colisionesActivas;
......@@ -57,4 +61,6 @@ public:
void borrarElementos();
void anadirObjeto(Objeto nuevo);
void anadirHook(Hook);
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment