Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {battle sea version 2.2.1}
- {copy right turbo pascal_free pascal}
- {data file sea_coin.txt create your own file name sea_coin.txt in the same folder with your Pascal program's folder }
- {run by free Pascal 2.6.4}
- {coppy this code !!! i can't post a link}
- program sorry_for_party_the_sea;
- uses crt,graph;
- const
- finp = 'sea_coin.txt';
- type
- int = integer;
- arr = array[1..100] of int;
- arr2 = array[1..10, 1..10] of string;
- var
- a,b,a1,a2 : arr2;
- live1,live2 : int;
- n,m,coin : int;
- f : text;
- ex,bom,rada : int;
- answer,t : int;
- procedure menu;
- var buy:int;
- begin
- clrscr;
- assign(f,finp); reset(f);
- readln(f,coin);
- readln(f,ex);
- readln(f,bom);
- readln(f,rada);
- close(f);
- writeln('YOUR coin: ',coin,' $');
- writeln('YOUR ex ship: ',ex);
- writeln('YOUR boom: ',bom);
- writeln('YOUR rada: ',rada);
- writeln('Hey wanna play ?');
- writeln('1 PLAY');
- writeln('2 STORE');
- writeln('3 INSTRUCTION');
- writeln('4 QUIT');
- readln(answer);
- if answer=4 then halt
- else if answer=2 then
- begin
- clrscr;
- writeln('welcome to battle ship store ! ');
- delay(1000);
- writeln('here comes the buy list: ');
- delay(1000);
- writeln('1: an extra ship 25 $');
- writeln('2: boomed all the ship 32 $');
- writeln('3: rada 39 $');
- writeln('if wannna quit so type 0');
- writeln('YOUR COIN: ',coin,' $ ');
- if coin>25 then
- begin
- readln(buy);
- if buy<>0 then
- repeat
- if (buy=1)and(coin>=25) then begin
- coin:=coin-25;
- ex :=ex+1;
- end
- else if(buy=1)and(coin<25) then
- begin
- writeln('u can''t buy this');
- readln;
- end;
- if (buy=2)and(coin>=32) then begin
- coin:=coin-32;
- bom :=bom+1;
- end
- else if(buy=2)and(coin<32) then
- begin
- writeln('u can''t buy this');
- readln;
- end;
- if (buy=3)and(coin>=39) then begin
- coin:=coin-39;
- rada:=rada+1;
- end
- else if (buy=3)and(coin<39) then
- begin
- writeln('u can''t buy this');
- readln;
- end;
- writeln;
- writeln('YOUR COIN: ',coin,' $ ');
- writeln;
- write('_ no=0_ buy more ?: '); readln(buy);
- if coin <25 then
- begin
- write('you ''ve out of money !');
- readln;
- break;
- end;
- until(coin<25)or(buy=0);
- end
- else begin
- clrscr;
- writeln('But');
- write('You don''t have enough money man ');
- readln;
- end;
- assign(f,finp); rewrite(f);
- writeln(f,coin);
- writeln(f,ex);
- writeln(f,bom);
- writeln(f,rada);
- close(f);
- menu;
- end
- else if answer=3 then
- begin
- clrscr;
- writeln('INSTRUCTION: ');
- writeln('to create ship you just have to type the coordinates ');
- writeln('example: 3 2 ');
- writeln;
- writeln('to shot the ship you just have to input the coordinates ');
- writeln('example: 9 9 ');
- writeln;
- writeln('you have 2 shot per time and so do the enemy ');
- writeln;
- writeln('boom can just effect in one line :) ');
- writeln;
- writeln('please do not type any words or the program will be crashed ');
- writeln;
- writeln('advoid playing so many time ! (it"s gonna be crashed) ');
- writeln;
- writeln('type your ship > 0 and <81 ');
- writeln;
- writeln('while playing you can pick up some item from enemy ');
- writeln;
- writeln('you will cost 10 $ for each guard ship ');
- writeln;
- writeln('lost captain means you have nothing but surrender ');
- writeln;
- write('press enter to next page');
- readln;
- clrscr;
- writeln('CREATE BY ');
- writeln('Zung the great ');
- writeln('Battle sea version 2.2.4');
- writeln('Enjoy the game !');
- writeln;
- write('press enter to return menu');
- readln;
- menu;
- end;
- end;
- procedure tile;
- var i:int;
- begin
- clrscr;
- textcolor(3);
- write('~~~~Hey hey hey welcome to~~~~');
- delay(1000);
- clrscr;
- write('~~~~The really old game~~~~');
- delay(1000);
- clrscr;
- write('~~~~where u can shot in a really ridiculous board~~~~');
- delay(1000);
- clrscr;
- write('this is :::::::');
- delay(1900);
- clrscr;
- write('S');
- delay(600);
- clrscr;
- write('SE');
- delay(600);
- clrscr;
- write('SEA');
- delay(600);
- clrscr;
- writeln('SEA');
- writeln('BATLE!!');
- writeln('Press enter');
- repeat until keypressed;
- write('loading ');
- for i:=1 to 5 do begin write('. '); delay(600); end;
- end;
- (* ------------------------------------------------------------ *)
- function fin(var a:arr2; i,j:int):boolean;
- begin
- fin:=false;
- if a[i,j]='0' then begin
- fin:=true;
- a[i,j]:='1';
- exit;
- end;
- end;
- procedure print(var a:arr2);
- var i,j:int;
- begin
- textcolor(black);
- write(' ');
- for i:=1 to 9 do write(i,' ');
- for i:=1 to 2 do writeln;
- for i:=1 to 9 do
- begin
- write(i,': ');
- for j:=1 to 9 do if a[i,j]='~' then write(a[i,j],' ')
- else if (a[i,j]='#') or (a[i,j]='^') then
- begin
- textcolor(12);
- write(a[i,j],' ');
- textcolor(black);
- end
- else if (a[i,j]='0') then
- begin
- textcolor(10);
- write(a[i,j],' ');
- textcolor(black);
- end
- else if (a[i,j]='x') then
- begin
- textcolor(yellow);
- write(a[i,j],' ');
- textcolor(black);
- end;
- writeln;
- end;
- end;
- procedure add;
- var i,j,k:int;
- begin
- clrscr;
- textbackground(white);
- textcolor(black);
- write('input your ship ( <= 81 ): '); readln(n);
- while (n<1)or(n>81) do
- begin
- write('hey add again man: ');
- readln(n);
- end;
- while (n>1) and(coin<n*10) do
- begin
- write('hey add again man, you dont have enough money !');
- readln(n);
- end;
- while (n<1) do
- begin
- write('hey add again man: ');
- readln(n);
- end;
- write('input enemy ship ( <= 81 ): '); readln(m);
- while (m<1)or(m>81) do
- begin
- write('hey add again man: ');
- readln(m);
- end;
- clrscr;
- for i:=1 to 9 do
- for j:=1 to 9 do begin
- a[i,j]:='~';
- a2[i,j]:='0';
- end;
- clrscr;
- writeln('let''s add your battle ship');
- writeln('x and y');
- write('add head master: '); readln(i,j);
- while (i<1)or(j<1)or(i>9)or(j>9) do
- begin
- write('add again: '); readln(i,j);
- end;
- a[i,j]:='^';
- a2[i,j]:='1';
- print(a);
- if n>1 then writeln('hey from now each guard ship costs 10 $ ');
- for k:=1 to n-1 do
- begin
- write('add guard ship ',k,': '); readln(i,j);
- while (i<1)or(j<1)or(i>9)or(j>9)or(not fin(a2,i,j)) do
- begin
- write('add guard ship ',k,' again: '); readln(i,j);
- end;
- a[i,j]:='#';
- clrscr;
- print(a);
- coin:=coin-10;
- writeln('you have ',coin-10,' $');
- end;
- writeln('so it looks like: ');
- write(' ');
- for i:=1 to 9 do write(i,' ');
- for i:=1 to 2 do writeln;
- for i:=1 to 9 do
- begin
- write(i,': ');
- for j:=1 to 9 do if a[i,j]='~' then write(a[i,j],' ')
- else
- begin
- textcolor(11);
- write(a[i,j],' ');
- textcolor(black);
- end;
- writeln;
- end;
- for i:=1 to 9 do for j:=1 to 9 do
- begin
- a1[i,j]:='0';
- end;
- writeln('press enter');
- repeat until keypressed;
- write('loading ');
- for i:=1 to 5 do begin write('. '); delay(591); end;
- end;
- procedure comadd;
- var i,j,l,xoa:int;
- begin
- textcolor(15);
- for i:=1 to 9 do
- for j:=1 to 9 do b[i,j]:='~';
- randomize;
- repeat
- i:=random(10);
- until (i>0);
- repeat
- j:=random(10);
- until(j>0);
- a1[i,j]:='1';
- b[i,j]:='^';
- i:=1; j:=1;
- for l:=1 to m-1 do
- begin
- repeat
- repeat
- i:=random(10);
- until(i>0);
- repeat
- j:=random(10);
- until(j>0);
- until fin(a1,i,j);
- b[i,j]:='#';
- end;
- for i:=1 to 9 do for j:=1 to 9 do
- begin
- a1[i,j]:='0';
- end;
- end;
- procedure complay(var i,j:int);
- var xoa:int ;
- begin
- randomize;
- repeat
- repeat
- i:=random(10);
- until(i>0);
- repeat
- j:=random(10);
- until(j>0);
- until fin(a1,i,j);
- end;
- procedure letsplay;
- var i,j,d :int;
- c :arr2;
- count,use:int;
- k,m :int;
- pickup :int;
- f :string;
- o :text;
- begin
- for i:=1 to 9 do
- for j:=1 to 9 do c[i,j]:='~';
- for i:=1 to 9 do for j:=1 to 9 do
- begin
- a2[i,j]:='0';
- end;
- {its item time !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}
- d:=0;
- if (ex>0)or(bom>0)or(rada>0) then
- begin
- writeln('HEY !');
- writeln;
- writeln('USE items extra ? (type 1): ');
- writeln('USE items boomed ? (type 2): ');
- writeln('USE items rada ? (type 3): ');
- writeln('NO=0 ');
- writeln;
- writeln('YOUR ex ship: ',ex);
- writeln('YOUR boom: ',bom);
- writeln('YOUR rada: ',rada);
- readln(answer);
- if (answer=1)or(answer=2)or(answer=3) then
- repeat
- if (answer=2)and(bom>0) then
- begin
- count:=0;
- bom:=bom-1;
- write('type a line u what to bommed it: '); readln(use);
- for j:=1 to 9 do
- if (b[use,j]='#')or(b[use,j]='^') then
- begin
- count:=count+1;
- c[use,j]:='x';
- a2[use,j]:='1';
- live2:=live2-1;
- end else
- begin
- a2[use,j]:='1';
- c[use,j]:='0';
- end;
- if count=0 then writeln('man u hit no ship ! ')
- else writeln('good you hit ',count,' ship');
- writeln;
- writeln('press enter');
- repeat until keypressed;
- break;
- end
- else if(answer=2)and(bom=0) then
- begin
- writeln('na you don''t have any, chose again !: ');
- readln(answer);
- end;
- if (answer=1)and(ex>0) then
- begin
- d:=2;
- ex:=ex-1;
- break;
- end
- else if (answer=1)and(ex=0) then
- begin
- writeln('na you don''t have any, chose again !: ');
- readln(answer);
- end;
- if (answer=3)and(rada>0) then
- begin
- d:=3;
- rada:=rada-1;
- writeln('get ready to sea the enemy"sea ');
- writeln('you have few second to explore before the enemy find us: ');
- writeln('the map will be in white color');
- delay(3100);
- textbackground(white);
- for i:=1 to 9 do
- begin
- for j:=1 to 9 do write(b[i,j],' ');
- writeln;
- end;
- delay(469);
- clrscr;
- write('so fast right ? :)');
- repeat until keypressed;
- break;
- end
- else if (answer=3)and(rada=0) then
- begin
- writeln('na you don''t have any, chose again !: ');
- readln(answer);
- end;
- until answer=0
- else write('na u don''t have any item ');
- end;
- {playing time !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}
- textbackground(yellow);
- repeat
- for count:=1 to 2 do
- begin
- clrscr;
- writeln('THE ENEMY''S SEA');
- print(c);
- writeln('your turn :');
- write('input your fire !! : '); readln(i,j);
- if (i=99) and (j=99) then
- begin
- clrscr;
- write('input cheat '); readln(f);
- if (f='edge eyes') then
- begin
- print(b);
- delay(3000);
- clrscr;
- end;
- if (f='fire balls') then
- for k:=1 to 9 do
- for m:=1 to 9 do if b[k,m]='#' then
- begin
- c[k,m]:='x';
- a2[k,m]:='1';
- end;
- if (f='shield protected') then
- for k:=1 to 9 do
- for m:=1 to 9 do if a[k,m]='^' then a1[k,m]:='1';
- if (f='surrender') then
- begin
- live1:=0;
- writeln('ok that was your choice ! ');
- writeln('you heard it men, fall back');
- writeln('press enter');
- readln;
- exit;
- end;
- if (f='coinnage') then
- begin
- coin:=coin+99;
- writeln('your coin: ',coin);
- writeln('press enter');
- readln;
- end;
- if (f='black death') then
- begin
- live2:=0;
- writeln('the enemy has fallen in flame ! ');
- writeln('you win the battle but not so glory !');
- writeln('press enter');
- readln;
- exit;
- end;
- i:=10;
- j:=10;
- clrscr;
- writeln('THE ENEMY''S SEA');
- print(c);
- writeln('your turn :');
- end;
- while (i>9)or(j>9)or(i<1)or(j<1)or(not fin(a2,i,j)) do
- begin
- write('input your fire again !! : '); readln(i,j);
- end;
- if (b[i,j]='#') then
- begin
- clrscr;
- writeln('we''ve hit it');
- writeln('they still have ',live2-1,' ship (hang on guy !)');
- live2:=live2-1;
- c[i,j]:='x';
- randomize;
- pickup:=random(330);
- if pickup=1 then
- begin
- writeln('hey you have picked up from that ship an extra item !');
- ex:=ex+1;
- end else if pickup=21 then
- begin
- writeln('hey you have picked up from that ship an boom item !');
- bom:=bom+1;
- end else if pickup=144 then
- begin
- writeln('hey you have picked up from that ship an rada item !');
- rada:=rada+1;
- end else if pickup=300 then
- begin
- writeln('lucky for you, an bonus coin : + 20 $');
- coin:=coin+20;
- end;
- readln;
- assign(o,finp); rewrite(o);
- writeln(o,coin);
- writeln(o,ex);
- writeln(o,bom);
- writeln(o,rada);
- close(o);
- end else
- if (b[i,j]='^') then
- begin
- clrscr;
- live2:=0;
- writeln('we hit the leader ship !');
- delay(2000);
- writeln('victory is our ');
- writeln('press enter');
- readln;
- exit;
- end
- else c[i,j]:='0';
- end;
- clrscr;
- writeln('opponent''s turn :');
- for count:=1 to 2 do
- begin
- complay(i,j);
- if (a[i,j]='#') then
- begin
- writeln('they hit it');
- writeln('we have ',live1-1,' ship');
- live1:=live1-1;
- a[i,j]:='x';
- readln;
- end
- else
- if (a[i,j]='^') then
- begin
- live1:=0;
- writeln('Nooo ! Our leader has fallen');
- delay(2000);
- writeln('the captain rest in peace !');
- delay(2000);
- writeln('fall back men we lose !');
- delay(2000);
- print(a);
- repeat until keypressed;
- for i:=1 to 9 do for j:=1 to 9 do
- begin
- a[i,j]:='~';
- a2[i,j]:='0';
- a1[i,j]:='0';
- end;
- exit;
- end
- else a[i,j]:='0';
- writeln('_they fired at ',i,' ',j,'_');
- end;
- writeln;
- writeln('OUR SEA: ');
- print(a);
- repeat until keypressed;
- until (live1=0)or(live2=0);
- if (d=2)and(live1=0) then
- begin
- write('wait you can add extra ship : '); readln(i,j);
- while (i<1)or(j<1)or(i>9)or(j>9)or(not fin(a2,i,j)) do
- begin
- write('add again: '); readln(i,j);
- end;
- a[i,j]:='#';
- a2[i,j]:='0';
- print(a);
- live1:=1;
- letsplay;
- end;
- end;
- procedure theend;
- begin
- if live1=0 then
- begin
- writeln(' the battle was so rude !');
- delay(1000);
- writeln(' but that"s ok ');
- delay(1000);
- writeln(' try hard next time ! ');
- delay(1000);
- write('press enter');
- repeat until keypressed;
- end
- else if live2=0 then
- begin
- writeln(' good job captain !');
- delay(1000);
- writeln(' wish you luck everytime !');
- delay(1000);
- write('press enter');
- clrscr;
- writeln('you now have : ',coin+m,' coin ! ');
- repeat until keypressed;
- end;
- assign(f,finp); rewrite(f);
- writeln(f,coin+m);
- writeln(f,ex);
- writeln(f,bom);
- writeln(f,rada);
- close(f);
- end;
- begin
- clrscr;
- textbackground(white);
- tile;
- textcolor(black);
- repeat
- textbackground(white);
- menu;
- add;
- clrscr;
- live1:=n;
- live2:=m;
- writeln;
- comadd;
- clrscr;
- textbackground(yellow);
- letsplay;
- clrscr;
- theend;
- until answer=4;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement