Пример #1
0
void MatLabExporter::si(t_output &prog, t_proceso_it r, t_proceso_it q, t_proceso_it s, string tabs){
	insertar(prog,tabs+"if "+expresion((*r).par1));
	bloque(prog,++r,q,tabs+"\t");
	if (q!=s) {
		insertar(prog,tabs+"else");
		bloque(prog,++q,s,tabs+"\t");
	}
	insertar(prog,tabs+"end");
}
Пример #2
0
void VbExporter::si(t_output &prog, t_proceso_it r, t_proceso_it q, t_proceso_it s, string tabs){
	insertar(prog,tabs+"If "+expresion((*r).par1)+" Then");
	bloque(prog,++r,q,tabs+"\t");
	if (q!=s) {
		insertar(prog,tabs+"Else");
		bloque(prog,++q,s,tabs+"\t");
	}
	insertar(prog,tabs+"End If");
}
Пример #3
0
void MatLabExporter::translate_single_proc(t_output &out, Funcion *f, t_proceso &proc) {
	
	// cabecera del proceso
	if (!f) {
		out.push_back(string("function ")+ToLower(main_process_name)+"()");
	} else {
		string dec="function ";
		if (f->nombres[0]!="") {
			dec+=ToLower(f->nombres[0])+" = ";
		}
		dec+=ToLower(f->id)+"(";
		for(int i=1;i<=f->cant_arg;i++) {
			if (i!=1) dec+=", ";
			dec+=ToLower(f->nombres[i])/*,f->pasajes[i]==PP_REFERENCIA)*/;
		}
		dec+=")";
		out.push_back(dec);
	}
	
	// cuerpo del proceso
	bloque(out,++proc.begin(),proc.end(),"\t");
	
	// cola del proceso
	out.push_back("end");
	if (!for_test) out.push_back("");
}
Пример #4
0
void VbExporter::segun(t_output &prog, list<t_proceso_it> its, string tabs){
	list<t_proceso_it>::iterator p,q,r;
	q=p=its.begin();r=its.end();
	t_proceso_it i=*q;
	insertar(prog,tabs+"Select Case "+expresion((*i).par1));
	++q;++p;
	while (++p!=r) {
		i=*q;
		if ((*i).par1=="DE OTRO MODO")
			insertar(prog,tabs+"Case Else");
		else {
			string e="Case "+expresion((*i).par1);
			bool comillas=false; int parentesis=0, j=0,l=e.size();
			while(j<l) {
				if (e[j]=='\''||e[j]=='\"') comillas=!comillas;
				else if (!comillas) {
					if (e[j]=='['||e[j]=='(') parentesis++;
					else if (e[j]==']'||e[j]==')') parentesis--;
					else if (parentesis==0 && e[j]==',') {
						e.replace(j,1,", "); l+=6;
					}
				}
				j++;
			}
			insertar(prog,tabs+e);
		}
		bloque(prog,++i,*p,tabs+"\t");
		++q;
	}
	insertar(prog,tabs+"End Select");
}
Пример #5
0
int pruebaAlmacenamientoBufferCache(char nombre_archivo[] ){
	AtributoVariable<string> nombre("N");
	AtributoVariable<int> numeros("#");
	AtributoFijo<int> num("n");
	Registro registro(3,&nombre,&numeros,&num);
	Bloque bloque(&registro);
	Clave clave(&registro,1,"N");
	ComparadorRegistroVariable comparador;
	EABloques estrategia(&bloque,125,0.8f);
	estrategia.setClave(&clave);
	estrategia.setComparador(&comparador);
	Archivo archivo(&estrategia);
	AlmacenamientoBufferCache cache(&archivo,5);
	/*archivo original*/
	cache.crear(nombre_archivo);
	for(int i=0;i<5;i++){
		*(AtributoVariable<string>*)registro.get(0)=Terminos::obtenerTermino(i).c_str();
		((AtributoVariable<int>*)registro.get(1))->getVector().clear();
		for(int j=0;j< i%4+1;j++){
			((AtributoVariable<int>*)registro.get(1))->getVector().push_back(j);
		};
		*((AtributoFijo<int>*)registro.get(2))=i;
		if(not ((Almacenamiento&)cache).insertar(&registro))
			cout<<"Problema"<<endl;
	}
	cache.imprimir(cout);
	cache.cerrar();
	archivo.setEstrategia(&estrategia);
	archivo.abrir(nombre_archivo);
	archivo.imprimir(cout);
	archivo.cerrar();
	return 0;
}
Пример #6
0
void MatLabExporter::segun(t_output &prog, list<t_proceso_it> its, string tabs){
	list<t_proceso_it>::iterator p,q,r;
	q=p=its.begin();r=its.end();
	t_proceso_it i=*q;
	insertar(prog,tabs+"switch "+expresion((*i).par1));
	++q;++p;
	while (++p!=r) {
		i=*q;
		if ((*i).par1=="DE OTRO MODO")
			insertar(prog,tabs+"otherwise");
		else {
			string e=expresion((*i).par1); int en=1;
			bool comillas=false; int parentesis=0, j=0,l=e.size();
			while(j<l) {
				if (e[j]=='\''||e[j]=='\"') comillas=!comillas;
				else if (!comillas) {
					if (e[j]=='['||e[j]=='(') parentesis++;
					else if (e[j]==']'||e[j]==')') parentesis--;
					else if (parentesis==0 && e[j]==',') {
						e.replace(j,1,","); l+=5; en++;
					}
				}
				j++;
			}
			if (en>1) e=string("{")+e+"}";
			insertar(prog,tabs+"case "+e);
		}
		bloque(prog,++i,*p,tabs+"\t");
		++q;
	}
	insertar(prog,tabs+"end");
}
Пример #7
0
void MatLabExporter::paracada(t_output &out, t_proceso_it r, t_proceso_it q, string tabs){
	string var=ToLower((*r).par2), aux=ToLower((*r).par1);
	const int *dims=memoria->LeerDims(var);
	if (!dims) { insertar(out,string("ERROR: ")+var+" NO ES UN ARREGLO"); return; }
	int n=dims[0];
	
	string *auxvars=new string[n];
	for(int i=0;i<n;i++) auxvars[i]=get_aux_varname("aux_index_");
	
	string vname=var, sep="(";
	for(int i=0;i<n;i++) { 
		string idx=auxvars[i];
		insertar(out,tabs+"for "+idx+"=1:size("+var+","+IntToStr(i+1)+")");
		vname+=sep+idx; sep=",";
		tabs+="\t";
	}
	vname+=")";
	
	for(int i=n-1;i>=0;i--) release_aux_varname(auxvars[i]);
	delete []auxvars;
	
	t_output aux_out;
	bloque(aux_out,++r,q,tabs);
	replace_var(aux_out,aux,vname);
	insertar_out(out,aux_out);
	for(int i=0;i<n;i++) { 
		tabs.erase(tabs.size()-1);
		insertar(out,tabs+"end");
	}
}
Пример #8
0
void VbExporter::repetir(t_output &prog, t_proceso_it r, t_proceso_it q, string tabs){
	insertar(prog,tabs+"Do");
	bloque(prog,++r,q,tabs+"\t");
	if ((*q).nombre=="HASTAQUE")
		insertar(prog,tabs+"Loop Until "+expresion((*q).par1));
	else
		insertar(prog,tabs+"Loop While "+expresion((*q).par1));
}
Пример #9
0
void MatLabExporter::para(t_output &prog, t_proceso_it r, t_proceso_it q, string tabs) {
	string var=expresion((*r).par1), ini=expresion((*r).par2), fin=expresion((*r).par3), paso=(*r).par4;
	if (paso=="1")
		insertar(prog,tabs+"for "+var+"="+ini+":"+fin);
	else
		insertar(prog,tabs+"for "+var+"="+ini+":"+expresion(paso)+":"+fin);
	bloque(prog,++r,q,tabs+"\t");
	insertar(prog,tabs+"end");
}
Пример #10
0
void VbExporter::para(t_output &prog, t_proceso_it r, t_proceso_it q, string tabs){
	string var=expresion((*r).par1), ini=expresion((*r).par2), fin=expresion((*r).par3), paso=(*r).par4;
	if (paso=="1")
		insertar(prog,tabs+"For "+var+"="+ini+" To "+fin);
	else
		insertar(prog,tabs+"For "+var+"="+ini+" To "+fin+" Step "+expresion(paso));
	bloque(prog,++r,q,tabs+"\t");
	insertar(prog,tabs+"Next "+var);
}
Пример #11
0
//bloque
//da inicio el análisis sintáctico
void bloque ()
{
 int temp;
 
 if (token==consttok) {
    obtoken();
    declaracionconst();//llamada a función que checa que la constante esté bien definida.                                   */
			           //si lo está, se coloca el identificador en la tds 
	while (token==coma) {
	      obtoken();
	      declaracionconst();
	}
	if (token==puntoycoma) 
	   obtoken();
	else
	   error(5); //error 5: falta una coma o un punto y coma
 }

 if (token==vartok) {
    obtoken();
    declaracionvar(); //llamada a función que checa que la variable esté bien declarada.                                 */
				      //si lo está, se coloca el identificador en la tds
	while (token==coma) {
	      obtoken();
	      declaracionvar();
	}
	if (token==puntoycoma)
	   obtoken();
	else
	   error(5); //error 5: Falta una coma o un punto y coma
 }
  
 while (token==proctok) {
       obtoken();
       if (token==ident) {
	      poner(PROCEDIMIENTO);
	      obtoken();
       }
       else
          error(4); //error 4: Const, Var y Procedure deben ir seguidos de un identificador

       if (token==puntoycoma)
	      obtoken();
       else
          error(5); //error 5: falta una coma o un punto y coma 

       temp=it;
       bloque();       
	   it=temp;
         
       if (token==puntoycoma)
	      obtoken();
	   else 
	      error(5);
 }
 instruccion();
}
Пример #12
0
//main: inicia el compilador...solo parser, pero ahora "estabilizado"
int main (int argc,char *argv[]) { 

 time_t timer;char fecha[LONG_FECHA]; //serviran para imprimir la fecha en el listado de salida

 //verificar si hay archivo fuente
 if (argc!=2)
	printf("\nNo se ha proporcionado el nombre del programa fuente (uso: parser2 progfuente)");
 else { 
	fp=fopen(argv[1],"r"); //abrir el fuente solo para lectura
	if (fp==NULL) 
	   printf("\nNo se encontro el programa fuente indicado");
	else {
	   timer=time(NULL);
	   strcpy(fecha,asctime(localtime(&timer)));
	   printf("\n\nCompilador de pl0 version 3.0/Parser2 --- abril de 2011 --- A2\n");
	   printf("%s - %s\n",argv[1],fecha);

	   //inicializacion de tokens de símbolos especiales (en auxiliares.cpp)
	   inicializar_espec() ; 

	   //inicializacion de otras variables (en pl0.h y scanner.h)
	   ch=' ';
	   fin_de_archivo=0;
	   offset=-1;ll=0;
	   no_de_errores=0; 

	   //inicialización de conjuntos de estabilización (en conjuntos.cpp)
	   inicializa_conjuntos();

       // inicializacion de la tabla de simbolos (en tds.cpp)
       inicializarTdS();

	   //invocar al scanner (en scanner.cpp)
	   obtoken(); 

	   //inicializamos el índice sobre la tds (it en tds.h)
	   it =0; 
	  
	   //activación del parser (en parser.h)
	   bloque(set_arranque); 

	   if (token!=punto)	
		  error(9); //error 9: se esperaba un punto

	   //indicar cuántos errores hay (si los hubieron) (en auxiliares.cpp)
	   estadisticas();

	   //cerrar el programa fuente
	   fclose(fp);	   	   
	}
 }
 return (0);
}
Пример #13
0
void MatLabExporter::repetir(t_output &prog, t_proceso_it r, t_proceso_it q, string tabs){
	string auxvar=get_aux_varname("aux_logica_");
	insertar(prog,tabs+auxvar+"=true;");
	insertar(prog,tabs+"while "+auxvar);
	bloque(prog,++r,q,tabs+"\t");
	if ((*q).nombre=="HASTAQUE")
		insertar(prog,tabs+"\t"+auxvar+"="+expresion(invert_expresion((*q).par1))+";");
	else
		insertar(prog,tabs+"\t"+auxvar+"="+expresion((*q).par1)+";");
	insertar(prog,tabs+"end");
	release_aux_varname(auxvar);
}
Пример #14
0
void VbExporter::translate_single_proc(t_output &out, Funcion *f, t_proceso &proc) {
	
	//cuerpo del proceso
	t_output out_proc;
	bloque(out_proc,++proc.begin(),proc.end(),"\t\t");
	
	// cabecera del proceso
	bool is_sub=true;
	string ret; // sentencia "Return ..." de la funcion
	if (!f) {
		out.push_back("\tSub Main()");
	} else {
		string dec;
		if (f->nombres[0]=="") {
			dec="\tPublic Sub "; 
		} else {
			is_sub=false;
			dec="\tPublic Function ";
			ret=string("\tReturn ")+ToLower(f->nombres[0]);
		}
		dec+=ToLower(f->id)+"(";
		for(int i=1;i<=f->cant_arg;i++) {
			if (i!=1) dec+=", ";
			dec+=get_tipo(f->nombres[i],f->pasajes[i]==PP_REFERENCIA);
		}
		dec+=")";
		out.push_back(dec);
	}
	
	declarar_variables(out);
	
	insertar_out(out,out_proc);
	
	// cola del proceso
	if (ret.size()) out.push_back(string("\t")+ret);
	out.push_back(is_sub?"\tEnd Sub":"\tEnd Function");
	if (!for_test) out.push_back("");
	
}
Пример #15
0
int pruebaEstragiaCompresionAlmacenamiento1(char nombre_archivo[]){
	AtributoVariable<string> nombre("N");
	AtributoVariable<int> numeros("#");
	AtributoFijo<int> num("n");
	Registro registro(3,&nombre,&numeros,&num);
	Bloque bloque(&registro);
	Clave clave(&registro,1,"N");
	ComparadorRegistroVariable comparador;
	EstrategiaCompresion compresion;
	EABloques estrategia(&bloque,125,0.8f);
	estrategia.setClave(&clave);
	estrategia.setComparador(&comparador);
	Archivo archivo(&estrategia);
	/*archivo original*/
	archivo.crear(nombre_archivo);
	if(not compresion.descompresion(&archivo)){
		for(int i=0;i<5;i++){
			*(AtributoVariable<string>*)registro.get(0)=Terminos::obtenerTermino(i).c_str();
			((AtributoVariable<int>*)registro.get(1))->getVector().clear();
			for(int j=0;j< i%4+1;j++){
				((AtributoVariable<int>*)registro.get(1))->getVector().push_back(j);
			};
			*((AtributoFijo<int>*)registro.get(2))=i;
			if(not ((Almacenamiento&)archivo).insertar(&registro))
				cout<<"Problema"<<endl;
		}
		//archivo.imprimir(cout);
		compresion.compresion(&archivo,512);
		cout<<"/***************COMPRIMIENDO************************/"<<endl;
	}else{
		archivo.imprimir(cout);
		cout<<"/***************DESCOMPRIMIDO**********************/"<<endl;
	}
	archivo.cerrar();
	remove(nombre_archivo);
	return 0;
}
Пример #16
0
//bloque
//da inicio el análisis sintáctico
void bloque (int toksig[])
{
  int temp;
  int setpaso[NOTOKENS]; //conjunto de paso por valor
  int vacio[NOTOKENS];   //conjunto vacío
  
  init_set(vacio);
  
  do { 
    if (token==consttok) {
      obtoken();
      //do-while:equivale a insertar una coma
      do {
        declaracionconst(); //llamada a función que checa que la constante esté bien definida.                                   */
        //si lo está, se coloca el identificador en la TDS 
        while (token==coma) {
          obtoken();
          declaracionconst();
        }
        if (token==puntoycoma) 
          obtoken();
        else
          error(5); //error 5: falta una coma o un punto y coma
      } while (token==ident); 
    }
    
    if (token==vartok) {
      obtoken();
      //análogo al "do" de arriba
      do {
        declaracionvar(); //llamada a función que checa que la variable esté bien declarada.                                 */
        //si lo está, se coloca el identificador en la TDS
        while (token==coma) {
          obtoken();
          declaracionvar();
        }
        if (token==puntoycoma)
          obtoken();
        else
          error(5); //error 5: Falta una coma o un punto y coma
      } while (token==ident);
    }
    
    while (token==proctok) {
      obtoken();
      if (token==ident) {
        poner(PROCEDIMIENTO);
        obtoken();
      }
      else
        error(4); //error 4: Const, Var y Procedure deben ir seguidos de un identificador
      
      if (token==puntoycoma)
        obtoken();
      else
        error(5); //error 5: falta una coma o un punto y coma 
      
      temp=it;
      copia_set(setpaso,toksig);
      setpaso[puntoycoma]=1; //setpaso=puntoycoma+toksig
      
      bloque(setpaso);       //sucesor+símbolos de cajón
      
      it=temp;
      
      if (token==puntoycoma) {
        obtoken();
        copia_set(setpaso,tokiniinst);
        setpaso[ident]=setpaso[proctok]=1; //setpaso=tokiniinst+ident+proctok
        test(setpaso,toksig,6); //¿símbolo incorrecto después de un procedimiento?
      }
      else 
        error(5);
      
    }
    
    copia_set(setpaso,tokiniinst);
    setpaso[ident]=1; //setpaso=tokiniinst+ident
    test(setpaso,tokinidecl,7); //se espera una instrucción
    
  } while (tokinidecl[token]==1); //salir cuando el token ya no sea de declaración
  
  copia_set(setpaso,toksig);
  setpaso[puntoycoma]=setpaso[endtok]=1; //setpaso=puntoycoma+end+toksig
  instruccion(setpaso);
  
  //aquí viene el chequeo explícito de que el token que viene a continuación
  //está en el conjunto de sucesores correctos (los sucesores de bloque)
  copia_set(setpaso,toksig);
  test(setpaso,vacio,8); //símbolo incorrecto detrás de las instrucciones de un bloque
}
Пример #17
0
int main()
{
	//Crear una ventana
	Vector2f windowMedidas;
	windowMedidas.x = 640; windowMedidas.y = 360;
	RenderWindow window(VideoMode(windowMedidas.x, windowMedidas.y), "Urban Mind (Demo)");
	window.setFramerateLimit(60);
	//Crear la V-Cam
	Vector2f CamaraPosicion, CamaraMedidas;
	CamaraPosicion.x = 0; CamaraPosicion.y = 0;
	CamaraMedidas.x = 640; CamaraMedidas.y = 360;
	View Camara(FloatRect(CamaraPosicion.x, CamaraPosicion.y, CamaraMedidas.x, CamaraMedidas.y));
	Camara.setCenter(CamaraMedidas.x / 2, CamaraMedidas.y / 2);

	int Screen = 1, nivel = 1, nivelMaximoAlcanzado = nivel; // Screen 1 = Menu, 2 = Niveles, 3 Otros...

	//Menu
	Texture BackgroundIMG;
	BackgroundIMG.loadFromFile("Dibujos/MainBackground.jpg");
	Sprite BGIMG;
	BGIMG.setTexture(BackgroundIMG);
	BGIMG.setOrigin(BackgroundIMG.getSize().x / 2, BackgroundIMG.getSize().y / 2);
	BGIMG.scale(0.48, 0.48);
	BGIMG.setPosition(320, 180);
	//Musica del menu
	sf::Music BgMainMusic;
	BgMainMusic.openFromFile("Musica/MainTheme.ogg");
	BgMainMusic.setVolume(50);
	BgMainMusic.setLoop(true);
	//Musica del juego
	Music LevelMusic;
	LevelMusic.openFromFile("Musica/LevelMusic.ogg");
	LevelMusic.setVolume(80);
	LevelMusic.setLoop(true);
	//Efecto de sonide empujar caja
	SoundBuffer DragFX;
	DragFX.loadFromFile("Musica/PullBox.ogg");
	Sound BoxFx(DragFX);
	//Botones
	int Selected = 0;
	bool KeyPressed = false;
	Boton Jugar = Boton(Vector2f(320, 180), "Dibujos/1Off.png", "Dibujos/1ON.png", 0.5), Salir = Boton(Vector2f(320, 230), "Dibujos/2Off.png", "Dibujos/2ON.png", 0.5);
	//Cosas inGame
	jugador yo = jugador(0,0);
	bloque box = bloque(1);
	bloque Tile1 = bloque(0);
	Texture TexturaMeta;
	TexturaMeta.loadFromFile("Dibujos/TSprite.jpg");
	Sprite Meta;
	Meta.setTexture(TexturaMeta);
	Meta.setOrigin(TexturaMeta.getSize().x / 2, TexturaMeta.getSize().y/2);
	Meta.scale(0.1,0.1);
	Vector2f coordenadasParaGanar;
	//Letras
	Font sansation;
	sansation.loadFromFile("Retro_Computer.ttf");
	Text scoreLabel("", sansation, 12);
	scoreLabel.setPosition(34, 15 * 34);
	scoreLabel.setColor(Color::White);

	//Contenedor de posiciones (Cajas), Contenedor de posiciones (Suelo)
	vector <Vector2f> contenedorDeCajas, contenedorDeSuelo;

	//Gameloop
	while (window.isOpen())
	{
		Event event;
		while (window.pollEvent(event))
		{
			if (event.type == Event::Closed)
				window.close();
		};
		
		if (window.hasFocus()) //Si la aplicacion esta seleccionada
		{
			window.clear();

			switch (Screen)
			{
				case 1: //Menu principal

					//Si la musica no se esta reproduciendo...
					if (BgMainMusic.getStatus() != 2) 
						BgMainMusic.play();

					window.draw(BGIMG); //Dibujar fondo
					window.draw(Jugar.getSprite()); //Dibujar boton de jugar
					window.draw(Salir.getSprite()); //Dibujar boton de salir

					//Cambiar seleccion de boton
					if (!(Keyboard::isKeyPressed(Keyboard::S) || Keyboard::isKeyPressed(Keyboard::Down)) && (Keyboard::isKeyPressed(Keyboard::W) || Keyboard::isKeyPressed(Keyboard::Up)) && Selected > 0 && !KeyPressed)
					{
						Selected--;
						KeyPressed = true;
					}
					else if ((Keyboard::isKeyPressed(Keyboard::S) || Keyboard::isKeyPressed(Keyboard::Down)) && !(Keyboard::isKeyPressed(Keyboard::W) || Keyboard::isKeyPressed(Keyboard::Up)) && Selected < 1 && !KeyPressed)
					{
						Selected++;
						KeyPressed = true;
					}
					else
					{
						KeyPressed = false;
					};

					if (Selected == 0)
					{
						Jugar.SetON();
						Salir.SetOFF();
					}
					else if (Selected == 1)
					{
						Jugar.SetOFF();
						Salir.SetON();
					};

					if (Keyboard::isKeyPressed(Keyboard::Return) || Keyboard::isKeyPressed(Keyboard::Space))
					{
						if (Selected == 0)
						{
							Screen = 2;
							BgMainMusic.stop();
						}
						else if (Selected == 1)
						{
							window.close();
						};
					};
					break;

				case 2: //Niveles

					//Ajustar camara al jugador
					CamaraPosicion.x = yo.getPosition().x - CamaraMedidas.x / 2;
					CamaraPosicion.y = yo.getPosition().y - CamaraMedidas.y / 2;
					Camara.reset(FloatRect(CamaraPosicion.x, CamaraPosicion.y, CamaraMedidas.x, CamaraMedidas.y));
					//Si la musica no se esta reproduciendo...
					if (LevelMusic.getStatus() != 2)
						LevelMusic.play();

					switch (nivel)
					{
						case 0: //Nivel jugable
							window.setView(Camara);

							for (int i = 0; i < contenedorDeSuelo.size(); i++) //Dibujar escenario
							{
								Tile1.positionOnMap(&contenedorDeSuelo[i]);
								window.draw(Tile1.getSprite());
							};

							//Dibujar la meta
							Meta.setPosition(coordenadasParaGanar.x * 34, coordenadasParaGanar.y * 34);
							window.draw(Meta);

							for (int i = 0; i < contenedorDeCajas.size(); i++) //Dibujar cajas
							{
								box.positionOnMap(&contenedorDeCajas[i]);
								window.draw(box.getSprite());
							};

							if (!yo.getMovingState()) //Si no te estas moviendo...
							{
								yo.checkMove(); //Revisar que accion quieres hacer

								for (int i = 0; i < contenedorDeSuelo.size(); i++) //Comprobar si hay suelo a 1 de ti
								{
									if (yo.IsPossible(&contenedorDeSuelo[i], 1)) //Hay un suelo a 1 de ti
									{
										yo.changeFloorTest(true);
										break;
									}
									else
										yo.changeFloorTest(false);
								};

								for (int i = 0; i < contenedorDeSuelo.size(); i++) //Comprobar si hay suelo a 2 de ti
								{
									if (yo.IsPossible(&contenedorDeSuelo[i], 2)) //Hay un suelo a 2 de ti
									{
										yo.changeSecondFloorTest(true);
										break;
									}
									else
										yo.changeSecondFloorTest(false);
								};

								for (int i = 0; i < contenedorDeCajas.size(); i++) //Comprobar si hay caja a 1 de ti
								{
									if (yo.IsPossible(&contenedorDeCajas[i], 1)) //Hay una caja a 1 de ti
									{
										yo.changeBlockTest(true);
										break;
									}
									else
										yo.changeBlockTest(false);
								};

								for (int i = 0; i < contenedorDeCajas.size(); i++) //Comprobar si hay una caja a 2 de ti
								{
									if (yo.IsPossible(&contenedorDeCajas[i], 2)) //Hay caja a 2 de ti
									{
										yo.changeSecondBlockTest(true);
										break;
									}
									else
										yo.changeSecondBlockTest(false);
								};

								if (yo.getIfHoldingBox()) //Seleccionar caja
								{
									for (int i = 0; i < contenedorDeCajas.size(); i++)
									{
										if (yo.getWatchingTo() == 'W' && yo.getPosition().x == contenedorDeCajas[i].x * 34 && yo.getPosition().y - 34 == contenedorDeCajas[i].y * 34)
											yo.setBoxID(i);
										else if (yo.getWatchingTo() == 'S' && yo.getPosition().x == contenedorDeCajas[i].x * 34 && yo.getPosition().y + 34 == contenedorDeCajas[i].y * 34)
											yo.setBoxID(i);
										else if (yo.getWatchingTo() == 'A' && yo.getPosition().x - 34 == contenedorDeCajas[i].x * 34 && yo.getPosition().y == contenedorDeCajas[i].y * 34)
											yo.setBoxID(i);
										else if (yo.getWatchingTo() == 'D' && yo.getPosition().x + 34 == contenedorDeCajas[i].x * 34 && yo.getPosition().y == contenedorDeCajas[i].y * 34)
											yo.setBoxID(i);
									};
								};

								//Comprobar si te puedes mover o no
								if (yo.getFloorTest() && !yo.getBlockTest() || yo.getFloorTest() && yo.getSecondFloorTest() && yo.getBlockTest() && !yo.getSecondBlockTest() && yo.getIfHoldingBox())
									//Si hay suelo y no hay caja, o si hay suelo a 1 y 2 de ti y hay caja a l de ti y la empujas y no hay caja a 2 de ti
									yo.setGoalByKey();

								//Si la caja esta cerca
								if (yo.getPosition().x - 34 <= contenedorDeCajas[yo.getBoxID()].x * 34 && yo.getPosition().x + 34 >= contenedorDeCajas[yo.getBoxID()].x * 34 && yo.getPosition().y - 34 <= contenedorDeCajas[yo.getBoxID()].y * 34 && yo.getPosition().y + 34 >= contenedorDeCajas[yo.getBoxID()].y * 34)
									yo.setIfBoxNear(true); //Puedes empujarla/jalarla
								else
									yo.setIfBoxNear(false); //No puedes empujarla/jalarla
							};

							//Si tienes el movimiento activado, moverte
							if (yo.getMovingState())
							{
								yo.movimiento(yo.getNextMove());

								if (yo.getIfHoldingBox() && yo.getIfBoxNear()) //Si estas jalando caja y esta cerca
								{
									if (yo.getNextMove() == 'W' && contenedorDeCajas[yo.getBoxID()].x == yo.getPosition().x / 34)
									{
										if (yo.getPosition().y / 34 > contenedorDeCajas[yo.getBoxID()].y) //Si la caja esta arriba de ti
										{
											yo.Animar('W', true, 0);
											contenedorDeCajas[yo.getBoxID()].y = (yo.getPosition().y - 34) / 34;
											if (BoxFx.getStatus() != 2)
												BoxFx.play();
										}
										else
										{
											yo.Animar('S', true, 180);
											contenedorDeCajas[yo.getBoxID()].y = (yo.getPosition().y + 34) / 34;
											if (BoxFx.getStatus() != 2)
												BoxFx.play();
										}
									}
									else if (yo.getNextMove() == 'S' && contenedorDeCajas[yo.getBoxID()].x == yo.getPosition().x / 34)
									{
										if (yo.getPosition().y / 34 > contenedorDeCajas[yo.getBoxID()].y)
										{
											yo.Animar('W', true, 0);
											contenedorDeCajas[yo.getBoxID()].y = (yo.getPosition().y - 34) / 34;
											if (BoxFx.getStatus() != 2)
												BoxFx.play();
										}
										else
										{
											yo.Animar('S', true, 180);
											contenedorDeCajas[yo.getBoxID()].y = (yo.getPosition().y + 34) / 34;
											if (BoxFx.getStatus() != 2)
												BoxFx.play();
										}
									}
									else if (yo.getNextMove() == 'A' && contenedorDeCajas[yo.getBoxID()].y == yo.getPosition().y / 34)
									{
										if (yo.getPosition().x / 34 > contenedorDeCajas[yo.getBoxID()].x)
										{
											yo.Animar('A', true, 270);
											contenedorDeCajas[yo.getBoxID()].x = (yo.getPosition().x - 34) / 34;
											if (BoxFx.getStatus() != 2)
												BoxFx.play();
										}
										else
										{
											yo.Animar('D', true, 90);
											contenedorDeCajas[yo.getBoxID()].x = (yo.getPosition().x + 34) / 34;
											if (BoxFx.getStatus() != 2)
												BoxFx.play();
										}
									}
									else if (yo.getNextMove() == 'D' && contenedorDeCajas[yo.getBoxID()].y == yo.getPosition().y / 34)
									{
										if (yo.getPosition().x / 34 < contenedorDeCajas[yo.getBoxID()].x)
										{
											yo.Animar('D', true, 90);
											contenedorDeCajas[yo.getBoxID()].x = (yo.getPosition().x + 34) / 34;
											if (BoxFx.getStatus() != 2)
												BoxFx.play();
										}
										else
										{
											yo.Animar('A', true, 270);
											contenedorDeCajas[yo.getBoxID()].x = (yo.getPosition().x - 34) / 34;
											if (BoxFx.getStatus() != 2)
												BoxFx.play();
										}
									}
									else
										yo.Animar(yo.getNextMove(), false, 0);
								}
								else
									yo.Animar(yo.getNextMove(), false, 0);
							};

							window.draw(yo.getCharSprite()); //Dibujar personaje

							//Texto
							window.draw(scoreLabel);
							scoreLabel.setPosition(yo.getPosition().x - CamaraMedidas.x / 2, yo.getPosition().y + CamaraMedidas.y / 2 - scoreLabel.getCharacterSize());
							scoreLabel.setString("Level: " + to_string(nivelMaximoAlcanzado));

							if(yo.getPosition().x == coordenadasParaGanar.x*34 && yo.getPosition().y == coordenadasParaGanar.y*34)
							{
								nivelMaximoAlcanzado++;
								nivel = nivelMaximoAlcanzado;
								//Vaciar los vectores
								contenedorDeCajas.clear();
								contenedorDeSuelo.clear();
								//Cambiar la caja seleccionada
								yo.setBoxID(0);
							}

							break;

						case 1: //Cargar nivel 1
							//Posicion del jugador
							yo.setPosition(5, 1);
							//Asignar cosas
							contenedorDeCajas.push_back(Vector2f(0, 1));
							contenedorDeSuelo.push_back(Vector2f(0, 1));
							contenedorDeSuelo.push_back(Vector2f(1, 1));
							contenedorDeSuelo.push_back(Vector2f(2, 1));
							contenedorDeSuelo.push_back(Vector2f(3, 1));
							contenedorDeSuelo.push_back(Vector2f(4, 1));
							contenedorDeSuelo.push_back(Vector2f(5, 1));
							//Meta
							coordenadasParaGanar.x = 1;
							coordenadasParaGanar.y = 1;
							//ir al jugable
							nivel = 0;
							break;
						case 2: //Cargar nivel 2
							//Posicion del jugador
							yo.setPosition(4, 2);
							//Asignar cosas
							contenedorDeCajas.push_back(Vector2f(2, 2));
							contenedorDeSuelo.push_back(Vector2f(2, 1));
							contenedorDeSuelo.push_back(Vector2f(3, 1));
							contenedorDeSuelo.push_back(Vector2f(1, 2));
							contenedorDeSuelo.push_back(Vector2f(2, 2));
							contenedorDeSuelo.push_back(Vector2f(3, 2));
							contenedorDeSuelo.push_back(Vector2f(4, 2));
							contenedorDeSuelo.push_back(Vector2f(2, 3));
							//Meta
							coordenadasParaGanar.x = 1;
							coordenadasParaGanar.y = 2;
							//ir al jugable
							nivel = 0;
							break;
						case 3: //Cargar nivel 3
							//Posicion del jugador
							yo.setPosition(3, 3);
							//Asignar cosas
							contenedorDeCajas.push_back(Vector2f(1, 3));
							contenedorDeSuelo.push_back(Vector2f(1, 1));
							contenedorDeSuelo.push_back(Vector2f(2, 1));
							contenedorDeSuelo.push_back(Vector2f(3, 1));
							contenedorDeSuelo.push_back(Vector2f(1, 2));
							contenedorDeSuelo.push_back(Vector2f(3, 2));
							contenedorDeSuelo.push_back(Vector2f(1, 3));
							contenedorDeSuelo.push_back(Vector2f(2, 3));
							contenedorDeSuelo.push_back(Vector2f(3, 3));
							contenedorDeSuelo.push_back(Vector2f(1, 4));
							//Meta
							coordenadasParaGanar.x = 1;
							coordenadasParaGanar.y = 4;
							//ir al jugable
							nivel = 0;
							break;
						case 4: //Cargar nivel 4
							//Posicion del jugador
							yo.setPosition(10, 13);
							//Asignar cosas
							contenedorDeCajas.push_back(Vector2f(8, 13));
							contenedorDeCajas.push_back(Vector2f(10, 9));
							contenedorDeCajas.push_back(Vector2f(8, 7));
							contenedorDeCajas.push_back(Vector2f(8, 4));
							contenedorDeCajas.push_back(Vector2f(11, 2));
							contenedorDeCajas.push_back(Vector2f(2, 7));
							contenedorDeCajas.push_back(Vector2f(4, 2));
							//fila 1
							contenedorDeSuelo.push_back(Vector2f(4, 1));
							contenedorDeSuelo.push_back(Vector2f(7, 1));
							contenedorDeSuelo.push_back(Vector2f(8, 1));
							contenedorDeSuelo.push_back(Vector2f(9, 1));
							contenedorDeSuelo.push_back(Vector2f(11, 1));
							//fila 2
							contenedorDeSuelo.push_back(Vector2f(4, 2));
							contenedorDeSuelo.push_back(Vector2f(6, 2));
							contenedorDeSuelo.push_back(Vector2f(7, 2));
							contenedorDeSuelo.push_back(Vector2f(9, 2));
							contenedorDeSuelo.push_back(Vector2f(10, 2));
							contenedorDeSuelo.push_back(Vector2f(11, 2));
							//fila 3
							contenedorDeSuelo.push_back(Vector2f(1, 3));
							contenedorDeSuelo.push_back(Vector2f(2, 3));
							contenedorDeSuelo.push_back(Vector2f(3, 3));
							contenedorDeSuelo.push_back(Vector2f(4, 3));
							contenedorDeSuelo.push_back(Vector2f(6, 3));
							contenedorDeSuelo.push_back(Vector2f(8, 3));
							contenedorDeSuelo.push_back(Vector2f(11, 3));
							//fila 4
							contenedorDeSuelo.push_back(Vector2f(1, 4));
							contenedorDeSuelo.push_back(Vector2f(4, 4));
							contenedorDeSuelo.push_back(Vector2f(5, 4));
							contenedorDeSuelo.push_back(Vector2f(6, 4));
//							contenedorDeSuelo.push_back(Vector2f(7, 4));
							contenedorDeSuelo.push_back(Vector2f(8, 4));
							contenedorDeSuelo.push_back(Vector2f(9, 4));
							contenedorDeSuelo.push_back(Vector2f(10, 4));
							contenedorDeSuelo.push_back(Vector2f(11, 4));
							//fila 5
							contenedorDeSuelo.push_back(Vector2f(1, 5));
							contenedorDeSuelo.push_back(Vector2f(4, 5));
							contenedorDeSuelo.push_back(Vector2f(8, 5));
							//fila 6
							contenedorDeSuelo.push_back(Vector2f(1, 6));
							contenedorDeSuelo.push_back(Vector2f(3, 6));
							contenedorDeSuelo.push_back(Vector2f(4, 6));
							contenedorDeSuelo.push_back(Vector2f(8, 6));
							//fila 7
							contenedorDeSuelo.push_back(Vector2f(1, 7));
							contenedorDeSuelo.push_back(Vector2f(2, 7));
							contenedorDeSuelo.push_back(Vector2f(3, 7));
							contenedorDeSuelo.push_back(Vector2f(4, 7));
							contenedorDeSuelo.push_back(Vector2f(8, 7));
							contenedorDeSuelo.push_back(Vector2f(9, 7));
							contenedorDeSuelo.push_back(Vector2f(10, 7));
							//fila 8
							contenedorDeSuelo.push_back(Vector2f(3, 8));
							contenedorDeSuelo.push_back(Vector2f(8, 8));
							contenedorDeSuelo.push_back(Vector2f(10, 8));
							//fila 9
							contenedorDeSuelo.push_back(Vector2f(8, 9));
							contenedorDeSuelo.push_back(Vector2f(9, 9));
							contenedorDeSuelo.push_back(Vector2f(10, 9));
							contenedorDeSuelo.push_back(Vector2f(11, 9));
							//fila 10
							contenedorDeSuelo.push_back(Vector2f(9, 10));
							//fila 11
							contenedorDeSuelo.push_back(Vector2f(8, 11));
							contenedorDeSuelo.push_back(Vector2f(9, 11));
							contenedorDeSuelo.push_back(Vector2f(10, 11));
							//fila 12
							contenedorDeSuelo.push_back(Vector2f(8, 12));
							//fila 13
							contenedorDeSuelo.push_back(Vector2f(7, 13));
							contenedorDeSuelo.push_back(Vector2f(8, 13));
							contenedorDeSuelo.push_back(Vector2f(9, 13));
							contenedorDeSuelo.push_back(Vector2f(10, 13));
							//Meta
							coordenadasParaGanar.x = 4;
							coordenadasParaGanar.y = 1;
							//ir al jugable
							nivel = 0;
							break;

						default:
							LevelMusic.stop();
							nivel = 1;
							nivelMaximoAlcanzado = 1;
							window.setView(window.getDefaultView());
							Screen = 1;
							break;
					};
					break;
				default:
					Screen = 1;
					break;
			};

			window.display();
		};
	};
};
Пример #18
0
int main(int argc, char *argv[])
{
    SDL_Surface *ecran = NULL;                      //surface affichée à l'ecran
    SDL_Event event;                                //stock l'evenement

    Case plateau[TAILLE_PLATEAU][TAILLE_PLATEAU];   //le plateau
    Case precedent[TAILLE_PLATEAU][TAILLE_PLATEAU]; //le plateau precedent (pour annuler)

    Joueur joueur;                                  //à qui le tour ?

    bool continuer = true;                          //booléen pour rester dans la boucle
    bool fin = false;                               //booléen declenchant la fin du programme
    bool appuiAbandon = false, appuiAnnuler = false;//les boutons
    bool peutAnnuler;                               //si on peut appuyer sur annuler
    bool selection;                                 //une case est-elle selectionnée
    int cliqueeX = 0, cliqueeY = 0;                 //si oui : quelles sont ces coordonnées ?
    char cause[10];                                 //chaine pour la fin...

    // Démarrage de la SDL, et de la bibliotheque de police.
    SDL_Init(SDL_INIT_VIDEO);
    TTF_Init();

    //Ouverture de la fenetre
    #ifdef FULLSCREEN
        ecran = SDL_SetVideoMode(ECRAN_X, ECRAN_Y, NB_COULEURS, SDL_HWSURFACE|SDL_FULLSCREEN);
    #else
        ecran = SDL_SetVideoMode(ECRAN_X, ECRAN_Y, NB_COULEURS, SDL_HWSURFACE);
    #endif

    // On change le titre
    SDL_WM_SetCaption(TITRE_FENETRE, NULL);

    do
    {
        //initialisation des variables
        selection = false; // aucune case ne doit etre cliquee (securite)
        joueur = blanc; // les blancs commencent toujours

        //On initialise le plateau
        reinitialiser(plateau);
        peutAnnuler = false;

        do
        {
            //Affichage
            afficher(plateau, joueur, ecran, selection, cliqueeX, cliqueeY, appuiAbandon, appuiAnnuler);

            //Entree
            SDL_WaitEvent(&event);

            //Gestion (selon le type de l'evenement)

            //appui sur la croix (fenetre)
            if(event.type == SDL_QUIT)
                fin = true; //on s'en va...

            //appui sur une touche
            else if(event.type == SDL_KEYDOWN)
            {
                //la touche etant Echap
                if(event.key.keysym.sym == SDLK_ESCAPE)
                    fin = true; //on s'en va...
            }

            //bouton de la souris relaché
            else if(event.type == SDL_MOUSEBUTTONUP)
            {
                //c'etait un clic gauche
                if(event.button.button == SDL_BUTTON_LEFT)
                {
                    //on avais cliqué sur annuler
                    if(appuiAnnuler)
                    {
                        //si on peut annuler
                        if(peutAnnuler)
                        {
                            //on ne le peut plus
                            peutAnnuler = false;
                            //le plateau actuel est le plateau d'avant
                            egalPlateau(plateau, precedent);
                            //on redonne la main au joueur precedent
                            joueur = (joueur == noir) ? blanc : noir;
                            //aucune case cliquee
                            selection = false;
                        }

                        //bouton annuler : relaché
                        appuiAnnuler = false;
                    }

                    //on avais cliqué sur abandon
                    else if(appuiAbandon)
                    {
                        //c'est l'autre joueur qui gagne
                        joueur = (joueur == blanc) ? noir : blanc;
                        //bouton abandon : relaché
                        appuiAbandon = false;
                        //fin de la partie
                        continuer = false;
                        //la cause etant l'abandon
                        sprintf(cause, "abandon");
                    }
                }
            }

            //appui sur un bouton de la souris
            else if(event.type == SDL_MOUSEBUTTONDOWN)
            {
                //clic gauche
                if(event.button.button == SDL_BUTTON_LEFT)
                {
                    //on appuie sur le bouton annuler
                    if(event.button.x > BOUTON_ANNULER_X && event.button.x < BOUTON_ANNULER_X+TAILLE_BOUTON_X && event.button.y > BOUTON_ANNULER_Y && event.button.y < BOUTON_ANNULER_Y+TAILLE_BOUTON_Y)
                        appuiAnnuler = true;

                    //on appuie sur le bouton abandon
                    else if(event.button.x > BOUTON_ABANDON_X && event.button.x < BOUTON_ABANDON_X+TAILLE_BOUTON_X && event.button.y > BOUTON_ABANDON_Y && event.button.y < BOUTON_ABANDON_Y+TAILLE_BOUTON_Y)
                        appuiAbandon = true;

                    //on clique dans la zone de jeu
                    else if(event.button.x > ZDJ_X && event.button.x < ZDJ_X+ZDJ && event.button.y > ZDJ_Y && event.button.y < ZDJ_Y+ZDJ)
                    {
                        //si on avais dejà selectionné quelque chose
                        if(selection)
                        {
                            //si le deplacement est autorise
                            if(possible(plateau, cliqueeX, cliqueeY, ((event.button.x-ZDJ_X)/TAILLE_CASES), ((event.button.y-ZDJ_Y)/TAILLE_CASES)))
                            {
                                //(se deplacer), et si quelque chose a été mangé
                                if(manger(plateau, cliqueeX, cliqueeY, ((event.button.x-ZDJ_X)/TAILLE_CASES), ((event.button.y-ZDJ_Y)/TAILLE_CASES)))
                                {
                                    //le pion est toujours selectionnable, mais à son nouvel
                                    //emplacement
                                    cliqueeX = ((event.button.x-ZDJ_X)/TAILLE_CASES);
                                    cliqueeY = ((event.button.y-ZDJ_Y)/TAILLE_CASES);

                                    //a t-on gagne par victoire totale ?
                                    //si oui, on sort de la partie
                                    continuer = !gagner(plateau, joueur);

                                    if(!continuer)
                                         sprintf(cause, "victoire totale");

                                    //sinon, si on ne peut plus manger --> au joueur suivant !
                                    else if(!peutManger(plateau, cliqueeX, cliqueeY))
                                    {
                                        //on deselectionne le pion
                                        selection = false;
                                        //on change de joueur
                                        joueur = (joueur == blanc) ? noir : blanc;
                                        //on peut revenir en arriere
                                        peutAnnuler = true;

                                        //sommes-nous bloqué ?
                                        continuer = !bloque(plateau, joueur);
                                        if(!continuer)
                                        {
                                            sprintf(cause, "blocage");

                                            //si oui, c'est l'autre joueur,
                                            //celui qui vient de jouer, qui gagne !
                                            joueur = (joueur == blanc) ? noir : blanc;
                                        }

                                    }
                                }

                                //rien a été mangé : au joueur suivant !
                                else
                                {
                                    //on deselectionne le pion
                                    selection = false;
                                    //on change de joueur
                                    joueur = (joueur == blanc) ? noir : blanc;
                                    //on peut revenir en arriere
                                    peutAnnuler = true;
                                }
                            }
                        }

                        //sinon, si on clique sur un pion
                        else if(plateau[(event.button.x-ZDJ_X)/TAILLE_CASES][(event.button.y-ZDJ_Y)/TAILLE_CASES].pion != non)
                        {
                            //coordonnees du pion en question
                            cliqueeY = (event.button.y-ZDJ_Y)/TAILLE_CASES;
                            cliqueeX = (event.button.x-ZDJ_X)/TAILLE_CASES;

                            //si on peut selectionner ce pion
                            if(plateau[cliqueeX][cliqueeY].joueur == joueur && selectionnable(plateau, cliqueeX, cliqueeY))
                            {
                                //le prochain plateau precedent est le plateau actuel
                                egalPlateau(precedent, plateau);
                                //le pion est selectionné
                                selection = true;
                                //on ne peut plus annuler (il faudra d'abord cliquer sur une case)
                                peutAnnuler = false;
                            }
                        }
                    }
                }
            }
        //Gestion terminée

        //repeter ceci tant que la partie nest pas terminée, et que l'on ne veut pas s'en aller
        }while (continuer && !fin);

        //securité...
        appuiAbandon = false;
        appuiAnnuler = false;

        //considerons ici abandon <-> quitter et annuler <-> recommencer

        //tant que l'on a pas choisi...
        while(!continuer && !fin)
        {
            //on affiche le message de fin
            affichageFin(plateau, ecran, appuiAnnuler, appuiAbandon, joueur, cause);

            //si il y a un evenement
            SDL_WaitEvent(&event);

            //de type : "boutton de sourie relaché"
            if(event.type == SDL_MOUSEBUTTONUP)
            {
                //si le bouton en question est le gauche
                if(event.button.button == SDL_BUTTON_LEFT)
                {
                    //si on avais appuyé sur recommencer
                    if(appuiAnnuler)
                    {
                        //on relache le bouton
                        appuiAnnuler = false;
                        //on recommence une partie
                        continuer = true;
                    }
                    //sinon si on avais appuyé sur arreter
                    else if(appuiAbandon)
                    {
                        //on relache le bouton
                        appuiAbandon = false;
                        //on s'en va
                        fin = true;
                    }
                }
            }

            //de type : "appui sur une bouton de la souris"
            else if(event.type == SDL_MOUSEBUTTONDOWN)
            {
                //clic gauche
                if(event.button.button == SDL_BUTTON_LEFT)
                {
                    //sur le bouton "oui" (recommencer (annuler))
                    if(event.button.x > FIN_BOUTON_OUI_X && event.button.x < FIN_BOUTON_OUI_X+TAILLE_BOUTON_X && event.button.y > FIN_BOUTON_OUI_Y && event.button.y < FIN_BOUTON_OUI_Y+TAILLE_BOUTON_Y)
                        appuiAnnuler = true;

                    //sur le bouton "non" (arreter (abandon))
                    else if(event.button.x > FIN_BOUTON_NON_X && event.button.x < FIN_BOUTON_NON_X+TAILLE_BOUTON_X && event.button.y > FIN_BOUTON_NON_Y && event.button.y < FIN_BOUTON_NON_Y+TAILLE_BOUTON_Y)
                        appuiAbandon = true;
                }
            }

            //de type : "appui sur la croix de la fenetre"
            else if(event.type == SDL_QUIT)
                fin = true;

            //de type : "appui sur une touche"
            else if(event.type == SDL_KEYDOWN)
            {
                //la touche Echap
                if(event.key.keysym.sym == SDLK_ESCAPE)
                    fin = true;
            }
        }

    //tant que l'on ne veut pas s'en aller
    }while(!fin);

    //arret de la SDL et de la biblio des polices
    TTF_Quit();
    SDL_Quit();

    //tout s'est bien passé
    return EXIT_SUCCESS;
}
Пример #19
0
void VbExporter::paracada(t_output &prog, t_proceso_it r, t_proceso_it q, string tabs){
	string var=ToLower((*r).par2), aux=ToLower((*r).par1);
	insertar(prog,tabs+"For Each "+aux+" In "+var);
	bloque(prog,++r,q,tabs+"\t");
	insertar(prog,tabs+"Next");
}
Пример #20
0
void MatLabExporter::mientras(t_output &prog, t_proceso_it r, t_proceso_it q, string tabs){
	insertar(prog,tabs+"while "+expresion((*r).par1));
	bloque(prog,++r,q,tabs+"\t");
	insertar(prog,tabs+"end");
}