Programalama > JAVA - JSP

program snake29;
uses crt;

const
left=#75;
right=#77;
up=#72;
down=#80;
Esc=#27;
var
Ch : Array [1..20,1..40] of char;
Name : Array [1..6] of String;
HiScore : Array [1..6] of integer;
AHead,BHead : Array [1..15000] of integer;
a,b,aFood,bFood,i,k,j,iTail,iCounter,iCrash,iGained,xGamble,yGamble,
iLastScore,iList,iLive,iLifeScore,iMove,iScore,iTemp,Color,iLevel,iFactor,iChance : integer;
StTemp,User : String[10];
ChLevel,Decision,key,KeyControl : Char;
Lock,Pause,SoundLock : Boolean;

Procedure CreateFrame;
begin
 gotoxy(19,9);
 write('ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ SNAKE ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»');
 for i:=10 to 16 do
 begin
 gotoxy(19,i);
 write('º                                        º');
 end;
 gotoxy(19,17);
 write('º          ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»          º');
 gotoxy(19,18);
 write('º          º                  º          º');
 gotoxy(19,19);
 write('ÈÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍͼ');
end;


begin
randomize;
clrscr;

textcolor(11);
gotoxy(25,13);
write('*** LUCKY SNAKE ***');
gotoxy(24,15);
textcolor(9);
write('a Mr.Stork Production...');
textcolor(15);

readkey;

textcolor(15);
iCounter:=1;
clrscr;
writeln('Please write your name!');
readln(User);
iList:=6;      {It is 6,because we have 5 people in hi-score list.}
Name[iList]:=User;
clrscr;

iLevel:=3;
iFactor:=3;
iLifeScore:=1500;
SoundLock:=True;
repeat
 clrscr;
 iLive:=2;

 CreateFrame;

 gotoxy(21,10);
 writeln('What would you like to do ',User,'?');
 gotoxy(21,11);
 writeln('1. Let us roll!');
 gotoxy(21,12);
 writeln('2. I will decide how fast I am !');
 gotoxy(21,13);
 writeln('3. I wonder who is the best?');
 gotoxy(21,14);
 writeln('4. New player');
 gotoxy(21,15);
 writeln('5. Sound Option');
 gotoxy(21,16);
 writeln('6. Quit');

 repeat
  for k:=1 to 500 do
  begin
   gotoxy(31,18);
   Write('                  º');
   delay(20000);
   gotoxy(31,18);
   write('*** GOOD LUCK *** º');
   if KeyPressed then Break;
   delay(60000);
  end;
  Decision:=Readkey;

  if Decision='1' then
  begin
   if SoundLock=True then
    begin
     for i:=1 to 3 do
     begin
      if KeyPressed then Break;
      delay(30000);      {Start Music}
      sound(100);
      delay(30000);
      sound(150);
      delay(30000);
      sound(200);
      delay(30000);
      sound(75);
      delay(30000);
      sound(175);
      delay(30000);
      NoSound;
     end;
    end;
  end;
 until(Decision in ['1','2','3','4','5','6'] );

 case Decision of
  '1' :
       begin
        repeat {That is for lives}
         clrscr;
         gotoxy(21,12);
         writeln('PRESS ENTER WHEN YOU ARE READY! ',User);
         readln;

         if (i>j) then
          begin
           for a:=1 to 1500 do
           begin
            AHead[a]:=0;
            BHead[a]:=0;
           end
          end
          else
           for a:=1 to 1500 do
           begin
            AHead[a]:=0;
            BHead[a]:=0;
           end;

         clrscr;
         writeln('ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»');

         for i:=1 to 20 do
         begin
          writeln('º                                        º º                       º ');
         end;

         writeln('ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ');

         gotoxy(45,4);
         write('Score:        ');
         gotoxy(45,4);
         write('Score: ',iScore);
         gotoxy(45,6);
         write('Lives: ',iLive);
         gotoxy(45,8);
         iList:=1;
         write('Leader: ',Name[iList]);
         gotoxy(45,10);
         if (HiScore[iList]=0) then
          begin
           write('Hi-Score: ',iScore);
           gotoxy(45,8);
           write('Leader: ',User);
          end
         else
          begin
           write('Hi-Score: ',HiScore[iList]);
           gotoxy(45,8);
           write('Leader: ',Name[iList]);
          end;
         a:=1;
         b:=1;
         i:=10;
         aFood:=10;
         bFood:=16;
         gotoxy(bFood,aFood);
         textcolor(13);
         write('~');

         for j:=2 to 4 do
         begin
          AHead[a]:=i;
          BHead[b]:=j;
          Ch[i,j]:='';
          gotoxy(j,i);
          write(Ch[i,j]);
          a:=a+1;
          b:=b+1;
         end;

         key:=Right;
         iTail:=1;

         repeat
          iList:=6;
          Name[iList]:=User;

          repeat                   {If it is alive,go on}
           delay(60000 div iLevel);
           gotoxy(45,2);
           write(User);
           Lock:=True;

           KeyControl:=Key;

           if KeyPressed then
            begin
             key:=Readkey;
            end;

           if (key=#0) then
            begin
             key:=Readkey;
            end;

           if ((key<>Up) or (key<>Down) or (key<>Right) or (key<>Left) or (key<>Esc))  {This control is for monkey touching}
			                                and
			     ((key<>Up) and (key<>Down) and (key<>Right) and (key<>Left) and (key<>Esc)) then
			   Key:=KeyControl;

           case key of
            Right: j:=j+1;     {Right}

            Left : j:=j-1;     {Left}

            Up   : i:=i-1;     {Up}

            Down : i:=i+1;     {Down}

            Esc  : begin
                    gotoxy(50,18);
                    write('PAUSED');
                    gotoxy(46,20);
                    write(' 1. QUIT ');
                    gotoxy(46,21);
                    write(' 2. Continue ');

                    repeat
                     Decision:=Readkey;
                    until (Decision in ['1','2']);

                    case Decision of
                     '1' : EXIT;
                     '2' : Pause:=True;
                    end;

                    if (Pause=True) then
				   	   begin
                      key:=KeyControl;
                      gotoxy(50,18);
                      write('       ');
                      gotoxy(45,20);
                      write('         ');
                      gotoxy(45,21);
                      write('             ');
							 Continue;
                     end;


                   end;
           end;

           if (i>21) or (i<2) or (j>41) or (j<2) then Continue; {If it runs into the wall,stop!}

           for iCrash:=a downto iTail do
           begin
            if (AHead[iCrash]=i) and (BHead[iCrash]=j) then {We'll use this statement again!Don't forget!}
             begin
	           Lock:=False;
              break;        {Gives up the loop if the snake bites itself}
             end;
           end;

           if Lock=True then  {If it eats itself,we cannot open this}
            begin
             gotoxy(j,i);
             Ch[i,j]:='';
             write(Ch[i,j]);

             AHead[a]:=i;
             BHead[b]:=j;
             a:=a+1;
             b:=b+1;
             iMove:=iMove + 1;

             if (iMove=65) then
              begin
				   Ch[xGamble,yGamble]:=' ';
               gotoxy(46,12);
               write('                     ');
               gotoxy(yGamble,xGamble);
               write(Ch[xGamble,yGamble]);
               xGamble:=50;
               yGamble:=50;
               gotoxy(45,14);
               write('                      ');
              end;

             if (iCounter mod 6=0) then
              begin
               repeat
                xGamble:=Random(20);
                yGamble:=Random(40);
                iChance:=Random(2);
                for iCrash:=a downto iTail do
                 if (AHead[iCrash]=xGamble) and (BHead[iCrash]=yGamble) then Break;

               until (xGamble > 1) and (yGamble > 1) and (AHead[iCrash]<>xGamble) and (BHead[iCrash]<>yGamble);
               Ch[xGamble,yGamble]:='?';
               gotoxy(yGamble,xGamble);
               write(Ch[xGamble,yGamble]);
               gotoxy(46,12);
               write('ARE YOU BRAVE ENOUGH?');
               iGained:=Random(250);
               iCounter:=iCounter + 1;
               iMove:=0;
              end;

             if (xGamble=i) and (yGamble=j) then
              begin
               gotoxy(45,4);
               write('Score:         ');
               gotoxy(45,4);
               write('Score: ',iScore);
               Ch[xGamble,yGamble]:='';
               gotoxy(46,12);
               write('                     ');
               if (iChance=1) then
                begin
                 iScore:=iScore + iGained;
                 gotoxy(46,12);
                 write('YOU HAVE BONUS!');
                end;
               if (iChance=0) then
                begin
                 iScore:=iScore - iGained;
                 gotoxy(46,12);
                 write('HA-HAH! YOU LOSE :-D');
                end;
               gotoxy(yGamble,xGamble);
					write(Ch[xGamble,yGamble]);
               xGamble:=50;
               yGamble:=50;
              end;

             if (aFood=i) and (bFood=j) then
              begin
               iCounter:=iCounter + 1;
               gotoxy(bFood,aFood);
               write('');
               iScore:=iScore + (10 * iFactor);
               if (iScore > iLifeScore) then
                begin
                 iLive:=iLive + 1;    {HEEY!We have one more life!}
                 gotoxy(45,14);
                 write('WELL DONE! EXTRA LIFE!');
                 iLifeScore:=iLifeScore + 1500;
                 gotoxy(45,6);
                 write('Lives: ',iLive);
                end;
               gotoxy(45,4);

               if SoundLock=True then
                begin
                 delay(30000);     {Music part when the snake feeds}
                 sound(200);
                 delay(10000);
                 sound(150);
                 delay(10000);
                 sound(150);
                 delay(30000);
                 sound(300);
                 delay(30000);
                 NoSound;
                end;
               write('Score:     ');
               textcolor(15);
               gotoxy(45,4);
            	write('Score: ',iScore);
               iList:=1;
               if (iScore > HiScore[iList]) then
                begin
                 gotoxy(45,10);
                 write('Hi-Score:     ');
                 gotoxy(45,10);
                 write('Hi-Score: ',iScore);
                 gotoxy(45,8);
                 write('Leader: ',User);
                end
               else
                begin
                 gotoxy(45,10);
                 write('Hi-Score:     ');
                 gotoxy(45,10);
                 write('Hi-Score: ',HiScore[iList]);
                 gotoxy(45,8);
                 write('Leader: ',Name[iList]);
                end;
               repeat
                aFood:=random(19);
                bFood:=random(39);
                for iCrash:=a downto iTail do
                 if (AHead[iCrash]=aFood) and (BHead[iCrash]=bFood) then break;

               until ( (aFood>1) and (bFood>1) ) and ( (AHead[iCrash]<>aFood) and (BHead[iCrash]<>bFood) );
               gotoxy(bFood,aFood);
               Ch[aFood,bFood]:='~';
               repeat
                Color:=random(15);
               until (Color > 8);
               textcolor(Color);
               write(Ch[aFood,bFood]);
               Continue;
              end;

              gotoxy(BHead[iTail],AHead[iTail]);
              Ch[AHead[iTail],BHead[iTail]]:=' ';
              write(Ch[AHead[iTail],BHead[iTail]]);
              iTail:=iTail + 1;

            end; {End of Boolean}

          until ( (i>21) or (i<2) or (j>41) or (j<2) ) or ( (AHead[iCrash]=i) and (BHead[iCrash]=j) );
          if (i>21) or (i<2) or (j>41) or (j<2) then
           begin
            if SoundLock=True then
             begin
              for i:=1 to 3 do
              begin
               delay(30000);
               sound(100);
               delay(30000);
               sound(125);
               delay(30000);
               sound(75);
               delay(60000);
               NoSound;
              end;
             end;
             Break;
           end;

          if (AHead[iCrash]=i) and (BHead[iCrash]=j) then
           begin
            if SoundLock=True then
             begin
              for i:=1 to 3 do
              begin
               sound(350);
               delay(60000);
               sound(150);
               delay(60000);
               sound(70);
               delay(60000);
               NoSound;
              end;
             end;
             Break;
           end;

         until KeyPressed;
         iLive:=iLive - 1;
        until (iLive=0);
        gotoxy(20,8);
        textcolor(28);
        write('GAME OVER');
        gotoxy(8,13);
        write('Press any key to return menu..!');
        Readkey;
        textcolor(15);
        iList:=6;
        HiScore[iList]:=iScore;
        iScore:=0;
        for iList:=1 to 6 do
         for k:=iList + 1 to 6 do
         begin
          if (HiScore[k] > HiScore[iList]) then
           begin
            iTemp:=HiScore[iList];
            HiScore[iList]:=HiScore[k];
            HiScore[k]:=iTemp;

            {Score is ordered,let's order the name!}

            StTemp:=Name[iList];
            Name[iList]:= Name[k];
            Name[k]:=StTemp;
           end;
         end;

       end;           {End of game part}

  '2' :
      begin
       clrscr;
       CreateFrame;
       gotoxy(20,11);
       writeln('1. Probably I can beat a turtle!');
       gotoxy(20,12);
       writeln('2. Let us run a little faster!');
       gotoxy(20,13);
       writeln('3. I feel as if I was a cheetah');
       gotoxy(20,14);
       writeln('4. Wind is my nickname!');
       gotoxy(20,15);
       writeln('5. My only opponent is Turkish Airlines!');

        repeat
         for k:=1 to 500 do
         begin
         gotoxy(31,18);
         Write('                  º');
         delay(20000);
         gotoxy(31,18);
         write('** CHOOSE LEVEL **º');
         if KeyPressed then Break;
         delay(60000);
         end;
         ChLevel:=Readkey;
        until(ChLevel in ['1','2','3','4','5'] );

       case ChLevel of
        '1': begin
		        iLevel:=1;
              iFactor:=1;
             end;

        '2': begin
		        iLevel:=2;
              iFactor:=2;
             end;

        '3': begin
		        iLevel:=3;
              iFactor:=3;
             end;

        '4': begin
		        iLevel:=4;
              iFactor:=4;
             end;

        '5': begin
		        iLevel:=5;
              iFactor:=5;
             end;
       end;
      end;

  '3' :
     begin                     {Outputs hi-score list}
      clrscr;
      for iList:=1 to 5 do
      begin
       writeln(iList,'. ',Name[iList],' ',HiScore[iList]);
      end;
      readkey;
     end;

  '4' : begin
         clrscr;
         writeln('Welcome!..Please write your name');
         readln(User);
         iList:=6;
         name[iList]:=User;
        end;

  '5' : begin
         clrscr;
         writeln('1. Sound on');
         writeln('2. Sound off');

         repeat
          Decision:=Readkey;
         until (Decision in ['1','2']);

         case Decision of
          '1' : SoundLock:=True;

          '2' : SoundLock:=False;
         end;
        end;

  '6' : begin
         clrscr;
         gotoxy(25,13);
         textcolor(red);
         for i:=1 to 2 do
         begin
          clrscr;                        {I just wanted it's to seem a little more}
          gotoxy(25,13);
          write('TO BE CONTINUED...');
          Delay(65000);
         end;
        end;

 end;

until (Decision='6');

end.

{written by mr.stork}
{mr.stork@mynet.com}


Yorumlar                 Yorum Yaz
mbruce44 (0) Sakıncalı Yorum 05 March 16:32
la programlama bilmesek bunu yiyecez bu java değil pascal ile yazılmış bu kodlar bende var bir ara pascal ile program yzıyodum.
KATEGORİLER
ASP - 240
ASP.NET - 24
C# - 75
C++ - 174
CGI - 8
DELPHI - 247
FLASH - 49
HTML - 536
PASCAL - 246
PERL - 11
PHP - 160
WML - 9
XML - 2
Copyright © 2002 - 2024 Hazır Kod - Tüm Hakları Saklıdır.
Siteden yararlanırken gizlilik ilkelerini okumanızı tavsiye ederiz.
hazirkod.com bir İSOBİL projesidir.