-- Demonios, existe escasez de azucar en la patria. Usted, un afamado
-- contrabandista, debera robar unos buenos quintales del Peru y meterlos
-- en su auto rojo Formula-1 y escapar a Bolivia, asi sus compatriotas
-- podran endulzar sus tecitos y refrescos hervidos. Animo patriota !!
with Adagraph;
use Adagraph;
with Ada.Numerics.Discrete_Random;
use Ada.Numerics;
-- Demonios, existe escasez de azucar en la patria. Usted, un afamado
-- contrabandista, debera robar unos buenos quintales del Peru y meterlos
-- en su auto rojo Formula-1 y escapar a Bolivia, asi sus compatriotas
-- podran endulzar sus tecitos y refrescos hervidos. Animo patriota !!
procedure ladronesDeAzucar is
X_Max,
Y_Max : Integer := 0;
X_Char,
Y_Char : Integer := 0;
Tecla : Character;
Dir : Character := Vk_Left;
Nrovidas : Integer := 3;
Azucar_Quintales : Integer := 0;
ColorCarretera : Extended_Color_Type := Green;
ColorLineasCarretera : Extended_Color_Type := Yellow;
X_Personaje,
Y_Personaje : Integer := 1;
X_Personaje_Estacionado,
Y_Personaje_Estacionado: Integer := 1;
X_Cosa1 : Integer := 40;
Y_Cosa1 : Integer :=30;
X_Cosa2 : Integer := 70;
Y_Cosa2 : Integer := 10;
X_Cosa3 : Integer := 20;
Y_Cosa3 : Integer := 10;
X_Cosa4 : Integer := 45;
Y_Cosa4 : Integer := 10;
X_Cosa5 : Integer := 30;
Y_Cosa5 : Integer := 10;
contadorKM : Integer :=210;
NivelDelJuego : Integer :=1;
Ganar : Boolean := False;
Salir : 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 Inicializar is
begin
Ventana;
X_Personaje:=30;
Y_Personaje:=20;
end Inicializar;
--pagina 172 de Ada_Programming.pdf para generar numeros aleatorios
function Generate_Number (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 Generate_Number;
procedure Dibujar_Mensaje_Final is
begin
if (Ganar=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)-30,(Y_Max/2)+(Y_Char*3),"JOJOJO!! GANASTE!!!",Yellow);
Display_Text((X_Max/2)-(X_Char*6)-70,(Y_Max/2)+(Y_Char*3) - 20,"LOGRASTE CONTRABANDEAR LA AZUCAR!!",Yellow);
Display_Text((X_Max/2)-(X_Char*15),(Y_Max/2)-Y_Char,"APRETA LA TECLA 'q' PARA SALIR",Yellow);
end if;
if (Ganar=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),"CARAMBA! PERDISTE BROTHER!!!",Red);
Display_Text((X_Max/2)-(X_Char*6)-80,(Y_Max/2)+(Y_Char*3) - 20," TE MATARON POR CONTRABANDISTA!!",Red);
Display_Text((X_Max/2)-(X_Char*15),(Y_Max/2)-Y_Char,"APRETA LA TECLA 'q' PARA SALIR",Red);
end if;
end Dibujar_Mensaje_Final;
procedure Dibujar_Vidas is
begin
Draw_Box(400, 100, 600, 200 , Black,True);
Display_Text(400,100,"Tus Vidas: " & integer'image(NroVidas) ,Green);
end Dibujar_Vidas;
procedure Dibujar_Nivel is
begin
Display_Text(400,200,"Nivel del Juego: " & integer'image(NivelDelJuego) ,Green);
end Dibujar_Nivel;
procedure Dibujar_Quintales is
begin
Draw_Box(400, 400, 1000, 450 , Black,True);
Display_Text(400,400,"Quintales de Azucar: " & integer'image( Azucar_Quintales) ,White);
end Dibujar_Quintales;
procedure Dibujar_Km is
begin
Draw_Box(240, 420, 600, 450 , Black,True);
Display_Text(240,420,"Km para llegar a Bolivia: " & integer'image(contadorKM) ,Yellow);
end Dibujar_Km;
procedure Dibujar_Carretera is
begin
Draw_Box(0, 0, 210, 600 , ColorCarretera ,True);
Draw_Box(105, 10, 110, 20 , ColorLineasCarretera,True);
Draw_Box(105, 30, 110, 40 , ColorLineasCarretera,True);
Draw_Box(105, 50, 110, 60 , ColorLineasCarretera,True);
Draw_Box(105, 70, 110, 80 , ColorLineasCarretera,True);
Draw_Box(105, 90, 110, 100 , ColorLineasCarretera,True);
Draw_Box(105, 110, 110, 120 , ColorLineasCarretera,True);
Draw_Box(105, 130, 110, 140 , ColorLineasCarretera,True);
Draw_Box(105, 150, 110, 160 , ColorLineasCarretera,True);
Draw_Box(105, 170, 110, 180 , ColorLineasCarretera,True);
Draw_Box(105, 190, 110, 200 , ColorLineasCarretera,True);
Draw_Box(105, 210, 110, 220 , ColorLineasCarretera,True);
Draw_Box(105, 230, 110, 240 , ColorLineasCarretera,True);
Draw_Box(105, 250, 110, 260 , ColorLineasCarretera,True);
Draw_Box(105, 270, 110, 280 , ColorLineasCarretera,True);
Draw_Box(105, 290, 110, 300 , ColorLineasCarretera,True);
Draw_Box(105, 310, 110, 320 , ColorLineasCarretera,True);
Draw_Box(105, 330, 110, 340 , ColorLineasCarretera,True);
Draw_Box(105, 350, 110, 360 , ColorLineasCarretera,True);
Draw_Box(105, 370, 110, 380 , ColorLineasCarretera,True);
Draw_Box(105, 390, 110, 400 , ColorLineasCarretera,True);
Draw_Box(105, 410, 110, 420 , ColorLineasCarretera,True);
Draw_Box(105, 430, 110, 440 , ColorLineasCarretera,True);
Draw_Box(105, 450, 110, 460 , ColorLineasCarretera,True);
Draw_Box(105, 470, 110, 480 , ColorLineasCarretera,True);
Draw_Box(105, 490, 110, 500 , ColorLineasCarretera,True);
Draw_Box(105, 510, 110, 520 , ColorLineasCarretera,True);
Draw_Box(105, 530, 110, 540 , ColorLineasCarretera,True);
Draw_Box(105, 550, 110, 560 , ColorLineasCarretera,True);
Draw_Box(105, 570, 110, 580 , ColorLineasCarretera,True);
--banderas
--Bolivia
Draw_Box(240, 400, 260, 405 , Green,True);
Draw_Box(240, 405, 260, 410 , Yellow,True);
Draw_Box(240, 410, 260, 415 , Red,True);
--Peru
Draw_Box(240, 60, 260, 55 , White,True);
Draw_Box(240, 55, 260, 50 , Red,True);
Draw_Box(240, 50, 260, 45 , White,True);
end Dibujar_Carretera;
procedure DibujarAuto is
begin
Draw_Box(X_Personaje, Y_Personaje, X_Personaje+20, Y_Personaje+5, Light_Red, True);
Draw_Box(X_Personaje + 5, Y_Personaje, X_Personaje+15, Y_Personaje-15, White, True);
Draw_Box(X_Personaje , Y_Personaje-15, X_Personaje+20, Y_Personaje-40, Light_Red, True);
Draw_Circle(X_Personaje + 10 , Y_Personaje-25, 5, Red, True);
Draw_Box(X_Personaje +7, Y_Personaje-40, X_Personaje+12, Y_Personaje-45, White, True);
Draw_Box(X_Personaje -2, Y_Personaje-45, X_Personaje+22, Y_Personaje-55, Light_Red, True);
end DibujarAuto;
procedure DibujarPersona(ColorUsado : in Extended_Color_Type ; ColorUsadoComedor : in Extended_Color_Type) is
begin
Draw_Circle(X_Personaje , Y_Personaje, 3, ColorUsadoComedor , True);
Draw_Circle(X_Personaje + 10 , Y_Personaje, 5, ColorUsado, True);
Draw_Box(X_Personaje +10 , Y_Personaje-5, X_Personaje+15, Y_Personaje-15, ColorUsado, True);
Draw_Box(X_Personaje +12 , Y_Personaje-15, X_Personaje+15, Y_Personaje-20, ColorUsado, True);
end DibujarPersona;
procedure DibujarAutoEstacionado is
begin
X_Personaje_Estacionado := 400;
Y_Personaje_Estacionado := 100;
Draw_Box(X_Personaje_Estacionado, Y_Personaje_Estacionado, X_Personaje_Estacionado+20, Y_Personaje_Estacionado+5, Light_Red, True);
Draw_Box(X_Personaje_Estacionado + 5, Y_Personaje_Estacionado, X_Personaje_Estacionado+15, Y_Personaje_Estacionado-15, White, True);
Draw_Box(X_Personaje_Estacionado , Y_Personaje_Estacionado-15, X_Personaje_Estacionado+20, Y_Personaje_Estacionado-40, Light_Red, True);
Draw_Circle(X_Personaje_Estacionado+ 10 , Y_Personaje_Estacionado-25, 5, Red, True);
Draw_Box(X_Personaje_Estacionado +7, Y_Personaje_Estacionado-40, X_Personaje_Estacionado+12, Y_Personaje_Estacionado-45, White, True);
Draw_Box(X_Personaje_Estacionado -2, Y_Personaje_Estacionado-45, X_Personaje_Estacionado+22, Y_Personaje_Estacionado-55, Light_Red, True);
end DibujarAutoEstacionado;
procedure DibujarAzucar is
begin
Draw_Box(15, 20, 20, 25, White, True);
Draw_Box(55, 70, 60, 75, White, True);
Draw_Box(115, 40, 120, 45, White, True);
Draw_Box(98, 200, 103, 205, White, True);
Draw_Box(33, 140, 38, 145, White, True);
Draw_Box(35, 120, 40, 125, White, True);
Draw_Box(55, 170, 60, 175, White, True);
Draw_Box(215, 40, 220, 45, White, True);
Draw_Box(48, 200, 53, 205, White, True);
Draw_Box(33, 140, 38, 145, White, True);
Draw_Box(25, 44, 30, 49, White, True);
Draw_Box(55, 70, 60, 75, White, True);
Draw_Box(215, 99, 220, 104, White, True);
Draw_Box(28, 200, 33, 205, White, True);
Draw_Box(23, 160, 28, 165, White, True);
Draw_Box(15, 20, 20, 25, White, True);
Draw_Box(55, 70, 60, 75, White, True);
Draw_Box(115, 40, 120, 45, White, True);
Draw_Box(98, 200, 103, 205, White, True);
Draw_Box(33, 140, 38, 145, White, True);
Draw_Box(35, 120, 40, 125, White, True);
Draw_Box(55, 170, 60, 175, White, True);
Draw_Box(215, 40, 220, 45, White, True);
Draw_Box(48, 200, 53, 205, White, True);
Draw_Box(33, 140, 38, 145, White, True);
Draw_Box(25, 44, 30, 49, White, True);
Draw_Box(55, 70, 60, 75, White, True);
Draw_Box(215, 99, 220, 104, White, True);
Draw_Box(28, 200, 33, 205, White, True);
Draw_Box(23, 160, 28, 165, White, True);
Draw_Box(15, 20, 20, 25, White, True);
Draw_Box(55, 70, 60, 75, White, True);
Draw_Box(115, 40, 120, 45, White, True);
Draw_Box(98, 200, 103, 205, White, True);
Draw_Box(33, 440, 38, 445, White, True);
Draw_Box(35, 420, 40, 425, White, True);
Draw_Box(55, 470, 60, 475, White, True);
Draw_Box(215, 40, 220, 45, White, True);
Draw_Box(48, 200, 53, 205, White, True);
Draw_Box(33, 140, 38, 145, White, True);
Draw_Box(25, 44, 30, 49, White, True);
Draw_Box(55, 70, 60, 75, White, True);
Draw_Box(215, 99, 220, 104, White, True);
Draw_Box(28, 200, 33, 205, White, True);
Draw_Box(23, 160, 28, 165, White, True);
Draw_Box(315, 20, 320, 25, White, True);
Draw_Box(355, 70, 360, 75, White, True);
Draw_Box(315, 40, 320, 45, White, True);
Draw_Box(198, 200, 203, 205, White, True);
Draw_Box(133, 40, 138, 45, White, True);
Draw_Box(35, 120, 40, 125, White, True);
Draw_Box(55, 170, 60, 175, White, True);
Draw_Box(315, 60, 320, 65, White, True);
Draw_Box(48, 200, 53, 205, White, True);
Draw_Box(33, 140, 38, 145, White, True);
Draw_Box(25, 44, 30, 49, White, True);
Draw_Box(55, 70, 60, 75, White, True);
Draw_Box(215, 99, 220, 104, White, True);
Draw_Box(28, 200, 33, 205, White, True);
Draw_Box(23, 160, 28, 165, White, True);
Draw_Box(53, 147, 58, 152, Magenta, True);
Draw_Box(25, 44, 30, 49, Magenta, True);
Draw_Box(55, 70, 60, 75, Yellow, True);
Draw_Box(15, 209, 20, 214, Green, True);
Draw_Box(27, 100, 32, 105, Red, True);
Draw_Box(24, 560, 29, 565, Cyan, True);
end DibujarAzucar;
procedure ResetearObjetos is
begin
X_Cosa1 := Generate_Number (Minvalue => 5, Maxvalue => 200);
X_Cosa2 := Generate_Number (Minvalue => 4, Maxvalue => 200);
X_Cosa3 := Generate_Number (Minvalue => 20, Maxvalue => 200);
X_Cosa4 := Generate_Number (Minvalue => 10, Maxvalue => 200);
X_Cosa5 := Generate_Number (Minvalue => 50, Maxvalue => 200);
Y_Cosa1 := 600;
Y_Cosa2 := 800;
Y_Cosa3 := 1000;
Y_Cosa4 := 750;
Y_Cosa5 := 1300;
end ResetearObjetos;
procedure RealizarAccion is
begin
if (NiveldelJuego = 3) then
NroVidas := NroVidas - 1;
end if;
if (NiveldelJuego = 2) then
Azucar_Quintales:=Azucar_Quintales +1;
end if;
Resetearobjetos;
if (Nrovidas=0) then
Dibujar_Vidas;
Ganar:=False;
Salir:=True;
end if;
end RealizarAccion;
procedure DibujarLadron (Tecla : in Character ) is
begin
if Tecla =Vk_Right then
X_Personaje:=X_Personaje+10;
end if;
if Tecla =Vk_Left then
X_Personaje:=X_Personaje-10;
end if;
if Tecla =Vk_Up then
Y_Personaje:=Y_Personaje+10;
end if;
DibujarAuto;
if (X_Personaje+10>=X_Cosa1 and X_Personaje+10<=(X_Cosa1+15) and Y_Personaje>=Y_Cosa1 and Y_Personaje <= (Y_Cosa1 +15)) then
RealizarAccion ;
end if;
if (X_Personaje+10>=X_Cosa2 and X_Personaje+10<=(X_Cosa2+15) and Y_Personaje>=Y_Cosa2 and Y_Personaje <= (Y_Cosa2 +15)) then
RealizarAccion ;
end if;
if (X_Personaje+10>=X_Cosa3 and X_Personaje+10<=(X_Cosa3+15) and Y_Personaje>=Y_Cosa3 and Y_Personaje <= (Y_Cosa3 +15)) then
RealizarAccion ;
end if;
if (X_Personaje+10>=X_Cosa4 and X_Personaje+10<=(X_Cosa4+15) and Y_Personaje>=Y_Cosa4 and Y_Personaje <= (Y_Cosa4 +15)) then
RealizarAccion ;
end if;
if (X_Personaje+10>=X_Cosa5 and X_Personaje+10<=(X_Cosa5+15) and Y_Personaje>=Y_Cosa5 and Y_Personaje <= (Y_Cosa5 +15)) then
RealizarAccion ;
end if;
end Dibujarladron;
procedure DibujarladronPersona(Tecla : in Character ) is
begin
DibujarPersona(Black, Black);
if Tecla =Vk_Right then
X_Personaje:=X_Personaje+10;
end if;
if Tecla =Vk_Left then
X_Personaje:=X_Personaje-10;
end if;
if Tecla =Vk_Up then
Y_Personaje:=Y_Personaje+10;
end if;
if (Get_Pixel(X_Personaje, Y_Personaje ) = White) then
Azucar_Quintales:=Azucar_Quintales +1;
end if;
--para subirse al auto
if (Get_Pixel(X_Personaje +10 , Y_Personaje -5 ) = Light_Red) then
Salir:=True;
end if;
DibujarPersona(Yellow, Light_Green);
end DibujarladronPersona;
procedure DibujarBala is
begin
delay(0.02);
--dibujamos los enemigos
Draw_Box( X_Cosa1, Y_Cosa1, X_Cosa1+15, Y_Cosa1+15, Black, True);
Draw_Box( X_Cosa2, Y_Cosa2, X_Cosa2+15, Y_Cosa2+15, Black, True);
Draw_Box( X_Cosa3, Y_Cosa3, X_Cosa3+15, Y_Cosa3+15, Black, True);
Draw_Box( X_Cosa4, Y_Cosa4, X_Cosa4+15, Y_Cosa4+15, Black, True);
Draw_Box( X_Cosa5, Y_Cosa5, X_Cosa5+15, Y_Cosa5+15, Black, True);
-- dibujamos al ladron contrabandista
DibujarAuto;
Y_Personaje:= Y_Personaje +5;
if (Y_Personaje > 600) then
Y_Personaje :=0;
ResetearObjetos;
contadorKM := contadorKM - 10;
end if;
delay(0.01);
if (Y_Cosa1< 10 ) then
Y_Cosa1 := 600;
X_Cosa1 := Generate_Number (Minvalue => 5, Maxvalue => 90);
end if;
if (Y_Cosa2< 10 ) then
Y_Cosa2 := 800;
X_Cosa2 := Generate_Number (Minvalue => 40, Maxvalue => 80);
end if;
if (Y_Cosa3< 10 ) then
Y_Cosa3 := 1200;
X_Cosa3 := Generate_Number (Minvalue => 50, Maxvalue => 80);
end if;
if (Y_Cosa4< 10 ) then
Y_Cosa4 := 900;
X_Cosa4 := Generate_Number (Minvalue => 4, Maxvalue => 80);
end if;
if (Y_Cosa5< 10 ) then
Y_Cosa5 := 800;
X_Cosa5 := Generate_Number (Minvalue => 20, Maxvalue => 80);
end if;
Y_Cosa1:= Y_Cosa1 - 7;
Y_Cosa2:= Y_Cosa2 - 8;
Y_Cosa3:= Y_Cosa3- 1;
Y_Cosa4:= Y_Cosa4- 1;
Y_Cosa5:= Y_Cosa5- 3;
--dibujamos los enemigos
Draw_Box( X_Cosa1, Y_Cosa1, X_Cosa1+15, Y_Cosa1+15, Black, True);
Draw_Box( X_Cosa2, Y_Cosa2, X_Cosa2+15, Y_Cosa2+15, Black, True);
Draw_Box( X_Cosa3, Y_Cosa3, X_Cosa3+15, Y_Cosa3+15, Black, True);
Draw_Box( X_Cosa4, Y_Cosa4, X_Cosa4+15, Y_Cosa4+15, Black, True);
Draw_Box( X_Cosa5, Y_Cosa5, X_Cosa5+15, Y_Cosa5+15, Black, True);
end DibujarBala;
procedure JugarNivel1 is
begin
Tecla:=Vk_Nul;
DibujarAzucar;
loop
DibujarAutoEstacionado;
Display_Text( 20, 400, "Usted esta en la Fabrica de Azucar <<LA DULCE PERUANA>>", Yellow);
Display_Text( 20, 380, "..robe los quintales de azucar y escape en su auto rojo...go go go...", Yellow);
Draw_Box( 20, 380, 360, 320, Black, True);
Display_Text( 20, 360, "Quintales de azucar robados: " & integer'image(Azucar_Quintales) , Cyan);
Dibujar_Nivel;
if (Key_Hit) then
Tecla:=Get_Key;
if Tecla=Vk_Left or Tecla=Vk_Right or Tecla=Vk_Up or Tecla=Vk_Down then
Dir:=Tecla;
DibujarLadronPersona(Dir);
end if;
end if;
exit when Salir=True;
end loop;
end JugarNivel1;
procedure JugarNivel2 is
begin
Tecla:=Vk_Nul;
loop
Dibujarladron(Vk_Nul);
Dibujar_Carretera;
Dibujar_Vidas;
Dibujar_Km;
DibujarBala;
Dibujarladron(Vk_Nul);
Dibujar_Nivel;
Dibujar_Quintales;
if (Key_Hit) then
Tecla:=Get_Key;
if Tecla=Vk_Left or Tecla=Vk_Right or Tecla=Vk_Up or Tecla=Vk_Down then
Dir:=Tecla;
DibujarLadron(Dir);
end if;
end if;
if (Contadorkm = 100) then
Salir:=True;
end if;
exit when Salir=True;
end loop;
end JugarNivel2;
procedure JugarNivel3 is
begin
Tecla:=Vk_Nul;
loop
Dibujarladron(Vk_Nul);
Dibujar_Carretera;
Dibujar_Vidas;
Dibujar_Km;
DibujarBala;
Dibujarladron(Vk_Nul);
Dibujar_Nivel;
Dibujar_Quintales;
if (Key_Hit) then
Tecla:=Get_Key;
if Tecla=Vk_Left or Tecla=Vk_Right or Tecla=Vk_Up or Tecla=Vk_Down then
Dir:=Tecla;
DibujarLadron(Dir);
end if;
end if;
if (Contadorkm = 0) then
Ganar:=True;
Salir:=True;
end if;
exit when Salir=True;
end loop;
Dibujar_Mensaje_Final;
end JugarNivel3;
procedure Esperartecla is
begin
Salir := False;
loop
if (Key_Hit) then
Tecla:= Get_Key;
if Tecla='q' then
Salir:=True;
end if;
end if;
exit when Salir=True;
end loop;
end Esperartecla ;
begin
Inicializar;
Jugarnivel1;
Salir:=False;
Clear_Window(Hue => Black);
X_Personaje := 20;
Y_Personaje := 0;
NivelDelJuego := 2;
Jugarnivel2;
Salir:=False;
Clear_Window(Hue => Black);
NivelDelJuego := 3;
Jugarnivel3;
EsperarTecla;
Tecla:= Get_Key;
-- Demonios, existe escasez de azucar en la patria. Usted, un afamado
-- contrabandista, debera robar unos buenos quintales del Peru y meterlos
-- en su auto rojo F1 y escapar a Bolivia, asi sus compatriotas
-- podran endulzar sus tecitos y refrescos hervidos. Animo patriota !!
end ladronesDeAzucar ;
No hay comentarios:
Publicar un comentario