Draw bottle with buble and projectile

Delphi & Pascal (česká wiki)
Přejít na: navigace, hledání
Category: KMP (Club of young programmers)
flasa.pngAuthor: Ján Benkovič
web: www.tbteacher.host.sk

Program: Flasa.pas
File exe: Flasa.exe

Draw bottle with buble and projectile. Projectile perforate bottle. After this, water drain and wait for keyboard.
{ FLASA.PAS                              Copyright (c) Jan Benkovic }
{ Vykresli flasu s bublinkami a naboj ktory flasu prederavi.        }
{ Az flasa vytecie zobrazi sa nazov a pocka na stlacenie klavesy.   }
{                                                                   }
{ Datum:02.04.2000                             http://www.trsek.com }
 
Program flasa;
uses crt,graph;
 
var
 gd,gm : integer;
 x,y,d,pocet,i,a,b,c :integer;
 output: string;
 
begin
 randomize;
 detectgraph(gd,gm);
 InitGraph(Gd, Gm, '');
 rectangle(270,200,370,400);
 line(270,200,300,150);
 line(370,200,340,150);
 setcolor(green);
 line(340,150,300,150);
 line(340,130,300,130);
 line(340,150,340,130);
 line(335,150,335,130);
 line(330,150,330,130);
 line(325,150,325,130);
 line(320,150,320,130);
 line(315,150,315,130);
 line(310,150,310,130);
 line(305,150,305,130);
 line(300,150,300,130);
 setcolor(black);
 line(271,200,369,200);
 
 for i:=199 downto 1 do
  begin
   setcolor(blue);
   delay(5);
   line(271,200+i,369,200+i);
  end;
 
 pocet:=random(80)+21;
 repeat
  d:=d+1;
  a:=random(85)+277;
  b:=random(190)+205;
  c:=random(5)+1;
  setcolor(white);
  delay(10);
  circle(a,b,c);
 until d=pocet;
 
 str(pocet,output);
 outtextXY(1,1,'Pocet bubliniek vo flasi je :');
 outtextXY(242,1,output);
 
 for i:= 1 to 230 do
  begin
   delay(10);
   line(600-i,370,640-i,370);
   putpixel(640-i,370,black);
  end;
 
 putpixel(370,371,black);
 putpixel(370,370,black);
 putpixel(370,369,black);
 i:=0;
 
 repeat
  delay(10);
  i:=i+1;
  setcolor(white);
  line(370+i,370,410+i,370);
  putpixel(370+i,370,black);
  putpixel(370,371,blue);
  putpixel(370,370,blue);
  putpixel(370,369,blue);
  putpixel(371,370,blue);
  putpixel(371,370+i,blue);
  putpixel(372,370+i,blue);
  putpixel(373,370+i,blue);
  if i>=172 then
   begin
    putpixel(370,371,black);
    putpixel(370,370,black);
    putpixel(370,369,black);
    putpixel(371,370,black);
    putpixel(371,170+i,black);
    putpixel(372,170+i,black);
    putpixel(373,170+i,black);
   end
  else
   begin
    setcolor(black);
    line(271,200+i,369,200+i);
   end;
 until i=330;
 
 setcolor(black);
 outtextXY(1,1,'Pocet bubliniek vo flasi je :');
 outtextXY(242,1,output);
 setcolor(red);
 settextstyle(0,0,2);
 outtextxy(250,50,'F(r)anta');
 readln;
 closegraph;
end.