Exemplo n.º 1
0
void  Controlador_principal::dibujar(DLibV::Pantalla& pantalla)
{
	if(centrar)
	{
		auto fcentrar=[this](DLibV::Representacion_TTF * txt)
		{
			int ancho=txt->acc_posicion().w;
			int x=camara.acc_pos_x()+(camara.acc_caja_foco().w /2)-(ancho/2);
			txt->establecer_posicion(x, 0, 0, 0, DLibV::Representacion::FRECT_X);
		};

		try
		{
			auto * txt_jap=static_cast<DLibV::Representacion_TTF *>(vista.obtener_por_id("txt_japones"));
			auto * txt_rom=static_cast<DLibV::Representacion_TTF *>(vista.obtener_por_id("txt_romaji"));
			auto * txt_tra=static_cast<DLibV::Representacion_TTF *>(vista.obtener_por_id("txt_traduccion"));

			txt_jap->preparar(pantalla.acc_renderer());	
			txt_rom->preparar(pantalla.acc_renderer());
			txt_tra->preparar(pantalla.acc_renderer());
	
			fcentrar(txt_jap);
			fcentrar(txt_rom);
			fcentrar(txt_tra);
		

			centrar=false;
		}
		catch(std::exception& e)
		{
			std::string err="Error al centrar interface: ";
			err+=e.what();
			throw std::runtime_error(err);
		}

	}

	vista.volcar(pantalla, camara);
}
Exemplo n.º 2
0
void Controlador_juego::dibujar(DLibV::Pantalla& pantalla)
{
	using namespace App_Interfaces;

	//Pantalla...
	pantalla.limpiar(128, 128, 128, 255);

	//Recolectar representables...
	std::vector<const Representable_I *> vr=(*sala_actual).obtener_vector_representables();
	vr.push_back(&jugador);

	for(const auto& p : proyectiles_jugador) vr.push_back(p.get());
	for(const auto& p : proyectiles_enemigos) vr.push_back(p.get());

	//TODO: Ordenar la vista.
	
	//Generar vista.
	representador.generar_vista(pantalla, vr);

	//Hud
	std::stringstream ss;
	ss<<jugador.acc_espaciable_x()<<","<<jugador.acc_espaciable_y()<<std::endl<<" HULL: "<<jugador.acc_salud()<<" SHIELD: "<<jugador.acc_escudo();

	DLibV::Representacion_texto_auto_estatica rep_hud(pantalla.acc_renderer(), DLibV::Gestor_superficies::obtener(App::Recursos_graficos::RS_FUENTE_BASE), ss.str());
	rep_hud.establecer_posicion(16, 16);
	rep_hud.volcar(pantalla);

	//Contador de tiempo...
	rep_hud.asignar(contador_tiempo.formatear_tiempo_restante());
	rep_hud.establecer_posicion(16, 32);
	rep_hud.volcar(pantalla);

	//Automapa	
	representador.dibujar_marco_automapa(pantalla);

	const auto& v=automapa.acc_vista();
	int x=0, y=0;

	for(const auto& u : v)
	{
		representador.dibujar_pieza_automapa(pantalla, x, y, u.visitado ? u.tipo : App_Definiciones::direcciones::nada);
		if(++x==App_Juego_Automapa::Definiciones_automapa::ANCHO)
		{
			x=0; ++y;
		}
	}
}
Exemplo n.º 3
0
void  Controlador_menu::dibujar(DLibV::Pantalla& pantalla)
{
	if(centrar)
	{
		try
		{
			auto fcentrar=[](DLibV::Representacion_TTF * txt, int x, int w, int flags)
			{
				int fac=txt->acc_posicion().w;
				int px=x+(w /2)-(fac/2);
				txt->establecer_posicion(px, px, 0, 0, flags);
			};

			std::map<std::string, DLibV::Representacion_TTF *> map={
				{"txt_iniciar", nullptr}, {"txt_etiquetas", nullptr}, 
				{"txt_config_ejercicio", nullptr}, {"txt_config_app", nullptr}};

			for(auto& p : map) 
			{
				p.second=static_cast<DLibV::Representacion_TTF *>(vista.obtener_por_id(p.first));
				p.second->preparar(pantalla.acc_renderer());
			}

			auto caja_centrar=vista.obtener_por_id("centrar_txt");

			int 	xh=caja_centrar->acc_posicion().x, 
				wh=caja_centrar->acc_posicion().w,
				xv=caja_centrar->acc_posicion().y,
				wv=caja_centrar->acc_posicion().h;    

			fcentrar(map["txt_iniciar"], xh, wh, DLibV::Representacion::FRECT_X);
			fcentrar(map["txt_etiquetas"], xh, wh, DLibV::Representacion::FRECT_X);
			fcentrar(map["txt_config_ejercicio"], xv, wv, DLibV::Representacion::FRECT_Y);
			fcentrar(map["txt_config_app"], xv, wv, DLibV::Representacion::FRECT_Y);

			centrar=false;
		}
		catch(std::exception& e)
		{
			std::string err="Error al despertar controlador menú: ";
			err+=e.what();
			throw std::runtime_error(err);
		}
	}

	vista.volcar(pantalla, camara);
}