-------------------------------
--Juego del Avioncito Matador--
-------------------------------
--Posterior a la Segunda Guerra Mundial, los judios, aprovechando
--que Hitler esta muerto, vuelven a fortalecerse y armarse.
--Usted como buen nazi, debera darles su merecido y evitar que se multipliquen
--atacando a los inocentes hogares de Alemania.
with Adagraph;
use Adagraph;
with Ada.Numerics.Discrete_Random;
use Ada.Numerics;
-------------------------------
--Juego del Avioncito Matador--
-------------------------------
--Posterior a la Segunda Guerra Mundial, los judios, aprovechando
--que Hitler esta muerto, vuelven a fortalecerse y armarse.
--Usted como buen nazi, debera darles su merecido y evitar que se multipliquen
--atacando a los inocentes hogares de Alemania.
--Mover con Left, Right, disparar con letra ´n´.
procedure Avioncitomatador is
X_Max,
Y_Max : Integer := 0;
X_Char,
Y_Char : Integer := 0;
Tecla : Character;
Dir : Character := Vk_Left;
Nrovidas : Integer := 3;
NroMatanzas : Integer := 0;
NroCaidas : Integer := 0;
Nivel : Integer := 1;
X_Avioncito,
Y_Avioncito : Integer := 40 ;
X_Bicho1 : Integer := 40;
Y_Bicho1 : Integer := 1030;
X_Bicho2 : Integer := 70;
Y_Bicho2 : Integer := 1010;
X_Bicho3 : Integer := 20;
Y_Bicho3 : Integer := 1010;
X_Bicho4 : Integer := 45;
Y_Bicho4 : Integer := 1010;
X_Bicho5 : Integer := 330;
Y_Bicho5 : Integer := 1010;
-- Setea el valor de nivel de dificultad, nro de matanzas necesarias para ganar
Nivel_de_Dificultad : Integer := 10;
MetralletaVisible : Boolean := False;
Gano : Boolean := False;
Salir : Boolean := False;
SalirCualquierMomento : Boolean := False;
procedure Ventana is
begin
Get_Max_Size(X_Max, Y_Max);
Create_Graph_Window(
X_Max ,
Y_Max ,
X_Char ,
Y_Char );
end Ventana ;
procedure Dibujar_Edificios is
begin
Draw_Box(0, 0, 40, 35 , White,True);
Draw_Box(40, 0, 75, 55 , Red,True);
Draw_Box(75, 0, 90, 70 , Green,True);
Draw_Box(90, 0, 240, 55 , White,True);
Draw_Box(130, 30, 190, 35 , Red,True);
Draw_Box(130, 30, 135, 50 , Red,True);
Draw_Box(185, 30, 190, 10 , Red,True);
Draw_Box(155, 10, 160, 50 , Red,True);
Draw_Box(155, 10, 135, 15 , Red,True);
Draw_Box(155, 50, 190, 45 , Red,True);
Draw_Box(240, 0, 300, 20 , Blue,True);
Draw_Box(300, 0, 340, 45 , Yellow,True);
Draw_Box(340, 0, 440, 20 , Light_Blue,True);
Draw_Box(440, 0, 467, 36 , Red,True);
Draw_Box(467, 0, 600, 44 , Magenta,True);
Draw_Box(600, 0, 640, 58 , Green,True);
Draw_Box(640, 0, 670, 39 , Brown,True);
Draw_Box(670, 0, 800, 60 , Light_Gray,True);
end Dibujar_Edificios;
procedure Inicializar is
begin
Ventana;
X_Avioncito:=30;
Y_Avioncito:=80;
Dibujar_Edificios;
end Inicializar;
function Generar_Numero_Aleatorio (
Minvalue : Integer;
Maxvalue : Integer )
return Integer is
subtype Random_Type is Integer range Minvalue .. Maxvalue;
package Random_Pack is new Ada.Numerics.Discrete_Random (
Random_Type);
G : Random_Pack.Generator;
begin
Random_Pack.Reset (G);
return Random_Pack.Random (G);
end Generar_Numero_Aleatorio;
procedure Mostrar_Cuadro is
begin
if (Gano=True) then
Draw_Box((X_Max/2)-150,(Y_Max/2)+80,(X_Max/2)+150,(Y_Max/2)-80,
Blue,True);
Display_Text((X_Max/2)-(X_Char*6)-80,(Y_Max/2)+(Y_Char*3),
"OH SI!! GANASTE MATADOR!!!",Yellow);
Display_Text((X_Max/2)-(X_Char*6)-107,(Y_Max/2)+(Y_Char*3) - 20,
" LOGRASTE MATAR A TODOS ESOS JUDIOS!",Yellow);
Display_Text((X_Max/2)-(X_Char*15),(Y_Max/2)-Y_Char,
"PRESIONA TECLA 's' PARA SALIR",Yellow);
end if;
if (Gano=False) then
Draw_Box((X_Max/2)-150,(Y_Max/2)+80,(X_Max/2)+150,(Y_Max/2)-80,
White,True);
Display_Text((X_Max/2)-(X_Char*6)-70,(Y_Max/2)+(Y_Char*3),
"DIOS SANTO! PERDISTE AVIONCITO!!!",Red);
if (NroVidas = 0) then
Display_Text((X_Max/2)-(X_Char*6)-80,(Y_Max/2)+(Y_Char*3) - 20,
" TE MATARON POR COBARDE!!",Red);
end if;
if (NroVidas > 0) then
Display_Text((X_Max/2)-(X_Char*6)-110,(Y_Max/2)+(Y_Char*3) - 20,
" DESTRUYERON LOS HOGARES DE TU CIUDAD!",Red);
end if;
Display_Text((X_Max/2)-(X_Char*15) -20,(Y_Max/2)-Y_Char,
"PRESIONA TECLA 's' PARA SALIR",Red);
end if;
end Mostrar_Cuadro;
procedure ReiniciarEnemigo1 is
begin
Draw_Box(0, 80, 1200, 900, Black, True);
X_Bicho1 := Generar_Numero_Aleatorio (
Minvalue => 5,
Maxvalue => 200);
Y_Bicho1 := 600;
end ReiniciarEnemigo1;
procedure ReiniciarEnemigo2 is
begin
Draw_Box(0, 80, 1200, 900, Black, True);
X_Bicho2 := Generar_Numero_Aleatorio (
Minvalue => 4,
Maxvalue => 200);
Y_Bicho2 := 800;
end ReiniciarEnemigo2;
procedure ReiniciarEnemigo3 is
begin
Draw_Box(0, 80, 1200, 900, Black, True);
X_Bicho3 := Generar_Numero_Aleatorio (
Minvalue => 20,
Maxvalue => 200);
Y_Bicho3 := 1000;
end Reiniciarenemigo3;
procedure ReiniciarEnemigo4 is
begin
Draw_Box(0, 80, 1200, 900, Black, True);
X_Bicho4 := Generar_Numero_Aleatorio (
Minvalue => 10,
Maxvalue => 200);
Y_Bicho4 := 750;
end Reiniciarenemigo4;
procedure ReiniciarEnemigo5 is
begin
Draw_Box(0, 80, 1200, 900, Black, True);
X_Bicho5 := Generar_Numero_Aleatorio (
Minvalue => 50,
Maxvalue => 200);
Y_Bicho5 := 1300;
end ReiniciarEnemigo5;
procedure Dibujar_Vidas is
begin
Display_Text(450,400,"Numero de Vidas: " & Integer'Image(Nrovidas) ,
Green);
end Dibujar_Vidas;
procedure Dibujar_Nivel is
begin
Display_Text(450,420,"Nivel: " & Integer'Image(Nivel) ,
Green);
end Dibujar_Nivel;
procedure Dibujar_Matanzas is
begin
Display_Text(450,380,"Numero de enemigos matados: " & Integer'Image(NroMatanzas) ,
Cyan);
end Dibujar_Matanzas;
procedure Dibujar_Caidas is
begin
Display_Text(450,360,"Tus hogares destruidos ;( : " & Integer'Image(Nrocaidas) ,
Light_Blue);
end Dibujar_Caidas;
procedure Mato_Enemigo is
begin
NroMatanzas := NroMatanzas +1;
if (NroMatanzas = Nivel_de_Dificultad) then
Gano:=True;
Salir:=True;
end if;
end Mato_Enemigo;
procedure Dibujaravion (
Colorusado : in Extended_Color_Type ) is
begin
Draw_Line(X_Avioncito , Y_Avioncito, X_Avioncito+30, Y_Avioncito, Colorusado , True);
Draw_Line(X_Avioncito +30 , Y_Avioncito, X_Avioncito+15, Y_Avioncito + 20, Colorusado , True);
Draw_Line(X_Avioncito , Y_Avioncito, X_Avioncito+15, Y_Avioncito +20, Colorusado , True);
Draw_Circle(X_Avioncito + 15 , Y_Avioncito+8, 5, Colorusado , True);
Draw_Box(X_Avioncito + 12 , Y_Avioncito,X_Avioncito + 18 ,Y_Avioncito-5, Colorusado , True);
if (MetralletaVisible = True) then
Draw_Box(X_Avioncito + 15 , Y_Avioncito +21, X_Avioncito+15 + 5, 600, Cyan , True);
if (X_Avioncito + 15 >= X_Bicho1 and X_Avioncito+15 + 5 <= X_Bicho1 +30 ) then ReiniciarEnemigo1; Mato_Enemigo; end if;
if (X_Avioncito + 15 >= X_Bicho2-10 and X_Avioncito+15 + 5 <= X_Bicho2 +10 ) then ReiniciarEnemigo2; Mato_Enemigo; end if;
if (X_Avioncito + 15 >= X_Bicho3-10 and X_Avioncito+15 + 5 <= X_Bicho3 +10 ) then ReiniciarEnemigo3; Mato_Enemigo; end if;
if (X_Avioncito >= X_Bicho4-15 and X_Avioncito + 15 <= X_Bicho4 +15 ) then ReiniciarEnemigo4; Mato_Enemigo; end if;
if (X_Avioncito + 15 >= X_Bicho5-10 and X_Avioncito + 15 + 5 <= X_Bicho5 +10 ) then ReiniciarEnemigo5; Mato_Enemigo; end if;
MetralletaVisible := False;
end if;
end Dibujaravion;
procedure DibujarEnemigo1 (
Colorusado : in Extended_Color_Type ) is
begin
Draw_Line(X_Bicho1 , Y_Bicho1, X_Bicho1+30, Y_Bicho1, Colorusado , True);
Draw_Line(X_Bicho1 +30 , Y_Bicho1, X_Bicho1+15, Y_Bicho1 - 20, Colorusado , True);
Draw_Line(X_Bicho1 , Y_Bicho1, X_Bicho1+15, Y_Bicho1 -20, Colorusado , True);
Draw_Circle(X_Bicho1 + 15 , Y_Bicho1+8, 5, Colorusado , True);
Draw_Box(X_Bicho1 + 12 , Y_Bicho1,X_Bicho1 + 18 ,Y_Bicho1-5, Colorusado , True);
Draw_Circle(X_Bicho1 + 15 , Y_Bicho1, 5, White , True);
end DibujarEnemigo1;
procedure DibujarEnemigo2 (
Colorusado1 : in Extended_Color_Type; Colorusado2 : in Extended_Color_Type ) is
begin
Draw_Circle(X_Bicho2, Y_Bicho2, 10,Colorusado1 ,True);
Draw_Circle(X_Bicho2 -5, Y_Bicho2, 2,Colorusado2 ,True);
Draw_Circle(X_Bicho2+5, Y_Bicho2, 2,Colorusado2 ,True);
Draw_Box(X_Bicho2-2, Y_Bicho2-5, X_Bicho2+2, Y_Bicho2-3 , Colorusado2 ,True);
end DibujarEnemigo2;
procedure DibujarEnemigo3 (
Colorusado1 : in Extended_Color_Type; Colorusado2 : in Extended_Color_Type ) is
begin
Draw_Circle(X_Bicho3, Y_Bicho3, 10,Colorusado1 ,True);
Draw_Circle(X_Bicho3 -5, Y_Bicho3, 2,Colorusado2 ,True);
Draw_Circle(X_Bicho3+5, Y_Bicho3, 2,Colorusado2 ,True);
Draw_Box(X_Bicho3-2, Y_Bicho3-5, X_Bicho3+2, Y_Bicho3-3 , Colorusado2 ,True);
end DibujarEnemigo3;
procedure DibujarEnemigo4 (
Colorusado1 : in Extended_Color_Type; Colorusado2 : in Extended_Color_Type ) is
begin
Draw_Box(X_Bicho4, Y_Bicho4, X_Bicho4 + 10, Y_Bicho4 + 10, Colorusado1 ,True);
Draw_Circle(X_Bicho4 +2, Y_Bicho4, 2,Colorusado2 ,True);
Draw_Circle(X_Bicho4+ 5, Y_Bicho4, 2,Colorusado2 ,True);
Draw_Box(X_Bicho4+2, Y_Bicho4-5, X_Bicho4+6, Y_Bicho4-3 , Colorusado2 ,True);
end DibujarEnemigo4;
procedure DibujarEnemigo5 (
Colorusado1 : in Extended_Color_Type; Colorusado2 : in Extended_Color_Type ) is
begin
Draw_Circle(X_Bicho5, Y_Bicho5, 10,Colorusado1 ,True);
Draw_Circle(X_Bicho5 -5, Y_Bicho5, 2,Colorusado2 ,True);
Draw_Circle(X_Bicho5+5, Y_Bicho5, 2,Colorusado2 ,True);
Draw_Box(X_Bicho5-2, Y_Bicho5-5, X_Bicho5+2, Y_Bicho5-3 , Colorusado2 ,True);
end DibujarEnemigo5;
procedure Reiniciarenemigos is
begin
Clear_Window(Hue => Black);
Dibujar_Edificios;
ReiniciarEnemigo1;
ReiniciarEnemigo2;
ReiniciarEnemigo3;
ReiniciarEnemigo4;
ReiniciarEnemigo5;
end Reiniciarenemigos;
procedure Dibujarnave (
Tecla : in Character ) is
begin
Dibujaravion(Black);
Draw_Line(X_Avioncito + 15 , Y_Avioncito +21, X_Avioncito+15, 400, Black , True);
if Tecla =Vk_Right then
X_Avioncito:=X_Avioncito+10;
end if;
if Tecla =Vk_Left then
X_Avioncito:=X_Avioncito-10;
end if;
if Tecla ='n' then
MetralletaVisible:=True;
end if;
Dibujaravion(Yellow);
if (X_Avioncito+10>=X_Bicho1 and X_Avioncito+10<=(X_Bicho1+15) and Y_Avioncito>=
Y_Bicho1 and Y_Avioncito <= (Y_Bicho1 +15)) then
Nrovidas := Nrovidas - 1;
Reiniciarenemigos;
end if;
if (X_Avioncito+10>=X_Bicho2 and X_Avioncito+10<=(X_Bicho2+15) and Y_Avioncito>=
Y_Bicho2 and Y_Avioncito <= (Y_Bicho2 +15)) then
Nrovidas := Nrovidas - 1;
Reiniciarenemigos;
end if;
if (X_Avioncito+10>=X_Bicho3 and X_Avioncito+10<=(X_Bicho3+15) and Y_Avioncito>=
Y_Bicho3 and Y_Avioncito <= (Y_Bicho3 +15)) then
Nrovidas := Nrovidas - 1;
Reiniciarenemigos;
end if;
if (X_Avioncito+10>=X_Bicho4 and X_Avioncito+10<=(X_Bicho4+15) and Y_Avioncito>=
Y_Bicho4 and Y_Avioncito <= (Y_Bicho4 +15)) then
Nrovidas := Nrovidas - 1;
Reiniciarenemigos;
end if;
if (X_Avioncito+10>=X_Bicho5 and X_Avioncito+10<=(X_Bicho5+15) and Y_Avioncito>=
Y_Bicho5 and Y_Avioncito <= (Y_Bicho5 +15)) then
Nrovidas := Nrovidas - 1;
Reiniciarenemigos;
end if;
if (Nrovidas=0) then
Dibujar_Vidas;
Gano:=False;
Salir:=True;
end if;
end Dibujarnave;
procedure Dibujarbala is
begin
delay(0.01);
--re pintamos de negro los enemigos para evitar barrido
Dibujarenemigo1(Black);
Dibujarenemigo2(Black,Black);
Dibujarenemigo3(Black,Black);
Dibujarenemigo4(Black,Black);
Dibujarenemigo5(Black,Black);
--repintamos la metralleta de negro para ocultarla
Draw_Box(X_Avioncito + 15 , Y_Avioncito +21, X_Avioncito+15 + 5, 600, Black, True);
-- dibujamos al avioncito matador
Dibujaravion(Yellow);
if (X_Avioncito > 600) then
X_Avioncito :=0;
Reiniciarenemigos;
end if;
delay(0.01);
if (Y_Bicho1< 20 ) then
Y_Bicho1 := 600;
Nrocaidas := Nrocaidas+1;
X_Bicho1 := Generar_Numero_Aleatorio (
Minvalue => 5,
Maxvalue => 400);
end if;
if (Y_Bicho2< 20 ) then
Y_Bicho2 := 800;
Nrocaidas := Nrocaidas+1;
X_Bicho2 := Generar_Numero_Aleatorio (
Minvalue => 40,
Maxvalue => 480);
end if;
if (Y_Bicho3< 20 ) then
Y_Bicho3 := 1200;
Nrocaidas := Nrocaidas+1;
X_Bicho3 := Generar_Numero_Aleatorio (
Minvalue => 100,
Maxvalue => 300);
end if;
if (Y_Bicho4< 20 ) then
Y_Bicho4 := 900;
Nrocaidas := Nrocaidas+1;
X_Bicho4 := Generar_Numero_Aleatorio (
Minvalue => 55,
Maxvalue => 380);
end if;
if (Y_Bicho5< 20 ) then
Y_Bicho5 := 800;
Nrocaidas := Nrocaidas+1;
X_Bicho5 := Generar_Numero_Aleatorio (
Minvalue => 10,
Maxvalue => 500);
end if;
if (Nrocaidas= 6) then
Gano:=False;
Salir:=True;
end if;
Y_Bicho1:= Y_Bicho1 - 5;
Y_Bicho2:= Y_Bicho2 - 4;
Y_Bicho3:= Y_Bicho3- 2;
Y_Bicho4:= Y_Bicho4- 1;
Y_Bicho5:= Y_Bicho5- 3;
--dibujamos los enemigos
Dibujarenemigo1(Light_Red);
Dibujarenemigo2(Cyan,Red);
Dibujarenemigo3(Green,Magenta);
Dibujarenemigo4(Light_Red,White);
Dibujarenemigo5(Green,Yellow);
end Dibujarbala;
procedure JugarNivel1 is
begin
Tecla:=Vk_Nul;
loop
Dibujarnave(Vk_Nul);
Dibujar_Vidas;
Dibujar_Matanzas;
Dibujar_Caidas;
Dibujar_Nivel;
Dibujarbala;
Dibujarnave(Vk_Nul);
if (Key_Hit) then
Tecla:=Get_Key;
if Tecla=Vk_Left or Tecla=Vk_Right or Tecla='n' then
Dir:=Tecla;
Dibujarnave(Dir);
end if;
if Tecla='q' then
SalirCualquierMomento:=True;
end if;
end if;
exit when Salir=True or SalirCualquierMomento=True;
end loop;
end JugarNivel1;
procedure JugarNivel2 is
begin
Tecla:=Vk_Nul;
loop
Dibujarnave(Vk_Nul);
Dibujar_Vidas;
Dibujar_Matanzas;
Dibujar_Caidas;
Dibujar_Nivel;
Dibujarbala;
Dibujarnave(Vk_Nul);
if (Key_Hit) then
Tecla:=Get_Key;
if Tecla=Vk_Left or Tecla=Vk_Right or Tecla='n' then
Dir:=Tecla;
Dibujarnave(Dir);
end if;
if Tecla='q' then
SalirCualquierMomento:=True;
end if;
end if;
exit when Salir=True or SalirCualquierMomento=True;
end loop;
end JugarNivel2;
procedure JugarNivel3 is
begin
Tecla:=Vk_Nul;
loop
Dibujarnave(Vk_Nul);
Dibujar_Vidas;
Dibujar_Matanzas;
Dibujar_Caidas;
Dibujar_Nivel;
Dibujarbala;
Dibujarnave(Vk_Nul);
if (Key_Hit) then
Tecla:=Get_Key;
if Tecla=Vk_Left or Tecla=Vk_Right or Tecla='n' then
Dir:=Tecla;
Dibujarnave(Dir);
end if;
if Tecla='q' then
SalirCualquierMomento:=True;
end if;
end if;
exit when Salir=True or SalirCualquierMomento=True;
end loop;
if (Salir=True) then
Mostrar_Cuadro;
end if;
end JugarNivel3;
procedure Esperartecla is
begin
Salir := False;
loop
if (Key_Hit) then
Tecla:=Get_Key;
if Tecla='s' then
Salir:=True;
end if;
end if;
exit when Salir=True;
end loop;
end Esperartecla ;
begin
Inicializar;
JugarNivel1;
Salir:=False;
Nivel_De_Dificultad:=20;
NroMatanzas := 0;
Nivel :=2;
JugarNivel2;
Salir:=False;
NroMatanzas := 0;
Nivel_De_Dificultad:=30;
Nivel :=3;
Jugarnivel3;
if (Salir=True) then
Esperartecla;
Tecla:= Get_Key;
end if;
-------------------------------
--Juego del Avioncito Matador--
-------------------------------
--Posterior a la Segunda Guerra Mundial, los judios, aprovechando
--que Hitler esta muerto, vuelven a fortalecerse y armarse.
--Usted como buen nazi, debera darles su merecido y evitar que se multipliquen
--atacando a los inocentes hogares de Alemania.
--Mover con Left, Right, disparar con letra ´n´.
end Avioncitomatador ;
No hay comentarios:
Publicar un comentario