Program KABBOOUM;
uses crt,graph,dos;
{ Constantes }
const
opca_x=250; { define a posi‡ao horizontal da 1¦ opcao }
opca_y=110; { define a posi‡ao vertical da 1¦ opcao }
t_bot_x=130; { tamanho do botÆo x }
t_bot_y=40; { tamanho do botÆo y }
espaco=50; { Espa‡o entre os botäes }
n_botoes=5; { N§ de botoes }
cor_botao=7; { Cor de fundo dos botäes }
cor_opcao=1; { Cor das varias opcoes }
enter=chr(13);
scim= chr(72);
sbax= chr(80);
sesq= chr(75);
sdir= chr(77);
esc=chr(27);
tab=chr(9);
alt_tab=chr(15);
dlt=chr(83);
home=chr(71);
ende=chr(79);
pgdw=chr(81);
c_ma=chr(67); { Faz apagar todos os ponto brancos do ecran}
c_mi=chr(99);
x_ma=chr(88); { Faz sair da procedure jogo e acabar com o torneio}
x_mi=chr(120);
bola1=25;
n_notas=20; { N§ maximo de notas }
{variaveis do jogo}
var
tan : pointer;
Size : Word;
min, max, ax, ay, bx, by, grav_op, turn, temp, kills, cai, t_corpo, t_arma,
som, ganhou, t_c, acel, vez, move, cont, conta, rastro, computador, n_jogad, axx,
ayy, r_exp, c_exp_x, c_exp_y, top1, top2, vencedor, vento, n_jogos, suavidade,
npicos, n_jogo_actual,opcao, sair,vento_max: integer;
picox, picoy: array[0..200] of integer;
nomes, dead, energ, n_exp, cor, p_c_y, p_c_x, victorias, pontos: array [0..10] of integer;
armas_dsp: array[1..10,1..11] of integer;
grav, vent: real;
ang, v, norma: array[0..10] of real;
rastro_0, rastro_1, rastro_texto, som_t, som_1, som_2, comput, comput_1,
comput_2, comput_3, n_jogadores, gravidade, suave_ss, suave_ps, suave_as,
suave_sn, suave_ms, suave_es, salvar, num_picos, suave, grav_1, grav_2,
grav_3, vento_txt,num_jogos: string;
nome_opca: array [1..n_botoes] of string;
armas: array [1..11] of string;
ik, tecla: char;
{
*****************************************************************************
* Procedure : Botao *
* Descri‡Æo : Consiste em criar uma box *
* Variaveis : x, y, xf, yf *
* Parte : Menu *
* *
*****************************************************************************
}
procedure botao(x, y, xf, yf: integer);
begin
{setcolor(cor_botao);
setfillstyle(1,cor_botao);
bar(x,y,xf,yf);
setcolor(15);
line(x-1,y-1,xf,y-1);
line(x-1,y-1,x-1,yf);
setcolor(8);
line(x-1,yf+1,xf+1,yf+1);
line(xf+1,y-1,xf+1,yf+1);}
setcolor(cor_botao);
rectangle(x,y,xf,yf);
setfillstyle(1,cor_botao);
floodfill(x+1,y+1,cor_botao);
setcolor(15);
line(x-1,y-1,xf,y-1);
line(x-1,y-1,x-1,yf);
setcolor(8);
line(x-1,yf+1,xf+1,yf+1);
line(xf+1,y-1,xf+1,yf+1);
end;
{
*****************************************************************************
* Procedure : Botao_actual *
* Descri‡Æo : Consiste em criar uma box do botao actual *
* Variaveis : x, y, xf, yf *
* Parte : Menu *
* *
*****************************************************************************
}
procedure botao_actual(x, y, xf, yf:integer);
begin
{ setcolor(cor_botao);
setfillstyle(1,cor_botao);
bar(x,y,xf,yf);
setcolor(8);
line(x-1,y-1,xf+1,y-1);
line(x-1,y-1,x-1,yf+1);
setcolor(15);
line(x,yf+2,xf+1,yf+2);
line(xf+1,y,xf+1,yf+1);
setcolor(15);}
setcolor(cor_botao);
rectangle(x,y,xf,yf);
setfillstyle(1,cor_botao);
floodfill(x+1,y+1,cor_botao);
setcolor(8);
line(x-1,y-1,xf+1,y-1);
line(x-1,y-1,x-1,yf+1);
setcolor(15);
line(x,yf+2,xf+1,yf+2);
line(xf+1,y,xf+1,yf+1);
setcolor(15);
end;
{
*****************************************************************************
* Procedure : Bomba_apre *
* Descri‡Æo : Consiste em apresentar uma cena fixe no menu do jogo *
* Variaveis : nÆo tem variaveis *
* Parte : MAIN *
* *
*****************************************************************************
}
procedure bomba_apre;
var
i: integer;
begin
if som=1 then
begin
sound(70);
delay(10);
nosound;
end;
end;
procedure prima_esc;
begin
settextstyle(2, HorizDir, 7);
botao(190,448,450,475);
setcolor(0);
outtextxy(200,448,'Prima ESC para Sair');
end;
{
*****************************************************************************
* Procedure : Opcoes *
* Descri‡Æo : Consiste pedir informa‡Æo sobre o computador e jogo *
* Variaveis : nÆo tem variaveis *
* Parte : Op‡oes *
* *
*****************************************************************************
}
procedure opcoes;
var
P,T : pointer;
Sz : Word;
tecla1 : Char;
nopcoes,opcao,saire: integer ;
txt :string;
i :integer;
begin
saire:=0;
tecla1:='1';
opcao:=1;
nopcoes:=10;
botao(200,20,450,70);
settextstyle(1, HorizDir, 5);
setcolor(14);
outtextxy(237,15,' OP€OES ');
settextstyle(2, HorizDir, 5);
for i:=0 to trunc(nopcoes/2)-1 do
begin
botao(10,90+(60*i),320,130+(60*i));
end;
for i:=0 to trunc(nopcoes/2)-1 do
begin
botao(330,90+(60*i),630,130+(60*i));
end;
setcolor(cor_opcao);
outtextxy(20,100,som_t);
outtextxy(340,100,comput);
outtextxy(20,160,n_jogadores);
outtextxy(340,160,gravidade);
outtextxy(20,220,rastro_texto);
outtextxy(340,220,num_picos);
outtextxy(20,280,suave);
outtextxy(340,280,vento_txt);
outtextxy(20,340,num_jogos);
outtextxy(340,340,salvar);
{++++++++++++++Imprimir no ecran a op‡Æo actual++++++++++++++++}
botao_actual(10,90,320,130-1);
SetFillStyle(1,cor_botao);
bar(199,99,310,120);
setcolor(15);
if (som=1) then outtextxy(200,100,som_1)
else if (som=0) then outtextxy(200,100,som_2);
{++++++++Imprimir no ecran as op‡äes nÆo selecionadas++++++++++}
setcolor(8);
if (computador=1) then outtextxy(520,100,comput_1)
else if (computador=2) then outtextxy(520,100,comput_2)
else if (computador=3) then outtextxy(520,100,comput_3);
setcolor(8);
str(n_jogad,txt);
outtextxy(200,160,txt);
setcolor(8);
if (grav_op=1) then outtextxy(520,160,grav_1)
else if (grav_op=2) then outtextxy(520,160,grav_2)
else if (grav_op=3) then outtextxy(520,160,grav_3);
setcolor(8);
if (rastro=0) then outtextxy(200,220,rastro_0)
else if (rastro=1) then outtextxy(200,220,rastro_1);
setcolor(8);
str(npicos,txt);
outtextxy(520,220,txt);
if (suavidade=20) then outtextxy(200,280,suave_es)
else if (suavidade=100) then outtextxy(200,280,suave_ms)
else if (suavidade=180) then outtextxy(200,280,suave_as)
else if (suavidade=260) then outtextxy(200,280,suave_sn)
else if (suavidade=340) then outtextxy(200,280,suave_ps)
else if (suavidade=420) then outtextxy(200,280,suave_ss);
str(vento_max,txt);
outtextxy(520,280,txt);
str(n_jogos,txt);
outtextxy(220,340,txt);
while(saire<>1) do
begin
tecla1:=readkey;
if (tecla1<>'0') then
begin
if (opcao=1) then
begin
botao(10,90,320,130);
SetFillStyle(1,cor_botao);
bar(199,99,310,120);
setcolor(8);
if (som=1) then outtextxy(200,100,som_1)
else if (som=0) then outtextxy(200,100,som_2);
end
else if (opcao=2) then
begin
botao(330,90,630,130);
SetFillStyle(1,cor_botao);
bar(519,99,600,120);
setcolor(8);
if (computador=1) then outtextxy(520,100,comput_1)
else if (computador=2) then outtextxy(520,100,comput_2)
else if (computador=3) then outtextxy(520,100,comput_3);
end
else if (opcao=3) then
begin
botao(10,150,320,190);
SetFillStyle(1,cor_botao);
bar(199,159,310,181);
setcolor(8);
str(n_jogad,txt);
outtextxy(200,160,txt)
end
else if (opcao=4) then
begin
botao(330,150,630,190);
SetFillStyle(1,cor_botao);
bar(519,159,600,181);
setcolor(8);
if (grav_op=1) then outtextxy(520,160,grav_1)
else if (grav_op=2) then outtextxy(520,160,grav_2)
else if (grav_op=3) then outtextxy(520,160,grav_3);
end
else if (opcao=5) then
begin
botao(10,210,320,250);
SetFillStyle(1,cor_botao);
bar(199,219,310,249);
setcolor(8);
if (rastro=0) then outtextxy(200,220,rastro_0)
else if (rastro=1) then outtextxy(200,220,rastro_1);
end
else if (opcao=6) then
begin
botao(330,210,630,250);
SetFillStyle(1,cor_botao);
bar(519,219,600,249);
setcolor(8);
str(npicos,txt);
outtextxy(520,220,txt)
end
else if (opcao=7) then
begin
botao(10,270,320,310);
SetFillStyle(1,cor_botao);
bar(199,279,310,309);
setcolor(8);
if (suavidade=20) then outtextxy(200,280,suave_es)
else if (suavidade=100) then outtextxy(200,280,suave_ms)
else if (suavidade=180) then outtextxy(200,280,suave_as)
else if (suavidade=260) then outtextxy(200,280,suave_sn)
else if (suavidade=340) then outtextxy(200,280,suave_ps)
else if (suavidade=420) then outtextxy(200,280,suave_ss);
end
else if (opcao=8) then
begin
botao(330,270,630,310);
SetFillStyle(1,cor_botao);
bar(499,279,610,309);
setcolor(8);
str(vento_max,txt);
outtextxy(520,280,txt);
end
else if (opcao=9) then
begin
botao(10,330,320,370);
SetFillStyle(1,cor_botao);
bar(199,339,310,369);
setcolor(8);
str(n_jogos,txt);
outtextxy(220,340,txt);
end
else if (opcao=10) then botao(330,330,630,370);
if (tecla1=sdir) then
begin
if (opcao<>nopcoes) then opcao:=opcao+1
else if (opcao=nopcoes) then opcao:=1;
end;
if (tecla1=sesq) then
begin
if (opcao<>1) then opcao:=opcao-1
else if (opcao=1) then opcao:=nopcoes;
end;
if (tecla1=scim) then
begin
if (opcao=1) then if (som=1) then som:=0 else som:=1
else if (opcao=2) then
begin
if (computador=1) then computador:=3
else computador:=computador-1;
end
else if (opcao=3) then
begin
if n_jogad=10 then n_jogad:=2
else n_jogad:=n_jogad+1;
end
else if (opcao=4) then
begin
if (grav_op=3) then grav_op:=1
else grav_op:=grav_op+1;
if (grav_op=1) then grav:=1
else if (grav_op=2) then grav:=5
else if (grav_op=3) then grav:=15;
end
else if (opcao=5) then
begin
if (rastro=0) then rastro:=1
else rastro:=0;
end
else if (opcao=6) then
begin
if (npicos=200) then npicos:=0
else npicos:=npicos+5;
end
else if (opcao=7) then
begin
if (suavidade<>20) then suavidade:=suavidade-80
else suavidade:=420;
end
else if (opcao=8) then
begin
if (vento_max<200) then vento_max:=vento_max+10
else vento_max:=0;
end
else if (opcao=9) then
begin
if (n_jogos<9) then n_jogos:=n_jogos+2
else n_jogos:=1;
end;
end;
if (tecla1=sbax) then
begin
if (opcao=1) then if (som=1) then som:=0 else som:=1
else if (opcao=2) then
begin
if (computador=3) then computador:=1
else computador:=computador+1;
end
else if (opcao=3) then
begin
if n_jogad=2 then n_jogad:=10
else n_jogad:=n_jogad-1;
end
else if (opcao=4) then
begin
if (grav_op=1) then grav_op:=3
else grav_op:=grav_op-1;
if (grav_op=1) then grav:=1
else if (grav_op=2) then grav:=5
else if (grav_op=3) then grav:=15;
end
else if (opcao=5) then
begin
if (rastro=0) then rastro:=1
else rastro:=0;
end
else if (opcao=6) then
begin
if (npicos=0) then npicos:=200
else npicos:=npicos-5;
end
else if (opcao=7) then
begin
if (suavidade<>420) then suavidade:=suavidade+80
else suavidade:=20;
end
else if (opcao=8) then
begin
if (vento_max<>0) then vento_max:=vento_max-10
else vento_max:=200;
end
else if (opcao=9) then
begin
if (n_jogos<>1) then n_jogos:=n_jogos-2
else n_jogos:=9;
end;
end;
if (opcao=1) then
begin
botao_actual(10,90,320,130-1);
SetFillStyle(1,cor_botao);
bar(199,99,310,120);
setcolor(15);
if (som=1) then outtextxy(200,100,som_1)
else if (som=0) then outtextxy(200,100,som_2);
end
else if (opcao=2) then
begin
botao_actual(330,90,630,130-1);
SetFillStyle(1,cor_botao);
bar(519,99,600,120);
setcolor(15);
if (computador=1) then outtextxy(520,100,comput_1)
else if (computador=2) then outtextxy(520,100,comput_2)
else if (computador=3) then outtextxy(520,100,comput_3);
end
else if (opcao=3) then
begin
botao_actual(10,150,320,190-1);
SetFillStyle(1,cor_botao);
bar(199,159,310,181);
setcolor(15);
str(n_jogad,txt);
outtextxy(200,160,txt)
end
else if (opcao=4) then
begin
botao_actual(330,150,630,190-1);
SetFillStyle(1,cor_botao);
bar(519,159,600,181);
setcolor(15);
if (grav_op=1) then outtextxy(520,160,grav_1)
else if (grav_op=2) then outtextxy(520,160,grav_2)
else if (grav_op=3) then outtextxy(520,160,grav_3);
end
else if (opcao=5) then
begin
botao_actual(10,210,320,250-1);
SetFillStyle(1,cor_botao);
bar(199,219,310,249);
setcolor(15);
if (rastro=0) then outtextxy(200,220,rastro_0)
else if (rastro=1) then outtextxy(200,220,rastro_1);
end
else if (opcao=6) then
begin
botao_actual(330,210,630,250-1);
SetFillStyle(1,cor_botao);
bar(519,219,600,249);
setcolor(15);
str(npicos,txt);
outtextxy(520,220,txt);
end
else if (opcao=7) then
begin
botao_actual(10,270,320,310-1);
SetFillStyle(1,cor_botao);
bar(199,279,310,309);
setcolor(15);
if (suavidade=20) then outtextxy(200,280,suave_es)
else if (suavidade=100) then outtextxy(200,280,suave_ms)
else if (suavidade=180) then outtextxy(200,280,suave_as)
else if (suavidade=260) then outtextxy(200,280,suave_sn)
else if (suavidade=340) then outtextxy(200,280,suave_ps)
else if (suavidade=420) then outtextxy(200,280,suave_ss);
end
else if (opcao=8) then
begin
botao_actual(330,270,630,310-1);
SetFillStyle(1,cor_botao);
bar(499,279,610,309);
setcolor(15);
str(vento_max,txt);
outtextxy(520,280,txt);
end
else if (opcao=9) then
begin
botao_actual(10,330,320,370-1);
SetFillStyle(1,cor_botao);
bar(199,339,310,369);
setcolor(15);
str(n_jogos,txt);
outtextxy(220,340,txt);
end
else if (opcao=10) then botao_actual(330,330,630,370-1);
end;
if (tecla1=enter) and (opcao=10) then saire:=1;
end;
end;
{
*****************************************************************************
* Procedure : Apre_menu *
* Descri‡Æo : Consiste em criar o menu *
* Variaveis : NÆo tem variaveis *
* Parte : Menu *
* *
*****************************************************************************
}
procedure apre_menu;
var
i,j:integer;
begin
settextstyle(3,0,6);
setcolor(4);
outtextxy(188,25,'KABBOOUM');
j:=1;
{ Desenhar os botäes do menu }
for i:=1 to n_botoes*espaco do
begin
botao(opca_x,opca_y+i,opca_x+t_bot_x,opca_y+i+t_bot_y);
settextstyle(3,0,4);
outtextxy(opca_x-55,opca_y+i,nome_opca[j]);
i:=i+espaco-1;
j:=1+j;
end;
botao_actual(opca_x,opca_y+(opcao-1)*espaco,opca_x+t_bot_x,opca_y+(opcao-1)*espaco+t_bot_y);
p_c_y[0]:=opca_y+(opcao-2)*espaco+10;
outtextxy(opca_x-55,opca_y+(opcao-1)*espaco+1,nome_opca[opcao]);
end;
{
*****************************************************************************
* Procedure : Troca *
* Descri‡Æo : Muda os valores da barra *
* Variaveis : x,y,txt *
* Parte : Jogo *
* *
*****************************************************************************
}
procedure troca(x,y,txt:integer);
var
temp:string;
begin
str(txt,temp);
setfillstyle(1,0);
floodfill(x+1,y+1,8);
setfillstyle(1,7);
floodfill(x+1,y+1,8);
setcolor(0);
settextstyle(2,0,5);
outtextxy(x+8,y,temp);
end;
{
*****************************************************************************
* Procedure : Ang *
* Descri‡Æo : Converter graus para radianos *
* Variaveis : graus *
* Parte : Jogo *
* *
*****************************************************************************
}
function angu(graus :integer):real;
begin
angu:=(Pi*graus)/180;
end;
function rad(radianos :real):integer;
begin
rad:=trunc((180*radianos)/Pi);
end;
{
*********************** Inicia‡„o das variaveis *****************************
* Procedure : Inicializacao *
* Descri‡Æo : Inicializar variaveis para o menu *
* Variaveis : NÆo tem variaveis *
* Parte : Menu *
* *
*****************************************************************************
}
procedure inicializacao;
var
txt:string;
i,j:integer;
begin
{ atribui‡Æo do texto do menu … estrutura }
nome_opca[1]:=' Jogar '; { inicializa‡Æo da op‡Æo 0 }
nome_opca[2]:=' Op‡oes '; { inicializa‡Æo da op‡Æo 2 }
nome_opca[3]:=' Ajuda '; { inicializa‡Æo da op‡Æo 3 }
nome_opca[4]:=' Cr‚ditos '; { inicializa‡Æo da op‡Æo 3 }
nome_opca[5]:=' Sair '; { inicializa‡Æo da op‡Æo 4 }
{ atribui‡Æo das varias op‡äes}
som:=0;
som_t:='Efeitos Digitalizados';
som_1:='Speaker';
som_2:='Sem Som';
computador:=1;
comput:='Tipo de Computador';
comput_1:='R pido';
comput_2:='Normal';
comput_3:='Lento';
n_jogadores:='N§ de Jogadores ';
gravidade:='Gravidade do planeta';
grav_1:='Lua';
grav_2:='Terra';
grav_3:='Jupiter';
grav:=5; {Gravidade inicial}
grav_op:=2; {Opcao da gravidade}
num_picos:='N§ m ximo de Picos';
suave:='Suavidade do terreno';
salvar:='Menu Principal';
suave_ss:='Nenhuma';
suave_ps:='Pouca';
suave_sn:='Normal';
suave_as:='Alguma';
suave_ms:='Muita';
suave_es:='Extrema';
vento_txt:='Vento m ximo';
vento_max:=100;
num_jogos:='N£mero de jogos';
n_jogos:=3;
opcao:=1;
tecla:='0';
sair:=0;
turn:=1;
cont:=1;
n_jogad:=2;
{se deixa rastro ou nÆo}
rastro:=1;
rastro_texto:='Com ou sem Rastro';
rastro_0:='Sem Rastro';
rastro_1:='Com Rastro';
{inicializa tank da apresenta‡Æo }
ang[0]:=angu(45);
p_c_x[0]:=150;
p_c_y[0]:=opca_y;
npicos:=50;
suavidade:=260;
min:=1;
max:=639;
armas[1]:='Granada';
armas[2]:='Morteiro';
armas[3]:='deslizante';
armas[4]:='DESLIZANTE';
armas[5]:='Lazer';
armas[6]:='napalme';
armas[7]:='NAPALME';
armas[8]:='Terramoto';
armas[9]:='Desvatador';
armas[10]:='terra';
armas[11]:='TERRA';
for i:=1 to 10 do
begin
nomes[i]:=i;
end;
end;
{
*****************************************************************************
* Procedure : Inicializa *
* Descri‡Æo : Inicializa‡Æo da variaveis que regulam o jogo *
* Variaveis : t_c,acel,enter,scim,sbax,sesq,sdir,esc *
* Parte : Jogo *
* *
*****************************************************************************
}
procedure inicializa ;
var
i,difer1,difer2 : integer;
begin
{Inicializa‡äes}
ik:=chr(0);
acel:=-1;
t_corpo:=8;
t_arma:=15;
c_exp_x:=0;
c_exp_y:=0;
difer1:=trunc(((640/(n_jogad+1))/2)/(n_jogad/10));
difer2:=trunc((640+difer1*2)/(n_jogad+1));
for i:=1 to n_jogad do
begin
energ[i]:=100;
dead[i]:=1;
n_exp[i]:=1;
v[i]:=20;
ang[i]:=angu(90);
p_c_x[i]:=trunc(-difer1+difer2*i);
p_c_y[i]:=40+t_arma;
norma[i]:=30;
end;
cor[1]:=0;
cor[2]:=2;
cor[3]:=3;
cor[4]:=4;
cor[5]:=5;
cor[6]:=6;
cor[7]:=8;
cor[8]:=9;
cor[9]:=11;
cor[10]:=12;
cai:=1;
vez:=1;
kills:=0;
vento:=1;
vencedor:=0;
end;
{
*****************************************************************************
* Procedure : Rot *
* Descri‡Æo : Rota‡Æo de um ponto relativamente a uma origem *
* Variaveis : cntx,cnty,rai1,rai2,direc,cor e ang_c *
* Parte : Jogo *
* *
*****************************************************************************
}
procedure rot(cntx,cnty,rai1,rai2,direc,cor : integer);
begin
ax:=trunc(cntx+rai1*cos(-ang[vez]));
ay:=trunc(cnty+rai1*sin(-ang[vez]));
bx:=trunc(cntx+rai2*cos(-ang[vez]));
by:=trunc(cnty+rai2*sin(-ang[vez]));
setcolor(1);
line(ax,ay,bx,by);
if ((ang[vez]>=angu(179)) and (direc=1)) then ang[vez]:=0
else if ((ang[vez]<=angu(1)) and (direc=-1)) then ang[vez]:=angu(180)
else if ((ang[vez]>=angu(175)) and (direc=5)) then ang[vez]:=0
else if ((ang[vez]<=angu(5)) and (direc=-5)) then ang[vez]:=angu(180)
else ang[vez]:=ang[vez]+angu(direc);
ax:=trunc(cntx+rai1*cos(-ang[vez]));
ay:=trunc(cnty+rai1*sin(-ang[vez]));
bx:=trunc(cntx+rai2*cos(-ang[vez]));
by:=trunc(cnty+rai2*sin(-ang[vez]));
setcolor(cor);
line(ax,ay,bx,by);
end;
{
*****************************************************************************
* Procedure : Tanque *
* Descri‡Æo : Consiste em criar um tank para a apresenta‡Æo *
* Variaveis : posx,posy,cor,qual *
* Parte : Menu *
* *
*****************************************************************************
}
procedure tanque(posx,posy,cor,qual:integer);
begin
setcolor(cor);
SetFillStyle(1, cor);
pieslice(posx,posy,0,180,20);
SetFillStyle(1, 8);
setcolor(8);
pieslice(posx-12,posy-3,0,360,4);
SetFillStyle(1, 8);
setcolor(8);
pieslice(posx+12,posy-3,0,360,4);
line(posx-12,posy-7,posx+12,posy-7);
line(posx-12,posy+1,posx+12,posy+1);
setcolor(7);
if qual=1 then
begin
line(posx-12,posy-8,posx-12,posy-7);
line(posx-8,posy-8,posx-8,posy-6);
line(posx-4,posy-8,posx-4,posy-6);
line(posx,posy-8,posx,posy-6);
line(posx+4,posy-8,posx+4,posy-6);
line(posx+8,posy-8,posx+8,posy-6);
line(posx+12,posy-8,posx+12,posy-7);
line(posx-12,posy,posx-12,posy+1);
line(posx-8,posy,posx-8,posy+2);
line(posx-4,posy,posx-4,posy+2);
line(posx,posy,posx,posy+2);
line(posx+4,posy,posx+4,posy+2);
line(posx+8,posy,posx+8,posy+2);
line(posx+12,posy,posx+12,posy+1);
end
else if qual=2 then
begin
line(posx-14,posy-8,posx-14,posy-7);
line(posx-10,posy-8,posx-10,posy-6);
line(posx-6,posy-8,posx-6,posy-6);
line(posx-2,posy-8,posx-2,posy-6);
line(posx+2,posy-8,posx+2,posy-6);
line(posx+6,posy-8,posx+6,posy-6);
line(posx+10,posy-8,posx+10,posy-6);
line(posx+14,posy-8,posx+14,posy-7);
line(posx-14,posy,posx-14,posy+1);
line(posx-10,posy,posx-10,posy+2);
line(posx-6,posy,posx-6,posy+2);
line(posx-2,posy,posx-2,posy+2);
line(posx+2,posy,posx+2,posy+2);
line(posx+6,posy,posx+6,posy+2);
line(posx+10,posy,posx+10,posy+2);
line(posx+14,posy,posx+14,posy+1);
end;
ax:=trunc(posx+20*cos(-ang[0]));
ay:=trunc(posy+20*sin(-ang[0]));
bx:=trunc(posx+40*cos(-ang[0]));
by:=trunc(posy+40*sin(-ang[0]));
setcolor(cor);
SetLineStyle(0,5,3);
line(ax,ay,bx,by);
SetLineStyle(0,5,1);
end;
{
*****************************************************************************
* Procedure : Barra de status *
* Descri‡Æo : Desenha a barra de status *
* Variaveis : NÆo tem variaveis *
* Parte : Jogo *
* *
*****************************************************************************
}
procedure barra;
begin
setcolor(15);
line(0,0,639,0);
line(0,0,0,30);
setcolor(8);
line(0,30,639,30);
line(639,0,639,30);
setcolor(7);
setfillstyle(1,7);
bar(1,1,638,29);
setcolor(0);
settextstyle(2,0,5);
outtextxy(15,7,'Tanque');
setcolor(8);
rectangle(70,6,100,24);
setcolor(0);
outtextxy(140,7,'Energia');
setcolor(8);
rectangle(200,6,235,24);
setcolor(0);
outtextxy(250,7,'Angulo');
setcolor(8);
rectangle(305,6,341,24);
setcolor(0);
outtextxy(350,7,'Velocidade');
setcolor(8);
rectangle(435,6,483,24);
setcolor(0);
outtextxy(500,7,'Arma');
setcolor(8);
rectangle(540,6,630,24);
end;
{
*****************************************************************************
* Procedure : Energia *
* Descri‡Æo : *
* Variaveis : NÆo tem variaveis *
* Parte : Jogo *
* *
*****************************************************************************
}
procedure energia;
var
nrm1,a1,b1,c1,d1:longint;
i:integer;
begin
for i:=1 to n_jogad do
begin
a1:=c_exp_x-p_c_x[i];
b1:=c_exp_y-p_c_y[i];
c1:=a1*a1;
d1:=b1*b1;
nrm1:=trunc(sqrt(c1+d1)-10);
if r_exp-nrm1>0 then
begin
energ[i]:=energ[i]-(trunc(((r_exp-nrm1)*100)/20));
if energ[i]<=0 then energ[i]:=0;
end;
end;
end;
{
*****************************************************************************
* Procedure : tanq *
* Descri‡Æo : desenhar o tanque *
* Variaveis : posx e posy *
* Parte : Jogo *
* *
*****************************************************************************
}
procedure tanq(posx,posy,cor:integer);
begin
setcolor(cor);
setfillstyle(1, cor);
pieslice(posx,posy,0,180,t_corpo-1);
end;
{
*****************************************************************************
* Procedure : caitanq *
* Descri‡Æo : *
* Variaveis : *
* Parte : Jogo *
* *
*****************************************************************************
}
procedure caitanq(apre:integer);
var
tmp_vez:integer;
ponto:array[1..10]of integer;
begin
tmp_vez:=vez;
for vez:=1 to n_jogad do
begin
if energ[vez]>0
then begin
ponto[vez]:=getpixel(p_c_x[vez],p_c_y[vez]+1);
while (ponto[vez]<>10) and (ponto[vez]<>13) do
begin
rot(p_c_x[vez],p_c_y[vez],t_corpo-1,t_arma,0,1);
SetFillStyle(1,1);
pieslice(p_c_x[vez],p_c_y[vez]-5,0,180,t_corpo);
setcolor(1);
arc(p_c_x[vez],p_c_y[vez],0,180,t_corpo-1);
p_c_y[vez]:=p_c_y[vez]+1;
rot(p_c_x[vez],p_c_y[vez],t_corpo,t_arma,0,cor[vez]);
ponto[vez]:=getpixel(p_c_x[vez],p_c_y[vez]+1);
if apre=1 then energ[vez]:=energ[vez]-1;
if computador=1 then delay(5)
else if computador=2 then delay(2)
else if computador=3 then delay(0);
SetFillStyle(1,cor[vez]);
pieslice(p_c_x[vez],p_c_y[vez],0,180,t_corpo-1);
end;
if apre=1 then if energ[vez]<=0 then energ[vez]:=0;
end;
end;
vez:=tmp_vez;
end;
{
*****************************************************************************
* Procedure : limpa *
* Descri‡Æo : *
* Variaveis : *
* Parte : Jogo *
* *
*****************************************************************************
}
procedure limpa(a,b:integer);
var
i,j :integer;
begin
if min<>1 then
begin
for i:=1 to min do
begin
putpixel(i,31,15);
if computador=1 then delay(10)
else if computador=2 then delay(5)
else if computador=3 then delay(0);
end;
end;
for i:=min to max do
begin
for j:=32 to 478 do
begin
putpixel(i,31,15);
if getpixel(i,j)=a then putpixel(i,j,b);
end;
end;
if max<>639 then
begin
for i:=max to 639 do
begin
putpixel(i,31,15);
if computador=1 then delay(10)
else if computador=2 then delay(5)
else if computador=3 then delay(0);
end;
end;
setcolor(0);
line(0,31,639,31);
end;
{
*****************************************************************************
* Procedure : Aparar Terra *
* Descri‡Æo : Varredor de Terra *
* Variaveis : NÆo tem variaveis *
* Parte : Jogo *
* *
*****************************************************************************
}
procedure aparar_terra;
var
x,y,xstart,xend,ystart,yend,yterra,i,j:integer;
texto:string;
flag:boolean;
begin
for i:=1 to n_jogad do
begin
xstart:=p_c_x[i]-t_corpo-t_arma;
xend:=p_c_x[i]+t_corpo+t_arma;
ystart:=p_c_y[i];
yend:=34;
flag:=false;
while not flag do
begin
for x:=xstart to xend do
if getpixel(x,yend)=10 then flag:=true;
yend:=yend+1;
end;
for x:=xstart to xend do begin
yterra:=ystart;
while (getpixel(x,yterra-1)<>1) and (getpixel(x,yterra)=10) do
begin
yterra:=yterra-1;
end;
for y:=ystart downto yend do
if ((getpixel(x,y+1)=1)or(getpixel(x,y+1)=15)) and (getpixel(x,y)=10)
then begin
PutPixel(x,y,1);
PutPixel(x,yterra,10);
yterra:=yterra-1;
end;
end;
end;
setcolor(13);
rectangle(0,32,639,479);
min:=1;
max:=639;
end;
{
*****************************************************************************
* Procedure : Terra *
* Descri‡Æo : Varredor de Terra *
* Variaveis : NÆo tem variaveis *
* Parte : Jogo *
* *
*****************************************************************************
}
procedure terra;
var
teste1,teste2,x,y,xstart,xend,ystart,yend,yterra,i:integer;
texto:string;
flag:boolean;
begin
if min<>1 then
begin
for i:=1 to min do
begin
putpixel(i,31,15);
if computador=1 then delay(10)
else if computador=2 then delay(5)
else if computador=3 then delay(0);
end;
end;
if (n_exp[vez]=8)or(n_exp[vez]=9)
then begin
xstart:=min;
xend:=max;
ystart:=478;
flag:=false;
yend:=34;
while not flag do
begin
for x:=xstart to xend do
if getpixel(x,yend)=10 then flag:=true;
yend:=yend+1;
end;
for x:=xstart to xend do begin
putpixel(x,31,15);
yterra:=ystart;
while (getpixel(x,yterra-1)<>1) and (getpixel(x,yterra)=10) do
begin
yterra:=yterra-1;
end;
for y:=ystart downto yend do
if ((getpixel(x,y+1)=1)or(getpixel(x,y+1)=15)) and (getpixel(x,y)=10)
then begin
PutPixel(x,y,1);
PutPixel(x,yterra,10);
yterra:=yterra-1;
end;
end;
end
else begin
if (n_exp[vez]=10)or(n_exp[vez]=11)
then begin
if c_exp_x-(bola1*2+1) <= 0 then xstart:=0
else xstart:=c_exp_x-(bola1*2+1);
if c_exp_x+(bola1*2+1) >= 639 then xend:=639
else xend:=c_exp_x+(bola1*2+1);
ystart:=478
end
else begin
if c_exp_x-(r_exp+1) <= 0 then xstart:=0
else xstart:=c_exp_x-(r_exp+1);
if c_exp_x+(r_exp+1) >= 639 then xend:=639
else xend:=c_exp_x+(r_exp+1);
if c_exp_y+(r_exp+1) >= 478 then ystart:=478
else ystart:=c_exp_y+(r_exp+1);
end;
flag:=false;
yend:=32;
while not flag do begin
for x:=xstart to xend do
if getpixel(x,yend)=10 then flag:=true;
yend:=yend+1;
end;
for x:=xstart to xend do begin
yterra:=ystart;
teste1:=getpixel(x,yterra-1);
teste2:=getpixel(x,yterra);
while not (getpixel(x,yterra-1)=1) and (getpixel(x,yterra)=10) {and (getpixel(x,yterra)=13)} do
begin
teste1:=getpixel(x,yterra-1);
teste2:=getpixel(x,yterra);
yterra:=yterra-1;
end;
for y:=ystart downto yend do
if (getpixel(x,y+1)=1) and (getpixel(x,y)=10) then begin
PutPixel(x,y,1);
PutPixel(x,yterra,10);
yterra:=yterra-1;
end;
end;
end;
if max<>639 then
begin
for i:=max to 639 do
begin
putpixel(i,31,15);
if computador=1 then delay(10)
else if computador=2 then delay(5)
else if computador=3 then delay(0);
end;
end;
setcolor(13);
rectangle(0,32,639,479);
setcolor(0);
line(0,31,639,31);
min:=1;
max:=639;
end;
{
*****************************************************************************
* Procedure : explos *
* Descri‡Æo : desenhar a explosÆo *
* Variaveis : cntx e cnty *
* Parte : Jogo *
* *
*****************************************************************************
}
procedure explos(cntx,cnty:integer);
var i,saidas,dir,encontrou,comp,conta,pos_x_i,pos_y_i,pos_x_f,pos_y_f,p_cx,p_cy,t,find:integer;
g:longint;
a,b,c,d,e,angl,ang_c:real;
begin
setlinestyle(0,1,3);
if n_exp[vez]=1
then
begin
r_exp:=10;
if (som=1) then sound(70);
setcolor(4);
for i:=1 to r_exp do
begin
circle(cntx,cnty,i);
if computador=1 then delay(10)
else if computador=2 then delay(5)
else if computador=3 then delay(0);
end;
setcolor(1);
if som=1 then sound(50);
for i:=r_exp downto 1 do
begin
circle(cntx,cnty,i);
if computador=1 then delay(10)
else if computador=2 then delay(5)
else if computador=3 then delay(0);
end;
nosound;
end
else if n_exp[vez]=2
then
begin
r_exp:=20;
if som=1 then sound(70);
setcolor(4);
for i:=1 to r_exp do
begin
circle(cntx,cnty,i);
if computador=1 then delay(10)
else if computador=2 then delay(5)
else if computador=3 then delay(0);
end;
setcolor(1);
if som=1 then sound(50);
for i:=r_exp downto 1 do
begin
circle(cntx,cnty,i);
if computador=1 then delay(10)
else if computador=2 then delay(5)
else if computador=3 then delay(0);
end;
nosound;
end
else if n_exp[vez]=3
then
begin
angl:=ang[vez];
if angl>Pi/2 then dir:=-1
else dir:=1;
saidas:=1;
cnty:=cnty-1;
if (getpixel(cntx+dir,cnty)<>1)and(getpixel(cntx+dir,cnty)<>15) then dir:=-dir;
while saidas<>0 do
begin
saidas:=0;
while (getpixel(cntx,cnty+1)=1) or (getpixel(cntx,cnty+1)=15) do
begin
putpixel(cntx,cnty,1);
cnty:=cnty+1;
putpixel(cntx,cnty,15);
saidas:=1;
if computador=1 then delay(50)
else if computador=2 then delay(25)
else if computador=3 then delay(0);
end;
if (getpixel(cntx+dir,cnty)=1) or (getpixel(cntx+dir,cnty)=15)
then
begin
putpixel(cntx,cnty,1);
cntx:=cntx+dir;
putpixel(cntx,cnty,15);
saidas:=1;
if computador=1 then delay(50)
else if computador=2 then delay(25)
else if computador=3 then delay(0);
end;
end;
putpixel(cntx,cnty,1);
cntx:=cntx;
cnty:=cnty;
r_exp:=10;
if som=1 then sound(70);
setcolor(4);
for i:=1 to r_exp do
begin
circle(cntx,cnty,i);
if computador=1 then delay(10)
else if computador=2 then delay(5)
else if computador=3 then delay(0);
end;
setcolor(1);
if som=1 then sound(50);
for i:=r_exp downto 1 do
begin
circle(cntx,cnty,i);
if computador=1 then delay(10)
else if computador=2 then delay(5)
else if computador=3 then delay(0);
end;
nosound;
end
else if n_exp[vez]=4
then
begin
angl:=ang[vez];
if angl>Pi/2 then dir:=-1
else dir:=1;
saidas:=1;
cnty:=cnty-1;
if (getpixel(cntx+dir,cnty)<>1) and (getpixel(cntx+dir,cnty)<>15) then dir:=-dir;
while saidas<>0 do
begin
saidas:=0;
while (getpixel(cntx,cnty+1)=1) or (getpixel(cntx,cnty+1)=15) do
begin
putpixel(cntx,cnty,1);
cnty:=cnty+1;
putpixel(cntx,cnty,15);
saidas:=1;
if computador=1 then delay(50)
else if computador=2 then delay(25)
else if computador=3 then delay(0);
end;
if (getpixel(cntx+dir,cnty)=1) or (getpixel(cntx+dir,cnty)=15)
then
begin
putpixel(cntx,cnty,1);
cntx:=cntx+dir;
putpixel(cntx,cnty,15);
saidas:=1;
if computador=1 then delay(50)
else if computador=2 then delay(25)
else if computador=3 then delay(0);
end;
end;
putpixel(cntx,cnty,1);
r_exp:=20;
if som=1 then
begin
if computador=1 then delay(70)
else if computador=2 then delay(40)
else if computador=3 then delay(20);
end;
setcolor(4);
for i:=1 to r_exp do
begin
circle(cntx,cnty,i);
if computador=1 then delay(10)
else if computador=2 then delay(5)
else if computador=3 then delay(0);
end;
setcolor(1);
if som=1 then
begin
if computador=1 then delay(50)
else if computador=2 then delay(30)
else if computador=3 then delay(20);
end;
for i:=r_exp downto 1 do
begin
circle(cntx,cnty,i);
if computador=1 then delay(10)
else if computador=2 then delay(5)
else if computador=3 then delay(0);
end;
nosound;
end
else if n_exp[vez]=5
then
begin
ang_c:=ang[vez];
p_cx:=p_c_x[vez];
p_cy:=p_c_y[vez];
t_arma:=t_arma+1;
pos_x_i:=trunc(p_cx+(t_arma)*cos(-ang_c));
pos_y_i:=trunc(p_cy+(t_arma)*sin(-ang_c));
t_arma:=t_arma+1;
pos_x_f:=trunc(p_cx+(t_arma)*cos(-ang_c));
pos_y_f:=trunc(p_cy+(t_arma)*sin(-ang_c));
while (getpixel(pos_x_f,pos_y_f)=1)or(getpixel(pos_x_f,pos_y_f)=15) do
begin
t_arma:=t_arma+1;
pos_x_f:=trunc(p_cx+(t_arma)*cos(-ang_c));
pos_y_f:=trunc(p_cy+(t_arma)*sin(-ang_c));
end;
cntx:=pos_x_f;
cnty:=pos_y_f;
for i:=1 to 100 do
begin
setcolor(random(15));
line(pos_x_i,pos_y_i,pos_x_f,pos_y_f);
if computador=1 then delay(10)
else if computador=2 then delay(5)
else if computador=3 then delay(0);
end;
setcolor(1);
line(pos_x_i,pos_y_i,pos_x_f,pos_y_f);
r_exp:=20;
if som=1 then
begin
if computador=1 then delay(70)
else if computador=2 then delay(40)
else if computador=3 then delay(20);
end;
setcolor(4);
for i:=1 to r_exp do
begin
circle(cntx,cnty,i);
if computador=1 then delay(10)
else if computador=2 then delay(5)
else if computador=3 then delay(0);
end;
setcolor(1);
if som=1 then
begin
if computador=1 then delay(50)
else if computador=2 then delay(30)
else if computador=3 then delay(10);
end;
for i:=r_exp downto 1 do
begin
circle(cntx,cnty,i);
if computador=1 then delay(10)
else if computador=2 then delay(5)
else if computador=3 then delay(0);
end;
t_arma:=15;
nosound;
end
else if n_exp[vez]=6
then
begin
nosound;
min:=cntx;
max:=cntx;
r_exp:=0;
angl:=ang[vez];
if angl>Pi/2 then dir:=-1
else dir:=1;
saidas:=1;
comp:=0;
cnty:=cnty-1;
if (getpixel(cntx+dir,cnty)<>1)and(getpixel(cntx+dir,cnty)<>15) then dir:=-dir;
conta:=1;
while comp<=200 do
begin
if conta<>1 then begin
t:=t+1;
cnty:=cnty-1;
if (t/3)=trunc(t/3) then dir:=0-dir;
end;
conta:=2;
saidas:=1;
while saidas<>0 do
begin
saidas:=0;
for i:=1 to n_jogad do
begin
if getpixel(cntx,cnty+1)=cor[i] then energ[i]:=energ[i]-10;
end;
while (getpixel(cntx,cnty+1)=1) or (getpixel(cntx,cnty+1)=15) do
begin
if cntx