home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / games / qikserve.zip / QIKSERVE.PAS < prev    next >
Pascal/Delphi Source File  |  1987-11-30  |  19KB  |  720 lines

  1. Program QikServe;
  2.  
  3. {$C- }
  4.  
  5. {$i Graph.p }
  6.  
  7. const
  8.    ycounter : array[1..4] of integer =
  9.               (67,105,146,185);
  10.    ymachine : array[1..4] of integer =
  11.               (51,89,130,169);
  12.    centeradj = -1;
  13.    rightadj  = -2;
  14.  
  15. type
  16.    stype = string[15];
  17.    words = string[80];
  18.    data0 = record
  19.               pict : array[0..2700] of real;
  20.            end;
  21.    data1 = record
  22.               shp : array[0..200] of integer;
  23.            end;
  24.    data2 = record
  25.               xp,yp,person,want,yell  : integer;
  26.               eatmove,eating,onscreen : boolean;
  27.            end;
  28.    data3 = record
  29.               fx,fy,kind : integer;
  30.               moving     : boolean;
  31.            end;
  32.  
  33. var
  34.    ch           : char;
  35.    screen       : data0;
  36.    pic          : array[1..21] of data1;
  37.    xpic         : array[0..2] of data1;
  38.    people       : array[1..10] of data2;
  39.    food         : array[1..10] of data3;
  40.    score,c,
  41.    guys,cy,
  42.    foodturn,
  43.    peopleturn,
  44.    total,smoke,
  45.    smoketime    : integer;
  46.    smoking,left : boolean;
  47.  
  48.  
  49. function st(h :integer) : stype;
  50. var
  51.    chaa : stype;
  52. begin
  53.    str(h,chaa);
  54.    st := chaa;
  55. end;
  56.  
  57.  
  58. function vl(h :stype) : integer;
  59. var
  60.    d,e : integer;
  61. begin
  62.    val(h,d,e);
  63.    vl := d;
  64. end;
  65.  
  66.  
  67. function findopen : integer;
  68. var
  69.    d,e : integer;
  70. begin
  71.    e := 0;
  72.    for d := 10 downto 1 do
  73.       if not food[d].moving
  74.          then e := d;
  75.    findopen := e;
  76. end;
  77.  
  78.  
  79. function level : integer;
  80. var
  81.    d : integer;
  82. begin
  83.    d := 0;
  84.    case cy of
  85.      67 : d := 1;
  86.     102 : d := 2;
  87.     142 : d := 3;
  88.     182 : d := 4;
  89.    end;
  90.    level := d;
  91. end;
  92.  
  93.  
  94. function speed : integer;
  95. var
  96.    d : integer;
  97. begin
  98.    d := (score div 100) + 2;
  99.    if d>10
  100.       then d := 10;
  101.    speed := d;
  102. end;
  103.  
  104.  
  105. procedure inkey;
  106. begin
  107.    if keypressed
  108.       then read(kbd,ch)
  109.       else ch := #0;
  110.    if (ch=#27) and not keypressed
  111.       then
  112.          begin
  113.             textmode(c80);
  114.             textcolor(7);
  115.             clrscr;
  116.             halt;
  117.          end;
  118.    ch := upcase(ch);
  119. end;
  120.  
  121.  
  122. procedure click;
  123. begin
  124.    sound(1000);
  125.    nosound;
  126. end;
  127.  
  128.  
  129. procedure beep;
  130. begin
  131.    sound(100);
  132.    delay(300);
  133.    nosound;
  134. end;
  135.  
  136.  
  137. procedure clearbuffer;
  138. begin
  139.    while keypressed do
  140.       read(kbd,ch);
  141.    ch := #0;
  142. end;
  143.  
  144.  
  145. procedure getshapes;
  146. var
  147.    fil1  : text;
  148.    fil2  : file of data0;
  149.    d,e,f : integer;
  150. begin
  151.    assign(fil1,'QikServe.shp');
  152.    reset(fil1);
  153.    for d := 1 to 21 do
  154.       with pic[d] do
  155.          begin
  156.             read(fil1,shp[0]);
  157.             read(fil1,shp[1]);
  158.             read(fil1,shp[2]);
  159.             e := (((shp[1]+3)div 4)*shp[2]*2+6)div 3;
  160.             for f := 3 to e-1 do
  161.                read(fil1,shp[f]);
  162.          end;
  163.    close(fil1);
  164.    assign(fil2,'QikServe.pic');
  165.    reset(fil2);
  166.    read(fil2,screen);
  167.    close(fil2);
  168. end;
  169.  
  170.  
  171. procedure putletter(px,py,color :integer; wword :words);
  172. const
  173.    wlet : array[1..66] of string[15] =
  174.           ('000000000000000','010010010000010','101101000000000',
  175.            '010111010111010','010111110011110','101001010100101',
  176.            '101010110101011','010010000000000','001010010010001',
  177.            '100010010010100','010111111111010','010010111010010',
  178.            '000000000010100','000000111000000','000000000000010',
  179.            '001001010100100','010101101101010','010110010010111',
  180.            '111001111100111','110001010001110','101101111001001',
  181.            '111100110001110','011100110101010','111001010010010',
  182.            '111101111101111','111101111001111','000000010000010',
  183.            '000010000010100','001010100010001','000111000111000',
  184.            '100010001010100','111001011000010','010111011101010',
  185.            '010101111101101','110101110101110','111100100100111',
  186.            '110101101101110','111100110100111','111100110100100',
  187.            '111100101101111','101101111101101','111010010010111',
  188.            '001001001101010','100101110101101','100100100100111',
  189.            '111111111101101','101111111101101','111101101101111',
  190.            '111101111100100','111101111010011','110101110101101',
  191.            '011100111001110','111010010010010','101101101101111',
  192.            '101101101101010','101101111111111','101101010101101',
  193.            '101101010010010','111001010100111','111100100100111',
  194.            '100110010001001','111001001001111','010101000000000',
  195.            '000000000000111','100010000000000','111111111111111');
  196. type
  197.    wletter = ' '..'a';
  198. var
  199.    aa,bb,cc,dd,ee : integer;
  200.    chara          : wletter;
  201. begin
  202.    if px=-1
  203.       then px := 160 - length(wword) * 7  div 2
  204.       else if px=-2
  205.               then px := 319 - length(wword)*7;
  206.    for aa := 1 to length(wword) do
  207.       begin
  208.          if copy(wword,aa,1)='█'
  209.             then chara := 'a'
  210.             else chara := upcase(copy(wword,aa,1));
  211.          bb := ord(chara);
  212.          for cc := 0 to 4 do
  213.             for dd := 0 to 2 do
  214.                if copy(wlet[bb-31],cc*3+(dd+1),1)='1'
  215.                   then case color of
  216.                            0 : draw(dd*2+px,cc+py,dd*2+px+1,cc+py,0);
  217.                            1 : draw(dd*2+px,cc+py,dd*2+px+1,cc+py,1);
  218.                            2 : draw(dd*2+px,cc+py,dd*2+px+1,cc+py,2);
  219.                            3 : draw(dd*2+px,cc+py,dd*2+px+1,cc+py,3);
  220.                            4 : begin
  221.                                   plot(dd*2+px,cc+py,0);
  222.                                   plot(dd*2+px+1,cc+py,1);
  223.                                end;
  224.                            5 : begin
  225.                                   plot(dd*2+px,cc+py,0);
  226.                                   plot(dd*2+px+1,cc+py,2);
  227.                                end;
  228.                            6 : begin
  229.                                   plot(dd*2+px,cc+py,0);
  230.                                   plot(dd*2+px+1,cc+py,3);
  231.                                end;
  232.                            7 : begin
  233.                                   plot(dd*2+px,cc+py,1);
  234.                                   plot(dd*2+px+1,cc+py,2);
  235.                                end;
  236.                            8 : begin
  237.                                   plot(dd*2+px,cc+py,1);
  238.                                   plot(dd*2+px+1,cc+py,3);
  239.                                end;
  240.                            9 : begin
  241.                                   plot(dd*2+px,cc+py,2);
  242.                                   plot(dd*2+px+1,cc+py,3);
  243.                                end;
  244.                        end;
  245.          px := px + 7;
  246.       end;
  247.    c := px;
  248. end;
  249.  
  250.  
  251. procedure titlescreen;
  252. const
  253.    name = 'QikServe';
  254. var
  255.    x,y,d,e : integer;
  256. begin
  257.    graphcolormode;
  258.    palette(2);
  259.    graphbackground(1);
  260.    clearscreen;
  261.    randomize;
  262.    getpic(xpic[1].shp,0,0,9,9);
  263.    getpic(xpic[2].shp,0,0,19,19);
  264.    for d := 1 to length(name) do
  265.       begin
  266.          x := random(40)+1;
  267.          y := random(24)+1;
  268.          while not((x=d*2+11) and (y=12)) do
  269.             begin
  270.                gotoxy(x,y); write(' ');
  271.                if x<d*2+11
  272.                   then x := x + 1
  273.                   else if x>d*2+11
  274.                           then x := x - 1;
  275.                if y<12
  276.                   then y := y + 1
  277.                   else if y>12
  278.                           then y := y - 1;
  279.                gotoxy(x,y); write(copy(name,d,1));
  280.                for e := 1 to d-1 do
  281.                   begin
  282.                      gotoxy(e*2+11,12);
  283.                      write(copy(name,e,1));
  284.                   end;
  285.                delay(20);
  286.             end;
  287.          sound(1000);
  288.          delay(10);
  289.          nosound;
  290.       end;
  291.    putletter(centeradj,100,3,'By Scott Ramsay');
  292.    putletter(90,180,1,'Press ');
  293.    putletter(c,180,2,'ESC ');
  294.    putletter(c,180,1,'anytime quit');
  295.    putletter(centeradj,187,1,'or press any other key to continue.');
  296.    clearbuffer;
  297.    repeat
  298.       inkey;
  299.    until ch<>#0;
  300. end;
  301.  
  302.  
  303. procedure gamescreen;
  304. begin
  305.    putpic(screen.pict,0,199);
  306. end;
  307.  
  308.  
  309. procedure printscore;
  310. var
  311.    d : integer;
  312. begin
  313.    putletter(46,24,0,'██████');
  314.    for d := 0 to 5-length(st(score)) do
  315.       putletter(d*7+46,24,6,'0');
  316.    putletter(c,24,6,st(score));
  317. end;
  318.  
  319.  
  320. procedure printchances;
  321. var
  322.    d : integer;
  323. begin
  324.    putletter(207,24,0,'██');
  325.    for d := 0 to 1-length(st(guys)) do
  326.       putletter(d*7+207,24,6,'0');
  327.    putletter(c,24,6,st(guys));
  328. end;
  329.  
  330.  
  331. procedure setup;
  332. var
  333.    d : integer;
  334. begin
  335.    total := 3;
  336.    score := 0;
  337.    guys := 6;
  338.    cy := 67;
  339.    smoke := 0;
  340.    smoking := true;
  341.    smoketime := 0;
  342.    left := true;
  343.    foodturn := 0;
  344.    peopleturn := 0;
  345.    for d := 1 to 10 do
  346.       people[d].onscreen := false;
  347.    for d := 1 to 10 do
  348.       food[d].moving := false;
  349.    putpic(pic[5].shp,25,cy);
  350.    colortable(0,2,1,3);
  351.    putpic(pic[20].shp,25,cy+20);
  352.    colortable(0,1,2,3);
  353.    printchances;
  354.    printscore;
  355.    clearbuffer;
  356.    putletter(centeradj,50,3,'press any key to play');
  357.    repeat
  358.       inkey;
  359.    until ch<>#0;
  360.    putletter(centeradj,50,0,'press any key to play');
  361. end;
  362.  
  363.  
  364. procedure smokeoff(h : integer);
  365. begin
  366.    putpic(xpic[1].shp,3,ymachine[h]);
  367.    putpic(xpic[1].shp,10,ymachine[h]-4);
  368.    putpic(xpic[1].shp,0,ymachine[h]-6);
  369. end;
  370.  
  371.  
  372. procedure smokepuff(var h :integer);
  373. begin
  374.    if h<>0
  375.       then
  376.          begin
  377.             if smoking
  378.                then
  379.                   begin
  380.                      if random<0.3
  381.                         then putpic(pic[19].shp,3,ymachine[h])
  382.                         else if random<0.6
  383.                                 then putpic(pic[19].shp,10,ymachine[h]-4)
  384.                                 else putpic(pic[19].shp,0,ymachine[h]-6);
  385.                   end
  386.                else smokeoff(h);
  387.             smoking := not smoking;
  388.             smoketime := smoketime - 1;
  389.             if smoketime=0
  390.                then
  391.                   begin
  392.                      smokeoff(h);
  393.                      h := 0;
  394.                   end;
  395.          end;
  396. end;
  397.  
  398.  
  399. procedure setfood;
  400. var
  401.    d : integer;
  402. begin
  403.    putpic(pic[6].shp,25,cy);
  404.    d := findopen;
  405.    with food[d] do
  406.       begin
  407.          kind := vl(ch);
  408.          fx := 50;
  409.          fy := ycounter[level];
  410.          moving := true;
  411.          putpic(pic[kind].shp,fx,fy);
  412.       end;
  413.    for d := 1 to 4 do
  414.       smokeoff(d);
  415.    smoke := level;
  416.    smoketime := 10;
  417.    putpic(pic[5].shp,25,cy);
  418.    clearbuffer;
  419. end;
  420.  
  421.  
  422. procedure getkey;
  423. begin
  424.    if (ch in ['1','2','3']) and (findopen<>0) and (cy in [67,102,142,182])
  425.       then setfood;
  426.    if (ch=#27) and keypressed
  427.       then
  428.          begin
  429.             read(kbd,ch);
  430.             putpic(xpic[2].shp,25,cy);
  431.             putpic(xpic[2].shp,25,cy+20);
  432.             if ch='H'
  433.                then cy := cy - 5
  434.                else if ch='P'
  435.                        then cy := cy + 5;
  436.             if cy<67
  437.                then cy := 182
  438.                else if cy>182
  439.                        then cy := 67;
  440.             if ch in ['H','P']
  441.                then
  442.                   begin
  443.                      left := not left;
  444.                      click;
  445.                   end;
  446.             putpic(pic[5].shp,25,cy);
  447.             if level<>0
  448.                then colortable(0,2,1,3);
  449.             if left
  450.                then putpic(pic[20].shp,25,cy+20)
  451.                else putpic(pic[21].shp,25,cy+20);
  452.             if level<>0
  453.                then colortable(0,1,2,3);
  454.          end;
  455. end;
  456.  
  457.  
  458. procedure loseguy;
  459. var
  460.    d : integer;
  461. begin
  462.    delay(1500);
  463.    for d := 1 to 10 do
  464.       with food[d] do
  465.         if moving
  466.            then
  467.               begin
  468.                  putpic(xpic[1].shp,fx,fy);
  469.                  moving := false;
  470.               end;
  471.    for d := 1 to total do
  472.       with people[d] do
  473.         if onscreen
  474.            then
  475.               begin
  476.                  putpic(xpic[2].shp,xp,ycounter[yp]);
  477.                  if yell<6
  478.                     then putpic(xpic[2].shp,xp-20,ycounter[yp]-7);
  479.                  onscreen := false;
  480.               end;
  481.    for d := 1 to 4 do
  482.       smokeoff(d);
  483.    guys := guys - 1;
  484.    printchances;
  485.    if guys<>0
  486.       then
  487.          begin
  488.             for d := 1 to 5 do
  489.                begin
  490.                   putletter(-1,40,(d mod 2)+1,'Get Ready');
  491.                   sound(1000);
  492.                   delay(40);
  493.                   nosound;
  494.                   delay(200);
  495.               end;
  496.             putletter(-1,40,0,'Get Ready');
  497.          end;
  498.    clearbuffer;
  499. end;
  500.  
  501.  
  502. procedure checkforperson;
  503. var
  504.    d : integer;
  505. begin
  506.    for d := 1 to total do
  507.       with people[d],food[foodturn] do
  508.          if onscreen and not eating
  509.             then if (fy=ycounter[yp]) and (abs(fx-xp)<15) and (want=kind)
  510.                     then
  511.                        begin
  512.                           if yell<6
  513.                              then putpic(xpic[2].shp,xp-20,ycounter[yp]-7);
  514.                           moving := false;
  515.                           eating := true;
  516.                           eatmove := (random<0.2);
  517.                           score := score + 10;
  518.                           printscore;
  519.                           sound(1000);
  520.                           delay(40);
  521.                           nosound;
  522.                        end;
  523. end;
  524.  
  525.  
  526. procedure lostfood;
  527. const
  528.    fn : array[1..3] of stype =
  529.         ('a hamburger','a shake','fries');
  530. var
  531.    d : integer;
  532. begin
  533.    putletter(-1,33,2,'Lost '+fn[food[foodturn].kind]+'!');
  534.    for d := 2000 downto 100 do
  535.       sound(d);
  536.    nosound;
  537.    with food[foodturn] do
  538.        for d := fy div 5 to 199 div 5 do
  539.           begin
  540.              getpic(xpic[0].shp,fx,d*5,fx+9,d*5-9);
  541.              putpic(pic[kind].shp,fx,d*5);
  542.              delay(30);
  543.              putpic(xpic[0].shp,fx,d*5);
  544.           end;
  545.    loseguy;
  546.    putletter(-1,33,0,'Lost '+fn[food[foodturn].kind]+'!');
  547. end;
  548.  
  549.  
  550. procedure movefood;
  551. begin
  552.    foodturn := foodturn + 1;
  553.    if foodturn=11
  554.       then foodturn := 1;
  555.    with food[foodturn] do
  556.       if moving
  557.          then
  558.             begin
  559.                putpic(xpic[1].shp,fx,fy);
  560.                fx := fx + 10;
  561.                checkforperson;
  562.                if fx>309
  563.                   then
  564.                      begin
  565.                         moving := false;
  566.                         lostfood;
  567.                      end
  568.                   else if moving
  569.                           then putpic(pic[kind].shp,fx,fy);
  570.             end;
  571. end;
  572.  
  573.  
  574. procedure personmad;
  575. begin
  576.    putletter(-1,33,2,'person mad!');
  577.    beep;
  578.    loseguy;
  579.    putletter(-1,33,0,'person mad!');
  580. end;
  581.  
  582.  
  583. function closeto(h :integer) : boolean;
  584. var
  585.    d : integer;
  586. begin
  587.    closeto := false;
  588.    for d := 1 to 10 do
  589.       with people[d] do
  590.          if (d<>h) and (xp>265) and (yp=people[h].yp)
  591.             then closeto := true;
  592. end;
  593.  
  594.  
  595. procedure movepeople;
  596. var
  597.    d,e : integer;
  598. begin
  599.    total := (score div 150) + 3;
  600.    if total>10
  601.       then total := 10;
  602.    peopleturn := peopleturn + 1;
  603.    if peopleturn=total+1
  604.       then peopleturn := 1;
  605.    for e := 1 to total do
  606.       with people[e] do
  607.          if not onscreen and (random(300)=0)
  608.             then
  609.                begin
  610.                   onscreen := true;
  611.                   eating := false;
  612.                   xp := 296;
  613.                   d := 0;
  614.                   repeat
  615.                      d := d + 1;
  616.                      yp := random(4)+1;
  617.                   until (d=10) or not closeto(e);
  618.                   yell := 0;
  619.                   want := random(3)+1;
  620.                   person := random(6)+1;
  621.                   putpic(pic[person*2+5].shp,xp,ycounter[yp]);
  622.                end;
  623.    with people[peopleturn] do
  624.       if onscreen
  625.          then
  626.             begin
  627.                if not eating
  628.                   then
  629.                      begin
  630.                         if yell<6
  631.                            then putpic(xpic[2].shp,xp-20,ycounter[yp]-7);
  632.                         yell := random(50);
  633.                         putpic(xpic[2].shp,xp,ycounter[yp]);
  634.                         xp := xp - random(speed);
  635.                         if xp<50
  636.                            then
  637.                               begin
  638.                                  onscreen := false;
  639.                                  personmad;
  640.                               end
  641.                            else
  642.                               begin
  643.                                  putpic(pic[person*2+5].shp,xp,ycounter[yp]);
  644.                                  if yell<6
  645.                                     then
  646.                                        begin
  647.                                           putpic(pic[4].shp,xp-20,ycounter[yp]-7);
  648.                                           putpic(pic[want].shp,xp-15,ycounter[yp]-15);
  649.                                           delay(80);
  650.                                        end;
  651.                               end;
  652.                      end
  653.                   else
  654.                      begin
  655.                          putpic(xpic[2].shp,xp,ycounter[yp]);
  656.                          if eatmove
  657.                             then xp := xp + 15;
  658.                          if xp>296
  659.                             then onscreen := false;
  660.                          if (random(50)=0) and not eatmove
  661.                             then
  662.                                begin
  663.                                   if (random<0.4) or (xp<140)
  664.                                      then eatmove := true
  665.                                      else
  666.                                         begin
  667.                                            eating := false;
  668.                                            want := random(3)+1;
  669.                                         end;
  670.                                end
  671.                             else if onscreen
  672.                                     then
  673.                                        begin
  674.                                           if random(200)<100
  675.                                              then putpic(pic[person*2+6].shp,xp,ycounter[yp])
  676.                                              else putpic(pic[person*2+5].shp,xp,ycounter[yp]);
  677.                                        end;
  678.                      end;
  679.             end;
  680. end;
  681.  
  682.  
  683. function gameover : boolean;
  684. begin
  685.    putletter(-1,50,3,'GAME OVER');
  686.    putletter(-1,90,1,'press space to play again');
  687.    putletter(-1,97,1,'or press any other key to quit');
  688.    clearbuffer;
  689.    repeat
  690.       inkey;
  691.    until ch<>#0;
  692.    gameover := (ch<>' ');
  693. end;
  694.  
  695.  
  696. procedure gamedone;
  697. begin
  698.    textmode(c80);
  699.    textcolor(7);
  700.    textbackground(0);
  701.    clrscr;
  702. end;
  703.  
  704.  
  705. begin
  706.    getshapes;
  707.    titlescreen;
  708.    repeat
  709.       gamescreen;
  710.       setup;
  711.       repeat
  712.          inkey;
  713.          getkey;
  714.          movefood;
  715.          movepeople;
  716.          smokepuff(smoke);
  717.       until guys=0;
  718.    until gameover;
  719.    gamedone;
  720. end.