//=======================================================
//= Fenix Street Fighter II Pong Edition                =                                                     =
//= Clon del Pong con luchadores del Street Fighter     =
//= Mi primer  juego! ^_^                               =
//=                                                     =
//= Por Hokutoy 2004                                    =
//= Visita la web de Fénix: http://fenix.divsite.net    =
//= Portado a GP32 por Chui.                            =
//=======================================================  
                      
Program SFP;   
Global  //Declara variables globales  
 Int ball_X=200;    //Se refiere a la cordenada X de la BOLA
 Int velo_ball=6;   //Se refiere a la velocidad (incremento de velo_ball) de la BOLA; 
 Int p1;    //Se refiere al proceso Ken 
 Int p2;    //Se refiere al proceso Ryu
 Int h1;    //Se refiere al proceso Hadoken de Ken
 Int h2;    //Se refiere al proceso Hadoken de Ryu
 Int b;  //Se refiere al proceso Ball (de IZQ a DERECH) 
 Int b2; //Se refiere al proceso Ball2 (de DERECH a IZQ)
 Int m_ken;    //Se refiere a la Musica de fondo  
 Int m_ryu;    //Se refiere a la Musica de fondo
 Int m_intro;  //Se refiere a la Musica de la intro 
 Int canal;
 Int Hadoken;   //Se refiere al SFX Hadoken de Ken
 Int Hadoken2;     //Se refiere al SFX Hadoken de Ryu    
 Int damage;    //Se refiere al SFX punch 
 Int levelup;   //Se refiere al SFX Levelup 
 Int Fight;     //Se refiere al SFX Raspa
 Int Raspa;    //Se refiere al SFX Fight
 Int win;       //Se refiere al SFX Win 
 Int sfx_Round1; //Se refiere al SFX R1 
 Int sfx_Round2; //Se refiere al SFX R2 
 Int sfx_Roundf; //Se refiere al SFX FR 
 Int sfx_option;
 Int sfx_kwin;
 Int sfx_Rwin;
 Int dmg;   //Se refiere al proceso de la animacion de daño de KEN
 Int dmg2;  //Se refiere al proceso de animacion de daño de RYU 
 Int v1;    //Se refiere al numero de vidas del player 1 
 Int m1;    //Se refiere al proceso de poner las vidas en el marcador del player 1
 Int v2;    //Se refiere al numero de vidas del player 2 
 Int m2;    //Se refiere al proceso de poner las vidas en el marcador del player 2
 Int startball;  
 Int luck;  //Determina, al azar, hacia que lado sale la bola inicialmente 
 Int rebote;    //Lleva la cuenta de rebotes bien hechos
 Int gfxball;   //Determina que tipo de graficos lleva la bola 
 Int Id_round;  //Se refiere al processo que determina el ROUND  
 Int Cont_round; 
 Int kwin; 
 Int Rwin;
 Int Level=33;
 Int Who_wins; 
 Int total_blue=0;blue=0;U_blue=0; D_blue=0; C_blue=0; T_C_blue=0; T_D_blue=0; T_U_blue=0;
 Int total_red=0;red=0;U_red=0; D_red=0; C_red=0; T_C_red=0; T_D_red=0; T_U_red=0; 
 Int total_giant=0;giant=0;U_giant=0; D_giant=0; C_giant=0; T_C_giant=0; T_D_giant=0; T_U_giant=0;
 Int total_hado=0; match_hado=0; total_match_combo=0; match_combo=0;   
 Int wins_ken=0; wins_ryu=0;
 Int musica; 
 Int unidades_wins_ryu=0; decenas_wins_ryu=0;
 Int unidades_wins_ken=0; decenas_wins_ken=0;
 Int Unidades_match_combo=0;decenas_match_combo=0;centenas_match_combo=0;
 Int U_M_C; D_M_C; C_M_C; 
 Int U_T_C; D_T_C; C_T_C; 
 Int U_M_H; D_M_H; C_M_H; 
 Int U_T_H; D_T_H; C_T_H;
 
		    

 
                       

 

Begin
	//Inicia modo gráfico a 320X240 y modo 8bits de color (256 colores)
	set_mode(m320x240);
	Graph_mode=mode_8bits; 
	
	//Un poco de musiquita y SFX;)
	 m_ken=load_song("ken.0it");                
	 m_ryu=load_song("ryu.0it");
	 hadoken=load_wav("hadoken.wav");
	 hadoken2=load_wav("hado.wav");
	 damage=load_wav("damage.wav");   
	 levelup=load_wav("levelup.wav"); 
	 fight=load_wav("fight.wav");
	 raspa=load_wav("raspa.wav");
	 sfx_kwin=load_wav("kw.wav"); 
	 sfx_rwin=load_wav("rw.wav");
	 sfx_round1=load_wav("round1.wav");
	 sfx_round2=load_wav("round2.wav");
	 sfx_roundf=load_wav("roundf.wav"); 
	 m_intro=load_song("nana.wav");
	 Sfx_option=load_wav("option.wav");
	
	 
	  
	  


	//Carga el fichero de gráficos
	load_fpg("ken.fpg");
	load_fpg("numeros.fpg");
	  
	
	// Inicializacion de alguna variantes (vidas y breaker de partida)  
	v1=6;   //P1 empieza con 6 vidas 
	V2=6;   //P2 empieza con 6 vidas
	startball=0;
	gfxball=21; //Para la ball normal
	rebote=0; 
	ball_X=160;
                                     
    //Crea el proceso ken - ryu - marcador_player_1 - marcador_player_2
    
	p1=ken();  
	p2=ryu(); 
	m1=marcadorp1();
	m2=marcadorp2();
	Intro();
	

	            
		
	
	
	//Embucla el proceso ppal. hasta pulsar tab (en ordenador) o botón L en GP32
	Loop  
	  
		//El frame hace que se recalcule todo, si no se pone se quedará como "colgado"
		Frame;
		If(key(_esc)); Break; 
		End  
		
		If(startball==0) 
		    signal(b,s_kill); 
		    signal(b2,s_kill);
		    Id_round=round();
		End
	
		If((rebote==12) AND (cont_round!=3)) gfxball=23;velo_ball=12;
		End  
		
		If((rebote==19) AND (cont_round!=3)) gfxball=25; velo_ball=2;
		End                                                      
		
		//If(cont_round==3) gfxball=25;velo_ball=1; 
		//End   
		
		
	End

	//Elimina TODOS los procesos que pudieran existir quedándose él solo
	let_me_alone();
End       
                               
                   
//===========================================================
//= Proceso intro                                           =
//= Controla el inicio-final de la partida y sirve de reset =
//===========================================================

Process intro() 
Private id_size=1; zoom=0; rot=0; id_angle=0;
Begin 
If(level==33) musica=m_ryu; Else musica=m_ken; End
canal=play_song(m_intro,0);  

 

// A Dormir todo dios... lol
signal(p1, s_sleep);            
signal(p2, s_sleep);  
signal(m1, s_sleep);           
signal(m2, s_sleep); 
startball=1;
cont_round=1;
clear_screen(); 
      

For(zoom=0;zoom<100;zoom++) 
    x=160; y=120;
    size=Id_size;
    graph=17;   // Pone la foto de la intro;  
    Frame; 
    Id_size++; 
    End    
For(zoom=0;zoom<100;zoom++) 
    x=160; y=120;
    size=Id_size;
    graph=17;   // Pone la foto de la intro;  
    Frame; 
    Id_size--; 
    End       
         
    Frame(4000); 
For(rot=0;rot<145;rot++)
    size=Id_size; 
    angle=id_angle; 
    graph=17;
    Frame(30);
    id_angle-=10000; //********** IMPORTANTE: Poner a 90000 para que funcione en el PC!
    If(size<100) Id_size+=1; End;                     
    End
                                       


    Loop  
    Frame(100);
    If(key(_enter)) play_wav(sfx_option,0); Frame(2000);Id_round=cont_round=1; stop_song(); play_song(musica,-1); startball=0; put_screen(0,level); signal(p1, s_wakeup);  signal(p2, s_wakeup);  signal(m1, s_wakeup);  signal(m2, s_wakeup); v1=6; V2=6; gfxball=21; kwin=0; rwin=0;match_combo=0;blue=0;U_blue=0; D_blue=0; C_blue=0;red=0;U_red=0; D_red=0; C_red=0;giant=0;U_giant=0; D_giant=0; C_giant=0;U_M_H=0; D_M_H=0; C_M_H=0;Break; End  
    End
End   
           
           
//===========================================================
//= Proceso Round                                           =
//= Controla el numero de round                             =
//===========================================================

Process round() 
Begin
Startball=1;


  
If(cont_round==1) Frame(2000);
    x=160;y=120; graph=39;
    play_wav(sfx_round1,0);Frame(4000);
    x=160;y=120; graph=18;play_wav(fight,0); Frame(2000);
    luck=rand(0,1); 
        If(luck==0); 
        ball_X=160 ;
        velo_ball=2;b=ball(); 
            Else 
        ball_X=160 ;
        velo_ball=2;
        b2=ball2();  
        End
End 
If(cont_round==2) Frame(2000);
    x=160;y=120; graph=40;
    play_wav(sfx_round2,0);Frame(4000);
    x=160;y=120; graph=18;play_wav(fight,0); Frame(2000);
    luck=rand(0,1); 
        If(luck==0); 
        ball_X=160 ;
        velo_ball=2;b=ball(); 
            Else 
        ball_X=160 ;
        velo_ball=2;
        b2=ball2();  
        End
End 

If(cont_round==3) Frame(2000);
    x=160;y=120; graph=41;
    play_wav(sfx_roundF,0);Frame(4000);
    x=160;y=120; graph=18;play_wav(fight,0); Frame(3000);
    luck=rand(0,1); 
        If(luck==0); 
        ball_X=160 ;
        velo_ball=2;b=ball(); 
            Else 
        ball_X=160 ;
        velo_ball=2;
        b2=ball2();  
        End
End 


End         
                             
//=======================================================
//= Proceso ken()                                       =
//= Llama al proceso Hadop1 para realicar el movimiento =
//=======================================================

Process ken()  
Private
    coli;
Begin
	//Le asignamos el gráfico deseado al proceso
	
	graph=5;
	
	
    
	//Le damos valor a sus coordenadas iniciales
	x=40; y=175; 
	

	Loop
		Frame 250;

		//Detectamos las pulsaciones de las teclas/stick de GP32 
		If(key(_left) OR key(_right) OR key(_backspace) OR key(_enter))  play_wav(hadoken,0);h1=hadop1(); End  //Al pulsar espacio llama al processo hadoken de ken
		graph++; 
		If(graph>10) graph=5;  End  
		coli=collision(Type ball);
		If (coli<>0) dmg=damage(); End  //Si detecta la colision con la bola se inicia el proceso de daño
	End
	
		
End
              
              
//=======================================================
//= Proceso hadop1()                                    =
//= Es llamado por KEN()                                =
//=======================================================
Process hadop1()  
Private
    coli;
Begin 
    signal(p1, s_sleep);    //Pone a dormir a Ken para ejecutar el Hadoken

	//Le asignamos el gráfico deseado al proceso
	graph=1;
    
	//Le damos valor a sus coordenadas iniciales
	x=45; y=177; 
	

	Loop
		Frame (250);          
        graph++;   
        coli=collision(Type ball); 
        If(graph==1) If (coli<>0) dmg=damage(); End ;End
		If(graph==2) If (coli<>0) dmg=damage(); End ;End 
		If(graph==3) If (coli<>0) dmg=damage(); End ;End
        If(graph==4) Frame(400);
            If (coli<>0) 
                play_wav(raspa,0);
                If(gfxball==21 OR gfxball==22) velo_ball++; blue++; U_blue++;T_U_Blue++; End  
                If(gfxball==23 OR gfxball==24) velo_ball=rand(2,12);red++;U_red++;T_U_red++; End
                If(gfxball==25 OR gfxball==26) velo_ball++;giant++;U_giant++;T_U_giant++;End
            rebote++; Unidades_match_combo++; U_M_H++; U_T_H++;
            If(Unidades_match_combo>9) unidades_match_combo=0;decenas_match_combo++; End
		    If(decenas_match_combo>9) decenas_match_combo=0;centenas_match_combo++; End
		     
		    If(U_M_H>9) U_M_H=0; D_M_H++;End
		    If(D_M_H>9) D_M_H=0; C_M_H++;End
		    If(U_T_H>9) U_T_H=0; D_T_H++;End
		    If(D_T_H>9) D_T_H=0; C_T_H++;End
		     
		     
		    If(T_U_blue>9) T_U_blue=0; T_D_blue++;End
		    If(T_D_blue>9) T_D_blue=0; T_C_blue++;End
		    If(U_blue>9) U_blue=0; D_blue++;End
		    If(D_blue>9) D_blue=0; C_blue++;End  
		    
		    If(T_U_red>9) T_U_red=0; T_D_red++;End
		    If(T_D_red>9) T_D_red=0; T_C_red++;End
		    If(U_red>9) U_red=0; D_red++;End
		    If(D_red>9) D_red=0; C_red++;End
		    
		    If(T_U_giant>9) T_U_giant=0; T_D_giant++;End
		    If(T_D_giant>9) T_D_giant=0; T_C_giant++;End
		    If(U_giant>9) U_giant=0; D_giant++;End
		    If(D_giant>9) D_giant=0; C_giant++;End
            
            
            
            b2=ball2();
            End
         Frame(400);signal(p1, s_wakeup);Return; 
         End //Acaba el Hadoken y despierta a Ken   
        End   
                   
End

//=======================================================
//= Proceso Ryu()                                       =
//= Llama al proceso Hadop2 para realicar el movimiento =
//=======================================================

Process ryu()  
Private
    coli;
Begin
	//Le asignamos el gráfico deseado al proceso
	graph=11;
	flags=1; //Invierte los graficos a lo espejo
	
	
    
	//Le damos valor a sus coordenadas iniciales
	x=280; y=175; 
	

	Loop
		Frame 250;

		//Detectamos las pulsaciones de las teclas/stick de GP32 
		If(key(_control) OR key(_alt) OR key(_tab) OR key(_space)) play_wav(hadoken2,0);h2=hadop2(); End  //Al pulsar enter llama al processo hadoken de ken
		graph++; 
		If(graph>16) graph=11;  End  
		coli=collision(Type ball2);
		If (coli<>0) dmg2=damage2(); End; 
		// =I.A en desarrollo =If(ball_X=>(170-velo_ball)) play_wav(hadoken,0);h2=hadop2(); End
	End
		
End
              
              
//=======================================================
//= Proceso hadop2()                                    =
//= Es llamado por Ryu()                                =
//=======================================================
Process hadop2()  
Private
    coli;
Begin 
    signal(p2, s_sleep);    //Pone a dormir a RYU para ejecutar el Hadoken

	//Le asignamos el gráfico deseado al proceso
	graph=43;  
	flags=1;
    
	//Le damos valor a sus coordenadas iniciales
	x=280; y=177; 
	

	Loop
		Frame (250);          
        graph++;   
        coli=collision(Type ball2);
		 If(graph==43) If (coli<>0) dmg=damage2(); End ;End
		 If(graph==44) If (coli<>0) dmg=damage2(); End ;End
		 If(graph==45) If (coli<>0) dmg=damage2(); End ;End
        If(graph==46) Frame(400);
            If (coli<>0)
            play_wav(raspa,0);
                If(gfxball==21 OR gfxball==22) velo_ball++; Blue++;U_blue++;T_U_Blue++;End  
                If(gfxball==23 OR gfxball==24) velo_ball=rand(2,12);red++;U_red++;T_U_red++; End
                If(gfxball==25 OR gfxball==26) velo_ball++; giant++;U_giant++;T_U_giant++; End
                rebote++;Unidades_match_combo++; U_M_H++; U_T_H++;
            If(Unidades_match_combo>9) unidades_match_combo=0;decenas_match_combo++; End
		    If(decenas_match_combo>9) decenas_match_combo=0;centenas_match_combo++; End
		    
		    If(U_M_H>9) U_M_H=0; D_M_H++;End
		    If(D_M_H>9) D_M_H=0; C_M_H++;End
		    If(U_T_H>9) U_T_H=0; D_T_H++;End
		    If(D_T_H>9) D_T_H=0; C_T_H++;End
		    
		    If(T_U_blue>9) T_U_blue=0; T_D_blue++;End
		    If(T_D_blue>9) T_D_blue=0; T_C_blue++;End
		    If(U_blue>9) U_blue=0; D_blue++;End
		    If(D_blue>9) D_blue=0; C_blue++;End
      
            If(T_U_red>9) T_U_red=0; T_D_red++;End
		    If(T_D_red>9) T_D_red=0; T_C_red++;End
		    If(U_red>9) U_red=0; D_red++;End
		    If(D_red>9) D_red=0; C_red++;End
		    
		    If(T_U_giant>9) T_U_giant=0; T_D_giant++;End
		    If(T_D_giant>9) T_D_giant=0; T_C_giant++;End
		    If(U_giant>9) U_giant=0; D_giant++;End
		    If(D_giant>9) D_giant=0; C_giant++;End          
                 
                 b=ball();End;
            Frame(400);signal(p2, s_wakeup);Return; End //Acaba el Hadoken y despierta a Ken  
          
    End 
End               

//=======================================================
//= Proceso ball()                                      =
//=======================================================

Process ball()   
Begin  
signal(b2, s_kill); 
startball=1;
flags=1; 
If(rebote==12) play_wav(levelup,0);End  
If(rebote==19) play_wav(levelup,0);End
graph=gfxball;

Loop  
x=ball_X; y=160;
Frame; 
ball_X-=velo_ball; 
graph++;
If(graph>(gfxball+1)) graph=gfxball; End
If(ball_X=<-100) damage();  End
If(ball_X=>420) damage2();  End

End   
End   

//=======================================================
//= Proceso ball2()                                      =
//=======================================================

Process ball2()   
Begin 
signal(b, s_kill);
startball=1;
If(rebote==12) play_wav(levelup,0);End  
If(rebote==19) play_wav(levelup,0);End 
graph=gfxball;
Loop  
x=ball_X; y=160;
Frame;
graph++;
ball_X+=velo_ball;  
If(graph>(gfxball+1)) graph=gfxball; End  
If(ball_X=<-100) damage();  End
If(ball_X=>420) damage2();  End

End   
End

                    
//=======================================================
//= Proceso damage()                                    =
//=======================================================
                                                              
Process damage()  
Begin 
    signal(p1, s_sleep);    //Pone a dormir a Ken para ejecutar el Damage 
    signal(b,s_kill);
    signal(h1,s_kill);
                         
    play_wav(damage,0);
	//Le asignamos el gráfico deseado al proceso
	graph=19;
    
	//Le damos valor a sus coordenadas iniciales
	x=40; y=170;
	If(gfxball==21 OR gfxball==22) v1-=1;   End  // Decrementa el numero de vidas del P1 
    If(gfxball==23 OR gfxball==24) v1-=2;   End  // Decrementa el numero de vidas del P1
    If(gfxball==25 OR gfxball==26) v1-=3;   End  // Decrementa el numero de vidas del P1
	//If(v2=<1) kwin++; End
                               
	Loop
		Frame (500);  
		graph++;  
		Frame (500); 
		If(cont_round!=3) gfxball=21; End; //reinicia para sacar la ball normal despues del daño
		If(match_combo<rebote) match_combo=rebote; U_M_C=Unidades_match_combo;D_M_C=decenas_match_combo;C_M_C=centenas_match_combo;
		    If(total_match_combo<match_combo) total_match_combo=match_combo; U_T_C=U_M_C; D_T_C=D_M_C;C_T_C=C_M_C;End 
		End;
		Unidades_match_combo=0;decenas_match_combo=0;centenas_match_combo=0;
		
        rebote=0;  
        
		
		If(graph==20)  signal(p1, s_wakeup); startball=0; If(v1<=1) loserp1(); winerp2();startball=1;  End;Return;  
	End	
	
End 
End

    
//=======================================================
//= Proceso damage2()                                    =
//=======================================================
                                                              
Process damage2()  
Begin 
    signal(p2, s_sleep);    //Pone a dormir a Ken para ejecutar el Damage 
    signal(b2,s_kill);
    signal(h2,s_kill);
    play_wav(damage,0);

	//Le asignamos el gráfico deseado al proceso
	flags=1;
	graph=47;
                            
	//Le damos valor a sus coordenadas iniciales
	x=285; y=175;  
    If(gfxball==21 OR gfxball==22) v2-=1;   End  // Decrementa el numero de vidas del P2 
    If(gfxball==23 OR gfxball==24) v2-=2;   End  // Decrementa el numero de vidas del P2
    If(gfxball==25 OR gfxball==26) v2-=3;   End  // Decrementa el numero de vidas del P2
	//If(v1=<1) rwin++; End
	    
             
	Loop
		Frame (500);  
		graph++;  
		Frame (500);
		If(cont_round!=3) gfxball=21; End;//reinicia para sacar la ball normal despues del daño 
		If(match_combo<rebote) match_combo=rebote;U_M_C=Unidades_match_combo;D_M_C=decenas_match_combo;C_M_C=centenas_match_combo;rebote=0;
		    If(total_match_combo<match_combo) total_match_combo=match_combo; U_T_C=U_M_C; D_T_C=D_M_C;C_T_C=C_M_C;End 
		End;
		
		
		Unidades_match_combo=0;decenas_match_combo=0;centenas_match_combo=0;
		rebote=0;
		
		

		If(graph==48)  signal(p2, s_wakeup);    startball=0;    If(v2<=1) loserp2(); winerp1(); startball=1; End; Return; 
    End	
End               
End
//=======================================================
//= Proceso marcadorp1()                                        =
//=======================================================  
Process marcadorp1()
Begin
    Loop 
        
    If(kwin==1) put(0,38,25,45); End  
    If(kwin==2) level=34;wins_ken++;unidades_wins_ken++;
        If(unidades_wins_ken>9) unidades_wins_ken=0; decenas_wins_ken++; End
        wl(); End 
    If(v1<=1) put(0,27,28,18);  put (0,27,50,18);  put (0,27,72,18);   put (0,27,94,18);   put (0,27,116,18);  End 
    If(v1==2) put(0,27,28,18);  put (0,27,50,18);  put (0,27,72,18);   put (0,27,94,18);  End   
    If(v1==3) put(0,27,28,18);  put (0,27,50,18);  put (0,27,72,18);    End
    If(v1==4) put(0,27,28,18);  put (0,27,50,18);  End 
    If(v1==5) put(0,27,28,18);  End  
   
   
    
    
    
    
    Frame;
    End  
End

//=======================================================
//= Proceso marcadorp2()                                        =
//=======================================================  
Process marcadorp2()
Begin
    Loop 
    If(Rwin==1) put(0,38,280,45);End  
    If(Rwin==2) level=33;wins_ryu++; unidades_wins_ryu++; 
        If(unidades_wins_ryu>9) unidades_wins_ryu=0; decenas_wins_ryu++; End
        wl(); End
    If(v2<=1) put(0,27,278,18);  put (0,27,256,18);  put (0,27,234,18);   put (0,27,212,18);   put (0,27,190,18);  End 
    If(v2==2) put(0,27,278,18);  put (0,27,256,18);  put (0,27,234,18);   put (0,27,212,18);  End   
    If(v2==3) put(0,27,278,18);  put (0,27,256,18);  put (0,27,234,18);    End
    If(v2==4) put(0,27,278,18);  put (0,27,256,18);  End 
    If(v2==5) put(0,27,278,18);  End
    
    
    
                           
    Frame;
    End  
End

//=======================================================
//= Proceso loserp1()                                =
//=======================================================  
Process loserp1()  
Begin       
signal(p1, s_sleep);    //Mata a Ken para ejecutar la pose de loser 
signal(h1,s_kill);
signal(dmg, s_kill);     //Mata al Hadoken de Ken para ejecutar la pose de loser
	//Le asignamos el gráfico deseado al proceso
	    
	//Le damos valor a sus coordenadas iniciales
	x=40; y=175;  
	graph=5;
	Loop
		
		Frame(3000);
		x=40; y=165;  
		graph=28;
		Frame(500);
		graph=29;  
		Frame(500);
		graph=30;
		Frame(8000);
		Return;   
		
		
		
	End
End               

//=======================================================
//= Proceso winerp1()                                =
//=======================================================  
Process winerp1()  
Begin       
signal(p1, s_sleep);    //Mata a Ken para ejecutar la pose de loser 
signal(h1,s_kill);
signal(dmg, s_kill);     //Mata al Hadoken de Ken para ejecutar la pose de loser
	//Le asignamos el gráfico deseado al proceso
	    
	//Le damos valor a sus coordenadas iniciales
	x=40; y=175;  
	graph=5;
	Loop
		
		Frame(3000);
		x=40; y=160;  
		graph=31;
		put(0,42,160,120);
		play_wav(sfx_kwin,0);
		Frame(500);
		graph=32;  
		Frame(500);
		graph=31;
		Frame(500);
		graph=32;
		Frame(500);
		graph=31;
		Frame(500);
		graph=32;
		Frame(6500);
		cont_round++;kwin++; 
		If(cont_round==3) gfxball=25;velo_ball=1;End
		startball=0; put_screen(0,level); signal(p1, s_wakeup);  signal(p2, s_wakeup);  signal(m1, s_wakeup);  signal(m2, s_wakeup); v1=6; V2=6; Return; 
		End
		Return;
		   
		
		
		
	End

//=======================================================
//= Proceso loserp2()                                =
//=======================================================  
Process loserp2()  
Begin       
signal(p2, s_sleep);    //Mata a Ken para ejecutar la pose de loser 
signal(h2,s_kill);
signal(dmg2, s_kill);     //Mata al Hadoken de Ken para ejecutar la pose de loser
	//Le asignamos el gráfico deseado al proceso
	    
	//Le damos valor a sus coordenadas iniciales
 
	flags=1; 
	graph=11;
	Loop
		x=280; y=175; 
		Frame(3000);
		x=280; y=142;  
		graph=56;
		Frame(500);
		graph=57;  
		Frame(500);
		graph=58;
		Frame(8000); 
		Return;   
		
		
		
	End
End               

//=======================================================
//= Proceso winerp2()                                =
//=======================================================  
Process winerp2()  
Begin       
signal(p2, s_sleep);    //Mata a Ken para ejecutar la pose de loser 
signal(h2,s_kill);
signal(dmg2, s_kill);     //Mata al Hadoken de Ken para ejecutar la pose de loser
	//Le asignamos el gráfico deseado al proceso
	    
	//Le damos valor a sus coordenadas iniciales
	x=280; y=175;
	flags=1;  
	graph=11;
	Loop
		
		Frame(3000);
		x=280; y=172;  
		graph=51; 
		put(0,49,160,120);
		play_wav(sfx_rwin,0);
		Frame(500);         
		graph=52;  
		Frame(500);
		graph=51;
		Frame(500);
		graph=53;
		Frame(500);
		graph=54;
		Frame(500);
		graph=55;
		Frame(6500);
		cont_round++; rwin++;
		If(cont_round==3) gfxball=25;velo_ball=1;End
		startball=0;put_screen(0,level); signal(p1, s_wakeup);  signal(p2, s_wakeup);  signal(m1, s_wakeup);  signal(m2, s_wakeup); v1=6; V2=6;
		Return;   
		
		           
		
	End
End  

            
//=======================================================
//= Proceso Win - Loses                                          =
//=======================================================  
Process wl()  
Begin 
signal(p1, s_sleep);            
signal(p2, s_sleep);  
signal(m1, s_sleep);           
signal(m2, s_sleep);
signal(Id_round, s_kill);
clear_screen();         
 
If(wins_ken==wins_ryu) who_wins=37;End
If(wins_ken<wins_ryu) who_wins=36;End
If(wins_ken>wins_ryu) who_wins=35;End
put_screen(0,who_wins);
xput(1,(decenas_wins_ken+1),25,190,0,40,0,0);
xput(1,(unidades_wins_ken+1),70,190,0,40,0,0);
xput(1,(decenas_wins_ryu+1),250,190,0,40,0,0);
xput(1,(unidades_wins_ryu+1),295,190,0,40,0,0);  


    
Loop  
    Frame;
    If(key(_enter)) play_wav(sfx_option,0); Frame(2000);delete_text(all_text);last(); Break; End 
    End 
End 

//=======================================================
//= Proceso Stats last                                          =
//=======================================================  
Process last()                 
Begin   
clear_screen();
put_screen(0,59); 

//C_M_H=(C_BLUE+C_RED+C_GIANT);
//D_M_H=(D_BLUE+D_RED+D_GIANT);
//U_M_H=(U_BLUE+U_RED+U_GIANT);

//C_T_H=C_T_H+(T_C_BLUE+T_C_RED+T_C_GIANT);
//D_T_H=D_T_H+(T_D_BLUE+T_D_RED+T_D_GIANT);
//U_T_H=U_T_H+(T_U_BLUE+T_U_RED+T_U_GIANT);



//MAX COMBO
xput(1,(C_M_C+1),170,223,0,20,0,0);
xput(1,(D_M_C+1),195,223,0,20,0,0);
xput(1,(U_M_C+1),220,223,0,20,0,0);
//MATCH HADO
xput(1,(C_M_H+1),230,68,0,20,0,0);
xput(1,(D_M_H+1),255,68,0,20,0,0);
xput(1,(U_M_H+1),280,68,0,20,0,0); 
//TOTAL BLUE
xput(1,(C_blue+1),100,114,0,15,0,0);
xput(1,(D_blue+1),120,114,0,15,0,0);
xput(1,(U_blue+1),140,114,0,15,0,0);
//TOTAL RED
xput(1,(C_RED+1),100,173,0,15,0,0);
xput(1,(D_RED+1),120,173,0,15,0,0);
xput(1,(U_RED+1),140,173,0,15,0,0);
//TOTAL GIANT
xput(1,(C_giant+1),260,138,0,15,0,0);
xput(1,(D_giant+1),280,138,0,15,0,0);
xput(1,(U_giant+1),300,138,0,15,0,0);

//xput(1,(decenas_wins_ryu+1),250,190,0,40,0,0);
//xput(1,(unidades_wins_ryu+1),295,190,0,40,0,0);   
Loop  
    Frame(300);
    If(key(_enter)) play_wav(sfx_option,0); Frame(2000);today(); Break; End 
    End 
End 
              
//=======================================================
//= Proceso Stats2  today                                        =
//=======================================================  
Process today()  
Begin   
clear_screen();
put_screen(0,60);
//TOTAL COMBO
xput(1,(C_T_C+1),170,223,0,20,0,0);
xput(1,(D_T_C+1),195,223,0,20,0,0);
xput(1,(U_T_C+1),220,223,0,20,0,0);                        
//TOTAL HADO
xput(1,(C_T_H+1),230,68,0,20,0,0);
xput(1,(D_T_H+1),255,68,0,20,0,0);
xput(1,(U_T_H+1),280,68,0,20,0,0); 
//TOTAL BLUE
xput(1,(T_C_blue+1),100,114,0,15,0,0);
xput(1,(T_D_blue+1),120,114,0,15,0,0);
xput(1,(T_U_blue+1),140,114,0,15,0,0);
//TOTAL RED
xput(1,(T_C_red+1),100,173,0,15,0,0);
xput(1,(T_D_red+1),120,173,0,15,0,0);
xput(1,(T_U_red+1),140,173,0,15,0,0);
//TOTAL GIANT
xput(1,(T_C_giant+1),260,138,0,15,0,0);
xput(1,(T_D_giant+1),280,138,0,15,0,0);
xput(1,(T_U_giant+1),300,138,0,15,0,0);    
Loop  
    Frame(300);
    If(key(_space)) play_wav(sfx_option,0); Frame(2000);intro(); Break; End  
    If(key(_enter)) play_wav(sfx_option,0); Frame(2000);Id_round=cont_round=1; stop_song();If(level==33) musica=m_ryu; Else musica=m_ken;END; play_song(musica,-1); startball=0; put_screen(0,level); signal(p1, s_wakeup);  signal(p2, s_wakeup);  signal(m1, s_wakeup);  signal(m2, s_wakeup); v1=6; V2=6; gfxball=21; kwin=0; rwin=0;match_combo=0;blue=0;U_blue=0; D_blue=0; C_blue=0;red=0;U_red=0; D_red=0; C_red=0;giant=0;U_giant=0; D_giant=0; C_giant=0;U_M_H=0; D_M_H=0; C_M_H=0; Break; End 
    End
     
End















































