Hra na hľadanie mín v poli, pascal
Delphi & Pascal (česká wiki)
Kategória: KMP (Klub mladých programátorov)
Autor: Juraj Gabcik
Program: Minefield.pas
Súbor exe: Minefield.exe
Potrebné: Egavga.bgi, Grafika.tpu
Autor: Juraj Gabcik
Program: Minefield.pas
Súbor exe: Minefield.exe
Potrebné: Egavga.bgi, Grafika.tpu
Máte za úlohu hľadať míny v mínovom poli. Pajácom pohybujete šípkami.
{ MINEFIELD.PAS Copyright (c) Juraj Gabcik } { } { Máte za úlohu hžada míny v mínovom poli. } { Pajácom pohybujete ípkami. } { } { Author: Juraj Gabcik } { Date : 04.12.2006 http://www.trsek.com } program minefield; uses grafika; var znak:char; var x,y,dx,dy,i,a,b,c,m,n:integer; {miny} procedure mina; begin setcolor(2); filledellipse(300,350,5,3); setcolor(4); filledellipse(300,350,4,2); end; procedure mina2; begin setcolor(2); filledellipse(200,280,5,3); setcolor(4); filledellipse(200,280,4,2); end; procedure mina3; begin setcolor(2); filledellipse(500,220,5,3); setcolor(4); filledellipse(500,220,4,2); end; procedure mina4; begin setcolor(2); filledellipse(220,130,5,3); setcolor(4); filledellipse(220,130,4,2); end; procedure mina5; begin setcolor(2); filledellipse(350,200,5,3); setcolor(4); filledellipse(350,200,4,2); end; procedure bum; begin for i:=1 to 9 do begin b:=b+6; setcolor(14); filledcircle(300,350,b); delay(150); end; if b>53 then begin delay(200); setcolor(0); filledcircle(300,350,70); b:=0; x:=x+60; y:=y-60; setcolor(15); filledcircle(x+dx,y+dy,8); mina; end; setcolor(0); if (x<350) or (x>370) or (y<280) or (y>300) then filledellipse(300,350,5,3); end; procedure bum2; begin for i:=1 to 9 do begin b:=b+6; setcolor(14); filledcircle(200,280,b); delay(150); end; if b>53 then begin delay(200); setcolor(0); filledcircle(200,280,70); b:=0; x:=x+65; y:=y-70; setcolor(15); filledcircle(x+dx,y+dy,8); mina2; end; end; procedure bum3; begin for i:=1 to 9 do begin b:=b+6; setcolor(14); filledcircle(500,220,b); delay(150); end; if b>53 then begin delay(200); setcolor(0); filledcircle(500,220,70); b:=0; x:=x-85; y:=y-10; setcolor(15); filledcircle(x+dx,y+dy,8); mina3; end; end; procedure bum4; begin for i:=1 to 9 do begin b:=b+6; setcolor(14); filledcircle(220,130,b); delay(150); end; if b>53 then begin delay(200); setcolor(0); filledcircle(220,140,70); b:=0; x:=x+85; y:=y+70; setcolor(15); filledcircle(x+dx,y+dy,8); mina4; end; end; procedure bum5; begin for i:=1 to 9 do begin b:=b+6; setcolor(14); filledcircle(350,200,b); delay(150); end; if b>53 then begin delay(200); setcolor(0); filledcircle(350,200,70); b:=0; x:=x+85; y:=y+70; setcolor(15); filledcircle(x+dx,y+dy,8); mina5; end; end; procedure zvuk; begin sound(311); delay(150); nosound; delay(50); sound(311); delay(150); nosound; delay(50); sound(311); delay(150); nosound; delay(50); sound(311); delay(150); nosound; delay(50); sound(311); delay(150); nosound; delay(50); end; {tank} procedure tank; begin setcolor(15); filledcircle(x+dx,y+dy,8); line(x+dx,y+dy,x+dx,y+dy); setcolor(14); rectangle(306,10,332,35); setcolor(2); rectangle(96,96,124,124); rectangle(505,96,533,124); x:=x+dx; y:=y+dy; setcolor(1); {podmienky} if y>49 then line(302,48,336,48); setcolor(0); if (y>56) and (y<80) and (x>300) and (x<340) then line(302,48,336,48); if (y<56) and (x>300) and (x<340) then line(302,48,336,48); if (x>285) and (x<315) and (y>335) and (y<365) then begin mina; zvuk; bum; end; if (x>185) and (x<215) and (y>265) and (y<295) then begin mina2; zvuk; bum2; end; if (x>485) and (x<515) and (y>205) and (y<235) then begin mina3; zvuk; bum3; end; if (x>205) and (x<235) and (y>115) and (y<145) then begin mina4; zvuk; bum4; end; if (x>335) and (x<365) and (y>185) and (y<215) then begin mina5; zvuk; bum5; end; setcolor(0); if (x<340) or (x>380) or (y<270) or (y>310) then filledellipse(300,350,5,3); if (x<245) or (x>285) or (y<190) or (y>230) then filledellipse(200,280,5,3); if (x<395) or (x>435) or (y<190) or (y>230) then filledellipse(500,220,5,3); if (x<285) or (x>325) or (y<190) or (y>230) then filledellipse(220,130,5,3); if (x<415) or (x>455) or (y<250) or (y>290) then filledellipse(350,200,5,3); if (x>120) and (x<150) and (y>150) and (y<180) then begin mina; mina2; mina3; mina4; mina5; end; end; {okolie} procedure okolie; begin setcolor(4); filledrectangle(0,10,640,480); filledrectangle(0,10,302,49); filledrectangle(336,10,640,49); setcolor(0); filledrectangle(302,10,336,49); filledrectangle(50,50,590,430); setcolor(14); rectangle(306,10,332,35); setcolor(2); rectangle(96,96,124,124); rectangle(505,96,533,124); setcolor(1); line(302,48,336,48); setcolor(14); writeln(' EXIT'); setcolor(4); filledrectangle(0,0,301,49); filledrectangle(337,0,640,49); setcolor(15); end; procedure okolie2; begin setcolor(4); filledrectangle(0,10,640,480); filledrectangle(0,10,302,49); filledrectangle(336,10,640,49); setcolor(0); filledrectangle(302,10,336,49); filledrectangle(50,50,590,430); setcolor(14); rectangle(306,10,332,35); setcolor(2); rectangle(96,96,124,124); rectangle(505,96,533,124); setcolor(1); line(302,48,336,48); setcolor(15); end; {zmaz} procedure zmaz(x,y:integer); begin setcolor(0); filledcircle(x+dx,y+dy,13); line(x+dx,y+dy,x+dx,y+dy); setcolor(15); end; procedure zmaz2(x,y:integer); begin delay(50); setcolor(0); filledcircle(x,y,2); setcolor(15); end; {koniec} procedure koniec; begin setcolor(0); filledrectangle(225,194,403,220); setcolor(15); printat(230,204,' Press ENTER to exit ',15,0); setcolor(4); filledrectangle(0,180,49,480); setcolor(1); filledrectangle(225,214,403,220); filledrectangle(225,194,235,220); filledrectangle(225,200,403,194); filledrectangle(392,194,403,220); end; {strela} procedure strela(m,n:integer); begin filledcircle(x+dx,y+dy,8); line(x+dx,y+dy,x+dx+12,y+dy); m:=m+10; for i:=1 to 10 do begin zmaz2(m,n); m:=m+7; filledcircle(m,n,2); setcolor(0); filledcircle(x+80,y,2); setcolor(15); line(x+dx,y+dy,x+dx+12,y+dy); end; end; {----------------------çtart------------------------} begin okolie; x:=320; y:=240; znak:=#0; setcolor(15); filledcircle(x+dx,y+dy,8); line(x+dx,y+dy,x+dx,y+dy); repeat znak:=readkey; dx:=0; dy:=0; zmaz(x,y); case znak of #77 : dx:=5; #75 : dx:=-5; #80 : dy:=5; #72 : dy:=-5; #52 : dx:=-8; #54 : dx:=8; #56 : dy:=-8; #50 : dy:=8; #13 : okolie2; #48 : strela(x,y); end; {podmienky} if (znak=#72) or (znak=#56) then line(x+dx,y+dy-12,x+dx,y+dy); if (znak=#80) or (znak=#50) then line(x+dx,y+dy+12,x+dx,y+dy); if (znak=#77) or (znak=#54) then line(x+dx,y+dy,x+dx+12,y+dy); if (znak=#75) or (znak=#52) then line(x+dx,y+dy,x+dx-12,y+dy); if (znak=#56) or (znak=#50) or (znak=#54) or (znak=#52) then sound(262); delay(2); nosound; {tank} tank; {podmienky} setcolor(0); if x>575 then x:=576; if x>575 then filledrectangle(560,50,590,430); setcolor(4); if x>575 then filledrectangle(591,0,640,480); setcolor(15); if x>575 then filledcircle(x+dx,y+dy,8); setcolor(0); if x<64 then x:=64; if x<66 then filledrectangle(50,50,80,430); setcolor(4); if x<66 then filledrectangle(0,0,49,480); setcolor(15); if x<66 then filledcircle(x+dx,y+dy,8); setcolor(0); if (y<64) and (x<314) then y:=64; if (y<64) and (x>325) then y:=64; if y<65 then begin filledrectangle(302,36,336,47); filledrectangle(307,11,331,34); setcolor(4); filledrectangle(0,10,301,49); filledrectangle(337,10,640,49); setcolor(0); filledrectangle(50,50,590,80); line(302,49,336,49); setcolor(4); filledrectangle(0,10,300,49); filledrectangle(338,10,640,49); setcolor(15); filledcircle(x+dx,y+dy,8); end; setcolor(0); if y<30 then filledrectangle(302,8,336,49); setcolor(14); if y<65 then rectangle(306,10,332,35); if y<30 then begin sound(262); delay(100); nosound; koniec; exit; end; setcolor(0); if y>416 then y:=416; if y>415 then begin filledrectangle(50,400,590,430); setcolor(4); filledrectangle(0,431,640,480); setcolor(15); filledcircle(x+dx,y+dy,8); end; setcolor(0); if (x>100) and (x<120) and (y>100) and (y<120) then begin filledrectangle(97,97,123,123); filledrectangle(125,97,129,123); filledrectangle(96,125,124,129); filledrectangle(96,95,124,91); filledrectangle(95,96,91,124); x:=505; tank; setcolor(2); rectangle(96,96,124,124); rectangle(505,96,533,124); end; setcolor(0); if (x>510) and (x<530) and (y>100) and (y<120) then begin filledrectangle(506,97,532,123); filledrectangle(505,95,533,91); filledrectangle(505,125,533,129); filledrectangle(504,97,500,123); filledrectangle(534,97,538,123); x:=125; tank; setcolor(2); rectangle(96,96,124,124); rectangle(505,96,533,124); end; until znak=#27; koniec; end.