Pohybujúci sa a strieľajúci samopaľ

Delphi & Pascal (česká wiki)
Přejít na: navigace, hledání
Kategória: KMP (Klub mladých programátorov)

Autor: Gabriel Staroň
Program: Samopal.pas
Súbor exe: Samopal.exe
Potrebné: Egavga.bgi

Pohybujúci sa a strieľajúci samopaľ.
{ SAMOPAL.PAS                                                       }
{                                                                   }
{ Author: Gabriel Staron                                            }
{ Date  : 15.02.1997                           http://www.trsek.com }
 
program Samopal;
uses crt,graph;
var
  grDriver : Integer;
  grMode   : Integer;
  ErrCode  : Integer;
  x,y      : integer;
  ch       : char;
begin
  x:=12;
  y:=40;
  grDriver := Detect;
  InitGraph(grDriver,grMode,'');
  setcolor(white);
  outtextxy(10,20,'Ovladanie sipkami, strelba enter');
repeat
   outtextxy(632,80,'Ű');                                {ciel}
   ch:=readkey;
   if (ch=#13) then begin                               {strela}
      sound(150);
      delay(500);
      nosound;
      setcolor(white);                                  {vykresli strelu}
      line(x+371,y+395,x+400,y+395);
      delay(100);
      setcolor(black);                                  {zmaz strelu}
      line(x+371,y+395,x+400,y+395);
      delay(100);
      setcolor(white);
      line(x+400,y+395,x+430,y+395);
      delay(100);
      setcolor(black);
      line(x+400,y+395,x+430,y+395);
      delay(100);
      setcolor(white);
      line(x+430,y+395,x+460,y+395);
      delay(100);
      setcolor(black);
      line(x+430,y+395,x+460,y+395);
      delay(100);
      setcolor(white);
      line(x+460,y+395,x+490,y+395);
      delay(100);
      setcolor(black);
      line(x+460,y+395,x+490,y+395);
      delay(100);
      setcolor(white);
      line(x+490,y+395,x+520,y+395);
      delay(100);
      setcolor(black);
      line(x+490,y+395,x+520,y+395);
      delay(100);
      setcolor(white);
      line(x+520,y+395,x+550,y+395);
      delay(100);
      setcolor(black);
      line(x+520,y+395,x+550,y+395);
      delay(100);
      setcolor(white);
      line(x+550,y+395,x+580,y+395);
      delay(100);
      setcolor(black);
      line(x+550,y+395,x+580,y+395);
      delay(100);
      setcolor(white);
      line(x+580,y+395,x+610,y+395);
      delay(100);
      setcolor(black);
      line(x+580,y+395,x+610,y+395);
      delay(100);
      setcolor(white);
      line(x+610,y+395,x+640,y+395);
      delay(100);
      setcolor(black);
      line(x+610,y+395,x+640,y+395);
      delay(100);
      setcolor(white);
      line(x+640,y+395,x+670,y+395);
      delay(100);
      setcolor(black);
      line(x+640,y+395,x+670,y+395);
      delay(100);
      setcolor(white);
      line(x+670,y+395,x+700,y+395);
      delay(100);
      setcolor(black);
      line(x+670,y+395,x+700,y+395);
      delay(100);
      setcolor(white);
      line(x+700,y+395,x+730,y+395);
      delay(100);
      setcolor(black);
      line(x+700,y+395,x+730,y+395);
      delay(100);
      setcolor(white);
      line(x+730,y+395,x+760,y+395);
      delay(100);
      setcolor(black);
      line(x+730,y+395,x+760,y+395);
      delay(100);
      setcolor(white);
      line(x+760,y+395,x+790,y+395);
      delay(100);
      setcolor(black);
      line(x+760,y+395,x+790,y+395);
      delay(100);
      setcolor(white);
      line(x+790,y+395,x+820,y+395);
      delay(100);
      setcolor(black);
      line(x+790,y+395,x+820,y+395);
      delay(100);
      setcolor(white);
      line(x+820,y+395,x+850,y+395);
      delay(100);
      setcolor(black);
      line(x+820,y+395,x+850,y+395);
      delay(100);
      setcolor(white);
      line(x+850,y+395,x+880,y+395);
      delay(100);
      setcolor(black);
      line(x+850,y+395,x+880,y+395);
      delay(100);
      setcolor(white);
      line(x+880,y+395,x+910,y+395);
      delay(100);
      setcolor(black);
      line(x+880,y+395,x+910,y+395);
      delay(100);
      setcolor(white);
      line(x+910,y+395,x+940,y+395);
      delay(100);
      setcolor(black);
      line(x+910,y+395,x+940,y+395);
      delay(100);
     end;
 
   if (ch=#0) then begin
       ch:=readkey;
      setcolor(black);                                  {zmaz samopal}
      line(x+300,y+390,x+370,y+390);
      line(x+300,y+390,x+300,y+430);
      line(x+300,y+430,x+310,y+430);
      line(x+310,y+430,x+310,y+400);
      line(x+310,y+400,x+330,y+400);
      line(x+330,y+400,x+330,y+420);
      line(x+330,y+420,x+340,y+420);
      line(x+340,y+420,x+340,y+400);
      line(x+340,y+400,x+370,y+400);
      line(x+370,y+400,x+370,y+390);
 
      if (ch='K') then x:=x-10;                         {vlavo}
      if (ch='M') then x:=x+10;                         {vpravo}
      if (ch='H') then y:=y-10;                         {hore}
      if (ch='P') then y:=y+10;                         {dole}
 
      setcolor(white);                                  {vykresli samopal}
      line(x+300,y+390,x+370,y+390);
      line(x+300,y+390,x+300,y+430);
      line(x+300,y+430,x+310,y+430);
      line(x+310,y+430,x+310,y+400);
      line(x+310,y+400,x+330,y+400);
      line(x+330,y+400,x+330,y+420);
      line(x+330,y+420,x+340,y+420);
      line(x+340,y+420,x+340,y+400);
      line(x+340,y+400,x+370,y+400);
      line(x+370,y+400,x+370,y+390);
 
      repeat until keypressed;
   end;
until (ch=#27);                                      {znak ESC znamena koniec}
closegraph;
end.