Buscando en Internet se puede encontrar este codigo de ejemplo de supersmash, me gusta la IA del rival.
Saludos querubines...
with Adagraph;use Adagraph;
with Ada.Integer_Text_Io;use Ada.Integer_Text_Io;
with ada.Text_IO;use ada.Text_IO;
procedure Super_Smash is
X:Integer:=100;
Y,Y1:Integer:=110;
X1:Integer:=480;
Guanyador:Boolean:=False;
K:Character;
Vida1,Vida2:Integer:=100;
Ia:Boolean:=False;
Ia1:Boolean:=False;
Sortir:Boolean:=False;
Color:Extended_Color_Type;
procedure Menu_Seleccio(K:in out Character;Ia,Ia1,Sortir:in out Boolean) is
i,j:integer;
begin
K:='.';
Ia:=False;
Ia1:=False;
Sortir:=false;
Open_Graph_Window(600,500);
Clear_Window(Blue);
Draw_Box(50,200,150,220,Green,True);
Draw_Box(235,200,355,220,Green,True);
Draw_Box(435,200,555,220,Green,True);
Draw_Box(525,20,580,40,Green,True);
Display_Text(55,205,"HUM VS HUM");
Display_Text(240,205,"HUM VS IA EASY");
Display_Text(440,205,"HUM VS IA HARD");
Display_Text(530,25,"SORTIR");
while not Ia and not Ia1 and not sortir and K/=' ' loop
Get_Mouse_Button(Left_Button,I,J);
if I>50 and J>200 and I<150 and J<220 then
K:=' ';
elsif I>235 and J>200 and I<355 and J<220 then
Ia1:=True;
elsif I>435 and J>200 and I<555 and J<220 then
Ia:=True;
elsif I>525 and J>20 and I<580 and J<40 then
Sortir:=True;
end if;
end loop;
close_graph_window;
end Menu_Seleccio;
procedure Inicialitzacio is
begin
Open_Graph_Window(600,500);
Clear_Window(Light_Blue);
Draw_Box(100,0,500,110,Green,True);
Draw_Box(100,100,500,110,Brown,True);
Draw_Box(150,180,250,190,Black,True);
Draw_Box(350,180,450,190,Black,True);
Draw_Circle(400,400,40,Yellow,True);
Draw_Line(400,400,450,450,Yellow);
Draw_Line(400,400,450,350,Yellow);
Draw_Line(400,400,350,450,Yellow);
Draw_Line(400,400,350,350,Yellow);
Draw_Line(400,400,460,400,Yellow);
Draw_Line(400,400,340,400,Yellow);
Draw_Line(400,400,400,460,Yellow);
Draw_line(400,400,400,340,yellow);
end Inicialitzacio;
procedure Dibuixar_Vida(Vida1,Vida2:in Integer) is
begin
Draw_Box(148,60,252,80,Black,True);
Draw_Box(150,62,150+Vida1,78,Blue,True);
Draw_Box(348,60,452,80,Black,True);
Draw_Box(350,62,350+Vida2,78,Blue,True);
end Dibuixar_Vida;
procedure Dibuix_Personatge_Aturat(X,Y:in Integer) is
begin
Draw_Line(X,Y,X+10,Y+20);
Draw_Line(X+10,Y+20,X+20,Y);
Draw_Line(X+10,Y+20,X+10,Y+50);
Draw_Line(X+10,Y+45,X,Y+25);
Draw_Line(X+10,Y+45,X+20,Y+25);
Draw_Circle(X+10,Y+55,10,Black,True);
end Dibuix_Personatge_Aturat;
procedure Cop_De_Puny_Dret(X,Y:in Integer) is
begin
Draw_Line(X,Y,X+10,Y+20,Light_Blue);
Draw_Line(X+10,Y+20,X+20,Y,Light_Blue);
Draw_Line(X+10,Y+20,X+10,Y+50,Light_Blue);
Draw_Line(X+10,Y+45,X,Y+25,Light_Blue);
Draw_Line(X+10,Y+45,X+20,Y+25,Light_Blue);
Draw_Circle(X+10,Y+55,10,Light_Blue,True);
Draw_Line(X,Y,X+10,Y+20);
Draw_Line(X+10,Y+20,X+20,Y);
Draw_Line(X+10,Y+20,X+10,Y+50);
Draw_Line(X+10,Y+45,X,Y+25);
Draw_Line(X+10,Y+45,X+20,Y+35);
Draw_Line(X+20,Y+35,X+25,Y+40);
Draw_Circle(X+10,Y+55,10,Black,True);
delay 0.1;
Draw_Line(X,Y,X+10,Y+20,Light_Blue);
Draw_Line(X+10,Y+20,X+20,Y,Light_Blue);
Draw_Line(X+10,Y+20,X+10,Y+50,Light_Blue);
Draw_Line(X+10,Y+45,X,Y+25,Light_Blue);
Draw_Line(X+10,Y+45,X+20,Y+35,Light_Blue);
Draw_Line(X+20,Y+35,X+25,Y+40,Light_Blue);
Draw_Circle(X+10,Y+55,10,Light_Blue,True);
Draw_Line(X,Y,X+10,Y+20);
Draw_Line(X+10,Y+20,X+20,Y);
Draw_Line(X+10,Y+20,X+10,Y+50);
Draw_Line(X+10,Y+45,X,Y+25);
Draw_Line(X+10,Y+45,X+20,Y+25);
Draw_Circle(X+10,Y+55,10,Black,True);
end Cop_De_Puny_Dret;
procedure Cop_De_Puny_Esquerre(X,Y:in Integer) is
begin
Draw_Line(X,Y,X+10,Y+20,Light_Blue);
Draw_Line(X+10,Y+20,X+20,Y,Light_Blue);
Draw_Line(X+10,Y+20,X+10,Y+50,Light_Blue);
Draw_Line(X+10,Y+45,X,Y+25,Light_Blue);
Draw_Line(X+10,Y+45,X+20,Y+25,Light_Blue);
Draw_Circle(X+10,Y+55,10,Light_Blue,True);
Draw_Line(X,Y,X+10,Y+20);
Draw_Line(X+10,Y+20,X+20,Y);
Draw_Line(X+10,Y+20,X+10,Y+50);
Draw_Line(X+10,Y+45,X,Y+35);
Draw_Line(X,Y+35,X-5,Y+40);
Draw_Line(X+10,Y+45,X+20,Y+25);
Draw_Circle(X+10,Y+55,10,Black,True);
delay 0.1;
Draw_Line(X,Y,X+10,Y+20,Light_Blue);
Draw_Line(X+10,Y+20,X+20,Y,Light_Blue);
Draw_Line(X+10,Y+20,X+10,Y+50,Light_Blue);
Draw_Line(X+10,Y+45,X,Y+35,Light_Blue);
Draw_Line(X,Y+35,X-5,Y+40,Light_Blue);
Draw_Line(X+10,Y+45,X+20,Y+25,Light_Blue);
Draw_Circle(X+10,Y+55,10,Light_Blue,True);
Draw_Line(X,Y,X+10,Y+20);
Draw_Line(X+10,Y+20,X+20,Y);
Draw_Line(X+10,Y+20,X+10,Y+50);
Draw_Line(X+10,Y+45,X,Y+25);
Draw_Line(X+10,Y+45,X+20,Y+25);
Draw_Circle(X+10,Y+55,10,Black,True);
end Cop_De_Puny_Esquerre;
procedure Bot_Dreta(X,Y:in Integer;POSX,POSY:out integer) is
begin
Draw_Line(X,Y,X+10,Y+20,Light_Blue);
Draw_Line(X+10,Y+20,X+20,Y,Light_Blue);
Draw_Line(X+10,Y+20,X+10,Y+50,Light_Blue);
Draw_Line(X+10,Y+45,X,Y+25,Light_Blue);
Draw_Line(X+10,Y+45,X+20,Y+25,Light_Blue);
Draw_Circle(X+10,Y+55,10,Light_Blue,True);
delay 0.03;
POSX:=X+40;
POSY:=Y+80;
Draw_Line(POSX,POSY,POSX+10,POSY+20);
Draw_Line(POSX+10,POSY+20,POSX+20,POSY);
Draw_Line(POSX+10,POSY+20,POSX+10,POSY+50);
Draw_Line(POSX+10,POSY+45,POSX,POSY+25);
Draw_Line(POSX+10,POSY+45,POSX+20,POSY+25);
Draw_Circle(POSX+10,POSY+55,10,Black,True);
end Bot_Dreta;
procedure Bot_Esquerra(X,Y:in Integer;Posx,Posy:out Integer) is
begin
Draw_Line(X,Y,X+10,Y+20,Light_Blue);
Draw_Line(X+10,Y+20,X+20,Y,Light_Blue);
Draw_Line(X+10,Y+20,X+10,Y+50,Light_Blue);
Draw_Line(X+10,Y+45,X,Y+25,Light_Blue);
Draw_Line(X+10,Y+45,X+20,Y+25,Light_Blue);
Draw_Circle(X+10,Y+55,10,Light_Blue,True);
delay 0.03;
POSX:=X-40;
POSY:=Y+80;
Draw_Line(POSX,POSY,POSX+10,POSY+20);
Draw_Line(POSX+10,POSY+20,POSX+20,POSY);
Draw_Line(POSX+10,POSY+20,POSX+10,POSY+50);
Draw_Line(POSX+10,POSY+45,POSX,POSY+25);
Draw_Line(POSX+10,POSY+45,POSX+20,POSY+25);
Draw_Circle(POSX+10,POSY+55,10,Black,True);
end Bot_Esquerra;
procedure Efecte_Gravetat(X,Y:in out Integer) is
begin
Draw_Line(X,Y,X+10,Y+20,Light_Blue);
Draw_Line(X+10,Y+20,X+20,Y,Light_Blue);
Draw_Line(X+10,Y+20,X+10,Y+50,Light_Blue);
Draw_Line(X+10,Y+45,X,Y+25,Light_Blue);
Draw_Line(X+10,Y+45,X+20,Y+25,Light_Blue);
Draw_Circle(X+10,Y+55,10,Light_Blue,True);
if Y>190 then
Y:=Y-80;
end if;
if Y>110 and (X+20<150 or (X>250 and X+20<350) or X>450) then
Y:=Y-80;
end if;
if Y=110 and (X<100 or X>500) then
Y:=Y-110;
end if;
Draw_Line(X,Y,X+10,Y+20);
Draw_Line(X+10,Y+20,X+20,Y);
Draw_Line(X+10,Y+20,X+10,Y+50);
Draw_Line(X+10,Y+45,X,Y+25);
Draw_Line(X+10,Y+45,X+20,Y+25);
Draw_Circle(X+10,Y+55,10,Black,True);
end Efecte_Gravetat;
procedure Moure_Dreta(X,Y:in out Integer) is
begin
Draw_Line(X,Y,X+10,Y+20,Light_Blue);
Draw_Line(X+10,Y+20,X+20,Y,Light_Blue);
Draw_Line(X+10,Y+20,X+10,Y+50,Light_Blue);
Draw_Line(X+10,Y+45,X,Y+25,Light_Blue);
Draw_Line(X+10,Y+45,X+20,Y+25,Light_Blue);
Draw_Circle(X+10,Y+55,10,Light_Blue,True);
Draw_Line(X+10,Y+20,X+20,Y);
Draw_Line(X+10,Y+20,X+10,Y+50);
Draw_Line(X+10,Y+45,X,Y+25);
Draw_Line(X+10,Y+45,X+20,Y+25);
Draw_Circle(X+10,Y+55,10,Black,True);
delay 0.1;
Draw_Line(X+10,Y+20,X+20,Y,Light_Blue);
Draw_Line(X+10,Y+20,X+10,Y+50,Light_Blue);
Draw_Line(X+10,Y+45,X,Y+25,Light_Blue);
Draw_Line(X+10,Y+45,X+20,Y+25,Light_Blue);
Draw_Circle(X+10,Y+55,10,Light_Blue,True);
delay 0.1;
X:=X+20;
Draw_Line(X,Y,X+10,Y+20);
Draw_Line(X+10,Y+20,X+20,Y);
Draw_Line(X+10,Y+20,X+10,Y+50);
Draw_Line(X+10,Y+45,X,Y+25);
Draw_Line(X+10,Y+45,X+20,Y+25);
Draw_Circle(X+10,Y+55,10,Black,True);
end Moure_Dreta;
procedure Moure_Esquerra(X,Y:in out Integer) is
begin
Draw_Line(X,Y,X+10,Y+20,Light_Blue);
Draw_Line(X+10,Y+20,X+20,Y,Light_Blue);
Draw_Line(X+10,Y+20,X+10,Y+50,Light_Blue);
Draw_Line(X+10,Y+45,X,Y+25,Light_Blue);
Draw_Line(X+10,Y+45,X+20,Y+25,Light_Blue);
Draw_Circle(X+10,Y+55,10,Light_Blue,True);
Draw_Line(X,Y,X+10,Y+20);
Draw_Line(X+10,Y+20,X+10,Y+50);
Draw_Line(X+10,Y+45,X,Y+25);
Draw_Line(X+10,Y+45,X+20,Y+25);
Draw_Circle(X+10,Y+55,10,Black,True);
delay 0.1;
Draw_Line(X,Y,X+10,Y+20,Light_Blue);
Draw_Line(X+10,Y+20,X+10,Y+50,Light_Blue);
Draw_Line(X+10,Y+45,X,Y+25,Light_Blue);
Draw_Line(X+10,Y+45,X+20,Y+25,Light_Blue);
Draw_Circle(X+10,Y+55,10,Light_Blue,True);
delay 0.1;
X:=X-20;
Draw_Line(X,Y,X+10,Y+20);
Draw_Line(X+10,Y+20,X+20,Y);
Draw_Line(X+10,Y+20,X+10,Y+50);
Draw_Line(X+10,Y+45,X,Y+25);
Draw_Line(X+10,Y+45,X+20,Y+25);
Draw_Circle(X+10,Y+55,10,Black,True);
end Moure_Esquerra;
procedure Evaluar_Si_Ferit_Dreta(A,B,Y,Y1,Vida:in out Integer) is
begin
if B-A=20 and Y=Y1 then
Draw_Line(B,Y,B+10,Y+20,Light_Blue);
Draw_Line(B+10,Y+20,B+20,Y,Light_Blue);
Draw_Line(B+10,Y+20,B+10,Y+50,Light_Blue);
Draw_Line(B+10,Y+45,B,Y+25,Light_Blue);
Draw_Line(B+10,Y+45,B+20,Y+25,Light_Blue);
Draw_Circle(B+10,Y+55,10,Light_Blue,True);
Draw_Line(B,Y,B+10,Y+20);
Draw_Line(B+10,Y+20,B+20,Y);
Draw_Line(B+10,Y+20,B+10,Y+50);
Draw_Line(B+10,Y+45,B,Y+25);
Draw_Line(B+10,Y+45,B+20,Y+25);
Draw_Circle(B+10,Y+55,10,Black,True);
Draw_Circle(B+10,Y+40,5,Red,True);
delay 0.02;
Draw_Line(B,Y,B+10,Y+20,Light_Blue);
Draw_Line(B+10,Y+20,B+20,Y,Light_Blue);
Draw_Line(B+10,Y+20,B+10,Y+50,Light_Blue);
Draw_Line(B+10,Y+45,B,Y+25,Light_Blue);
Draw_Line(B+10,Y+45,B+20,Y+25,Light_Blue);
Draw_Circle(B+10,Y+55,10,Light_Blue,True);
Draw_Circle(B+10,Y+40,5,Light_Blue,True);
B:=B+20;
Draw_Line(B,Y,B+10,Y+20);
Draw_Line(B+10,Y+20,B+20,Y);
Draw_Line(B+10,Y+20,B+10,Y+50);
Draw_Line(B+10,Y+45,B,Y+25);
Draw_Line(B+10,Y+45,B+20,Y+25);
Draw_Circle(B+10,Y+55,10,Black,True);
Vida:=Vida-10;
end if;
end Evaluar_Si_Ferit_Dreta;
procedure Evaluar_Si_Ferit_Esquerra(A,B,Y,Y1,Vida:in out Integer) is
begin
if (A-B)=20 and Y=Y1 then
Draw_Line(B,Y,B+10,Y+20,Light_Blue);
Draw_Line(B+10,Y+20,B+20,Y,Light_Blue);
Draw_Line(B+10,Y+20,B+10,Y+50,Light_Blue);
Draw_Line(B+10,Y+45,B,Y+25,Light_Blue);
Draw_Line(B+10,Y+45,B+20,Y+25,Light_Blue);
Draw_Circle(B+10,Y+55,10,Light_Blue,True);
Draw_Line(B,Y,B+10,Y+20);
Draw_Line(B+10,Y+20,B+20,Y);
Draw_Line(B+10,Y+20,B+10,Y+50);
Draw_Line(B+10,Y+45,B,Y+25);
Draw_Line(B+10,Y+45,B+20,Y+25);
Draw_Circle(B+10,Y+55,10,Black,True);
Draw_Circle(B+10,Y+40,5,Red,True);
delay 0.02;
Draw_Line(B,Y,B+10,Y+20,Light_Blue);
Draw_Line(B+10,Y+20,B+20,Y,Light_Blue);
Draw_Line(B+10,Y+20,B+10,Y+50,Light_Blue);
Draw_Line(B+10,Y+45,B,Y+25,Light_Blue);
Draw_Line(B+10,Y+45,B+20,Y+25,Light_Blue);
Draw_Circle(B+10,Y+55,10,Light_Blue,True);
Draw_Circle(B+10,Y+40,5,Light_Blue,True);
B:=B-20;
Draw_Line(B,Y,B+10,Y+20);
Draw_Line(B+10,Y+20,B+20,Y);
Draw_Line(B+10,Y+20,B+10,Y+50);
Draw_Line(B+10,Y+45,B,Y+25);
Draw_Line(B+10,Y+45,B+20,Y+25);
Draw_Circle(B+10,Y+55,10,Black,True);
Vida:=Vida-10;
end if;
end Evaluar_Si_Ferit_Esquerra;
begin
while not Sortir loop
Menu_Seleccio(K,Ia,Ia1,Sortir);
if ia then
Inicialitzacio;
Dibuixar_Vida(Vida1,Vida2);
X:=100;
Y:=110;
Y1:=110;
X1:=480;
Guanyador:=False;
Dibuix_Personatge_Aturat(X,Y);
Dibuix_Personatge_Aturat(X1,Y1);
while not Guanyador loop
K:=Get_Key;
if K='a' then
Moure_Esquerra(X,Y);
Efecte_Gravetat(X,Y);
elsif K='d' then
Moure_Dreta(X,Y);
Efecte_Gravetat(X,Y);
elsif K='q' then
Bot_Esquerra(X,Y,X,Y);
delay 0.05;
Efecte_Gravetat(X,Y);
elsif K='e' then
Bot_Dreta(X,Y,X,Y);
delay 0.05;
Efecte_Gravetat(X,Y);
elsif K='w' then
Cop_De_Puny_Dret(X,Y);
Evaluar_Si_Ferit_Dreta(X,X1,Y,Y1,Vida2);
Dibuixar_Vida(Vida1,Vida2);
Efecte_Gravetat(X1,Y1);
elsif K='s' then
Cop_De_Puny_Esquerre(X,Y);
Evaluar_Si_Ferit_Esquerra(X,X1,Y,Y1,Vida2);
Dibuixar_Vida(Vida1,Vida2);
Efecte_Gravetat(X1,Y1);
end if;
while not key_hit and not guanyador loop
Put_Pixel(1,1,Random_Color);
Color:=Get_Pixel(1,1);
if (X1-X)>20 and (color=black or color=blue or color=green or color=cyan or color=red or color=magenta or color=brown or color=light_gray or color=dark_gray) then
Moure_Esquerra(X1,Y1);
Efecte_Gravetat(X1,Y1);
elsif (X1-X)>20 and (Color=Light_Blue or Color=Light_Green or Color=Light_Cyan or Color=Light_Red) then
Bot_Esquerra(X1,Y1,X1,Y1);
delay 0.05;
Efecte_Gravetat(X1,Y1);
elsif (X1-X)>20 and (Color=Light_Magenta or Color=Yellow or Color=White)then
null;
end if;
if (X-X1)>20 and (color=black or color=blue or color=green or color=cyan or color=red or color=magenta or color=brown or color=light_gray or color=dark_gray) then
Moure_Dreta(X1,Y1);
Efecte_Gravetat(X1,Y1);
elsif (X-X1)>20 and (Color=Light_Blue or Color=Light_Green or Color=Light_Cyan or Color=Light_Red) then
Bot_Dreta(X1,Y1,X1,Y1);
delay 0.05;
Efecte_Gravetat(X1,Y1);
elsif (X-X1)>20 and (Color=Light_Magenta or Color=Yellow or Color=White) then
null;
end if;
if (X1-X)=20 and (color=black or color=blue or color=green or color=cyan or color=red or color=magenta or color=brown or color=light_gray) then
Cop_De_Puny_Esquerre(X1,Y1);
Evaluar_Si_Ferit_Esquerra(X1,X,Y,Y1,Vida1);
Dibuixar_Vida(Vida1,Vida2);
Efecte_Gravetat(X,Y);
elsif (X1-X)=20 and (Color=Light_Blue or Color=Light_Green or Color=Light_Cyan) then
Moure_Esquerra(X1,Y1);
Efecte_Gravetat(X1,Y1);
elsif (X1-X)=20 and (Color=Light_Magenta or Color=Yellow or Color=White) then
Moure_Dreta(X1,Y1);
Efecte_Gravetat(X1,Y1);
elsif (X1-X)=20 and (Color=Dark_Gray or Color=Light_Red) then
null;
end if;
if (X1-X)=-20 and (color=black or color=blue or color=green or color=cyan or color=red or color=magenta or color=brown or color=light_gray) then
Cop_De_Puny_Dret(X1,Y1);
Evaluar_Si_Ferit_Dreta(X1,X,Y,Y1,Vida1);
Dibuixar_Vida(Vida1,Vida2);
Efecte_Gravetat(X,Y);
elsif (X1-X)=-20 and (Color=Light_Blue or Color=Light_Green or Color=Light_Cyan) then
Moure_Dreta(X1,Y1);
Efecte_Gravetat(X1,Y1);
elsif (X1-X)=-20 and (Color=Light_Magenta or Color=Yellow or Color=White) then
Moure_Esquerra(X1,Y1);
Efecte_Gravetat(X1,Y1);
elsif (X1-X)=-20 and (Color=Dark_Gray or Color=Light_Red) then
null;
end if;
if X=X1 and (color=black or color=blue or color=green or color=cyan or color=red or color=magenta or color=brown or color=light_gray or color=dark_gray) then
Bot_Esquerra(X1,Y1,X1,Y1);
delay 0.05;
Efecte_Gravetat(X1,Y1);
elsif X=X1 and (Color=Light_Blue or Color=Light_Green or Color=Light_Cyan or Color=Light_Red or Color=Light_Magenta or Color=Yellow or Color=White) then
Bot_Dreta(X1,Y1,X1,Y1);
delay 0.05;
Efecte_Gravetat(X1,Y1);
end if;
if Y=0 or Y1=0 or Vida1<=0 or Vida2<=0 then
Guanyador:=True;
end if;
end loop;
end loop;
elsif ia1 then
Inicialitzacio;
Dibuixar_Vida(Vida1,Vida2);
X:=100;
Y:=110;
Y1:=110;
X1:=480;
Guanyador:=False;
Dibuix_Personatge_Aturat(X,Y);
Dibuix_Personatge_Aturat(X1,Y1);
while not Guanyador loop
K:=Get_Key;
if K='a' then
Moure_Esquerra(X,Y);
Efecte_Gravetat(X,Y);
elsif K='d' then
Moure_Dreta(X,Y);
Efecte_Gravetat(X,Y);
elsif K='q' then
Bot_Esquerra(X,Y,X,Y);
delay 0.05;
Efecte_Gravetat(X,Y);
elsif K='e' then
Bot_Dreta(X,Y,X,Y);
delay 0.05;
Efecte_Gravetat(X,Y);
elsif K='w' then
Cop_De_Puny_Dret(X,Y);
Evaluar_Si_Ferit_Dreta(X,X1,Y,Y1,Vida2);
Dibuixar_Vida(Vida1,Vida2);
Efecte_Gravetat(X1,Y1);
elsif K='s' then
Cop_De_Puny_Esquerre(X,Y);
Evaluar_Si_Ferit_Esquerra(X,X1,Y,Y1,Vida2);
Dibuixar_Vida(Vida1,Vida2);
Efecte_Gravetat(X1,Y1);
end if;
while not key_hit and not guanyador loop
Put_Pixel(1,1,Random_Color);
Color:=Get_Pixel(1,1);
if (X1-X)>20 and (color=black or color=blue or color=green or color=cyan or color=red or color=magenta or color=brown or color=light_gray or color=dark_gray) then
Moure_Esquerra(X1,Y1);
Efecte_Gravetat(X1,Y1);
elsif (X1-X)>20 and (Color=Light_Blue or Color=Light_Green or Color=Light_Cyan or Color=Light_Red) then
Bot_Esquerra(X1,Y1,X1,Y1);
delay 0.05;
Efecte_Gravetat(X1,Y1);
elsif (X1-X)>20 and (Color=Light_Magenta or Color=Yellow or Color=White)then
null;
end if;
if (X-X1)>20 and (color=black or color=blue or color=green or color=cyan or color=red or color=magenta or color=brown or color=light_gray or color=dark_gray) then
Moure_Dreta(X1,Y1);
Efecte_Gravetat(X1,Y1);
elsif (X-X1)>20 and (Color=Light_Blue or Color=Light_Green or Color=Light_Cyan or Color=Light_Red) then
Bot_Dreta(X1,Y1,X1,Y1);
delay 0.05;
Efecte_Gravetat(X1,Y1);
elsif (X-X1)>20 and (Color=Light_Magenta or Color=Yellow or Color=White) then
null;
end if;
if (X1-X)=20 and (color=black or color=blue or color=green or color=cyan) then
Cop_De_Puny_Esquerre(X1,Y1);
Evaluar_Si_Ferit_Esquerra(X1,X,Y,Y1,Vida1);
Dibuixar_Vida(Vida1,Vida2);
Efecte_Gravetat(X,Y);
elsif (X1-X)=20 and (Color=Light_Blue or Color=Light_Green or Color=Light_Cyan) then
Moure_Esquerra(X1,Y1);
Efecte_Gravetat(X1,Y1);
elsif (X1-X)=20 and (Color=Light_Magenta or Color=Yellow or Color=White) then
Moure_Dreta(X1,Y1);
Efecte_Gravetat(X1,Y1);
elsif (X1-X)=20 and (Color=Brown or Color=Light_Gray or Color=Dark_Gray or Color=Light_Red or Color=Red or Color=Magenta) then
null;
end if;
if (X1-X)=-20 and (color=black or color=blue or color=green or color=cyan) then
Cop_De_Puny_Dret(X1,Y1);
Evaluar_Si_Ferit_Dreta(X1,X,Y,Y1,Vida1);
Dibuixar_Vida(Vida1,Vida2);
Efecte_Gravetat(X,Y);
elsif (X1-X)=-20 and (Color=Light_Blue or Color=Light_Green or Color=Light_Cyan) then
Moure_Dreta(X1,Y1);
Efecte_Gravetat(X1,Y1);
elsif (X1-X)=-20 and (Color=Light_Magenta or Color=Yellow or Color=White) then
Moure_Esquerra(X1,Y1);
Efecte_Gravetat(X1,Y1);
elsif (X1-X)=20 and (Color=Brown or Color=Light_Gray or Color=Dark_Gray or Color=Light_Red or Color=Red or Color=Magenta) then
null;
end if;
if X=X1 and (color=black or color=blue or color=green or color=cyan or color=brown or color=light_gray or color=dark_gray) then
Bot_Esquerra(X1,Y1,X1,Y1);
delay 0.05;
Efecte_Gravetat(X1,Y1);
elsif X=X1 and (Color=Light_Blue or Color=Light_Green or Color=Light_Cyan or Color=Light_Red or Color=Light_Magenta or Color=Yellow or Color=White or color=red or color=magenta) then
Bot_Dreta(X1,Y1,X1,Y1);
delay 0.05;
Efecte_Gravetat(X1,Y1);
end if;
if Y=0 or Y1=0 or Vida1<=0 or Vida2<=0 then
Guanyador:=True;
end if;
end loop;
end loop;
elsif K=' ' then
Inicialitzacio;
Dibuixar_Vida(Vida1,Vida2);
X:=100;
Y:=110;
Y1:=110;
X1:=480;
Guanyador:=False;
Dibuix_Personatge_Aturat(X,Y);
Dibuix_Personatge_Aturat(X1,Y1);
while not Guanyador loop
K:=Get_Key;
if K='a' then
Moure_Esquerra(X,Y);
Efecte_Gravetat(X,Y);
elsif K='d' then
Moure_Dreta(X,Y);
Efecte_Gravetat(X,Y);
elsif K='q' then
Bot_Esquerra(X,Y,X,Y);
delay 0.05;
Efecte_Gravetat(X,Y);
elsif K='e' then
Bot_Dreta(X,Y,X,Y);
delay 0.05;
Efecte_Gravetat(X,Y);
elsif K='w' then
Cop_De_Puny_Dret(X,Y);
Evaluar_Si_Ferit_Dreta(X,X1,Y,Y1,Vida2);
Dibuixar_Vida(Vida1,Vida2);
Efecte_Gravetat(X1,Y1);
elsif K='s' then
Cop_De_Puny_Esquerre(X,Y);
Evaluar_Si_Ferit_Esquerra(X,X1,Y,Y1,Vida2);
Dibuixar_Vida(Vida1,Vida2);
Efecte_Gravetat(X1,Y1);
end if;
if K='j' then
Moure_Esquerra(X1,Y1);
Efecte_Gravetat(X1,Y1);
elsif K='l' then
Moure_Dreta(X1,Y1);
Efecte_Gravetat(X1,Y1);
elsif K='u' then
Bot_Esquerra(X1,Y1,X1,Y1);
delay 0.05;
Efecte_Gravetat(X1,Y1);
elsif K='o' then
Bot_Dreta(X1,Y1,X1,Y1);
delay 0.05;
Efecte_Gravetat(X1,Y1);
elsif K='i' then
Cop_De_Puny_Dret(X1,Y1);
Evaluar_Si_Ferit_Dreta(X1,X,Y,Y1,Vida1);
Dibuixar_Vida(Vida1,Vida2);
Efecte_Gravetat(X,Y);
elsif K='k' then
Cop_De_Puny_Esquerre(X1,Y1);
Evaluar_Si_Ferit_Esquerra(X1,X,Y,Y1,Vida1);
Dibuixar_Vida(Vida1,Vida2);
Efecte_Gravetat(X,Y);
end if;
if Y=0 or Y1=0 or Vida1<=0 or Vida2<=0 then
Guanyador:=True;
end if;
end loop;
end if;
if Y=0 or Vida1<=0 then
if Vida1<=0 then
Draw_Circle(X+10,Y+40,30,Red,True);
end if;
Display_Text(100,260,"GUANYADOR EL JUGADOR 2",Red);
else
if Vida2<=0 then
Draw_Circle(X1+10,Y1+40,15,Red,True);
end if;
Display_Text(100,260,"GUANYADOR EL JUGADOR 1",Red);
end if;
Vida1:=100;
Vida2:=100;
delay 3.0;
if not Sortir then
Close_Graph_Window;
end if;
end loop;
end super_smash;
No hay comentarios:
Publicar un comentario