home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / GAMETP.ZIP / SAMPLE.ZIP / RSAMPLE.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-10-30  |  27.8 KB  |  1,163 lines

  1. Program RSquid;
  2. {$X+ }
  3. {$M 38467,0,655360 }
  4.  
  5. { RSQUID Copyright 1992 by Scott D. Ramsay }
  6.  
  7. { Requires Turbo Pascal 6.0 and units:
  8.            VGAKERN.TPU
  9.            MISCFUNC.TPU
  10.            KEYBOARD.TPU
  11.            IMAGING.TPU
  12.            GMORPH.TPU
  13.            BEFFECTS.TPU
  14.            OOPOBJS.TPU                                             }
  15. {                                                                  }
  16. { I really don't feel like commenting this program.  Hopefully     }
  17. { most of the functions and procedures are self explanatory.       }
  18. {  I know it's sloppy coding, but I've tried to use all the        }
  19. { functions and I'm not out to win an award.                       }
  20. {  The Game pretty much covers almost all aspects of game program  }
  21. { except, for sound. (If you think this code is hacky, My          }
  22. { SoundBlaster code is terrible. ) But it actually works.  I'm     }
  23. { programming the card directly.  (Plug.) The unit will be ready   }
  24. { soon it will allow for two digitized voices played at once.      }
  25. { I.E. One background music, the other game SFX,  I don't like     }
  26. { programming the FM chip, (Besides I don't have any programs to   }
  27. { create any ROL,CMF,MID files).                                   }
  28. {  If you have any questions about the code, or help explain, send }
  29. { me e-mail at:                                                    }
  30. {        ramsays@express.digex.com                                 }
  31. {                                                                  }
  32. {  As an exersise "I sound like a teacher :( ", incorporate the    }
  33. { joystick unit into the program.                                  }
  34. {  As you can see, this program uses a lot of sprites, Look at the }
  35. { SETUP procedure.                                                 }
  36.  
  37. Uses Crt,VgaKern,MiscFunc,KeyBoard,Imaging,Gmorph,Beffects,OopObjs;
  38.  
  39. const
  40.   path    = '';
  41.   gmx     = 100;
  42.   gmy     = 50;
  43.   smx     = gmx shl 4-1;
  44.   smy     = gmy shl 4-1;
  45.   lvlbc   : array[0..5] of byte =
  46.             (186,80,233,239,222,208);
  47.  
  48. type
  49.   data1 = record
  50.             safe,flip,
  51.             vdx,vdy,guys,
  52.             vx,vy,drx    : integer;
  53.             lvls         : array[0..2] of integer;
  54.             score        : longint;
  55.             turn,blown   : boolean;
  56.           end;
  57.   pshot= ^tshot;
  58.   tshot = object(tobjs)
  59.             ndx,ndy  : integer;
  60.             constructor init;
  61.             procedure drawitemobject;virtual;
  62.             procedure calcitemobject;virtual;
  63.             function checkhit(hx,hy:integer):boolean;virtual;
  64.           end;
  65.   pgirl = ^tgirl;
  66.   tgirl = object(tshot)
  67.             goup,godown : boolean;
  68.             constructor init;
  69.             procedure calcitemobject; virtual;
  70.             procedure drawitemobject;virtual;
  71.             procedure checkplayertouch; virtual;
  72.           end;
  73.   pclod = ^tclod;
  74.   tclod = object(tshot)
  75.             constructor init;
  76.             procedure calcitemobject; virtual;
  77.             procedure drawitemobject;virtual;
  78.           end;
  79.   pnake = ^tnake;
  80.   tnake = object(tshot)
  81.             trn : boolean;
  82.             constructor init;
  83.             procedure drawitemobject;virtual;
  84.             function checkhit(hx,hy:integer):boolean;virtual;
  85.             procedure calcitemobject;virtual;
  86.             procedure checkplayertouch;virtual;
  87.           end;
  88.   psimm = ^tsimm;
  89.   tsimm = object(tnake)
  90.             constructor init;
  91.             procedure drawitemobject;virtual;
  92.             procedure checkplayertouch;virtual;
  93.           end;
  94.   PMyCycle = ^TMyCycle;
  95.   TMyCycle = object(Tcycle)
  96.                procedure cycle_move; virtual;
  97.              end;
  98.   PMyMorph = ^TMyMorph;
  99.   TMyMorph = object(TMorph)
  100.                function geomap(x,y:integer):integer;virtual;
  101.                procedure placegeo(x,y,geonum:integer;var geos);virtual;
  102.                procedure pre_map; virtual;
  103.                procedure post_map; virtual;
  104.              end;
  105.  
  106. var
  107.   drols,girls   : array[0..48] of pointer;
  108.   nakes         : array[0..116] of pointer;
  109.   simmers       : array[0..15] of pointer;
  110.   rsmisc        : array[0..17] of pointer;
  111.   gwmp,gpic,
  112.   nummo         : array[0..30] of pointer;
  113.   kill          : pkill;
  114.   nkbeg,nkend   : plist;
  115.   player        : data1;
  116.   map           : array[0..gmy-1,0..gmx-1] of byte;
  117.   girls_out     : integer;
  118.   blv           : shortint;
  119.   paused,warp   : boolean;
  120.   canchk        : word;
  121.   stx,geo_count,
  122.   ovx,ovy,gx,gy : integer;
  123.   oldexit       : pointer;
  124.   dac           : RGBlist;
  125.   MyCycle       : PMyCycle;
  126.   MyMorph       : PMyMorph;
  127.  
  128. procedure pause_ptr;external; { A VSP file using BINOBJ.EXE }
  129. {$l paused.obj }
  130.  
  131. procedure cleanup;far;
  132. begin
  133.   closemode;
  134.   exitproc := oldexit;
  135. end;
  136.  
  137.  
  138. procedure drawstatus(h:integer);
  139. var
  140.   xp : integer;
  141. begin
  142.   setpageactive(1);
  143.   xp := h shl 1+h+73;
  144.   with player do
  145.     begin
  146.       if lvls[h]<22
  147.         then
  148.           begin
  149.             if lvls[h]<1
  150.               then bar(xp,156,xp+1,178,lvlbc[h shl 1])
  151.               else bar(xp,156,xp+1,177-lvls[h],lvlbc[h shl 1]);
  152.           end;
  153.       if lvls[h]>0
  154.         then bar(xp,178-lvls[h],xp+1,178,lvlbc[h shl 1+1]);
  155.     end;
  156.   setpageactive(2);
  157. end;
  158.  
  159.  
  160. procedure page1stuff;
  161. var
  162.   p : plist;
  163.   d : integer;
  164. begin
  165.   setpageactive(2);
  166.   bar(14,155,63,178,0);
  167.   p := nkbeg;
  168.   while p<>nil do
  169.     with p^.item^ do
  170.       begin
  171.         if mapcolor<>0
  172.           then pset(14+nx shr 4 shr 1,155+ny shr 4 shr 1,mapcolor);
  173.         p := p^.next;
  174.       end;
  175.   with player do
  176.     pset(14+vx shr 4 shr 1,155+vy shr 4 shr 1,$c0);
  177.   fastwmatte(14,155,63,178,pages[2]^,pages[1]^);
  178.   for d := 0 to 2 do
  179.     drawstatus(d);
  180. end;
  181.  
  182.  
  183. procedure update;
  184. var
  185.   p : pointer;
  186. begin
  187.   if paused
  188.     then
  189.       begin
  190.         p := @pause_ptr; setpageactive(2);
  191.         fastput(98,64,p^);
  192.       end;
  193.   fastwmatte(13,20,172+128,179-32,pages[2]^,pages[1]^);
  194.   page1stuff;
  195. end;
  196.  
  197.  
  198. procedure ifix(var a:integer;min,max:integer);
  199. begin
  200.   if a<min
  201.     then a := min
  202.     else
  203.       if a>max
  204.         then a := max;
  205. end;
  206.  
  207.  
  208. procedure drawperson;
  209. var
  210.   nx,ny : integer;
  211. begin
  212.   with player do
  213.     begin
  214.       nx := 148; ny := 85-16;
  215.       if safe>0
  216.         then
  217.           begin
  218.             dec(nx,ord(safe<30)*random(4));
  219.             dec(ny,ord(safe<75)*random(2)-ord(safe<30)*random(4));
  220.           end;
  221.       if blown
  222.         then fbitdraw(nx,ny+4,rsmisc[2+flip]^)
  223.         else
  224.           case drx of
  225.             0 : if safe>0
  226.                   then fbitdraw(nx,ny+8,rsmisc[1]^)
  227.                   else fbitdraw(nx,ny,drols[flip]^);
  228.             1 : if turn
  229.                   then fbitdraw(nx,ny,drols[flip]^)
  230.                   else fbitdraw(nx,ny,drols[32+flip]^);
  231.            -1 : if turn
  232.                   then fbitdraw(nx,ny,drols[flip]^)
  233.                   else fbitdraw(nx,ny,drols[16+flip]^);
  234.           end;
  235.     end;
  236. end;
  237.  
  238.  
  239. procedure drawitems(over:boolean);
  240. var
  241.   p : plist;
  242. begin
  243.   p := nkbeg;
  244.   while p<>nil do
  245.     begin
  246.       if (p^.item^.overshow=over)
  247.         then p^.item^.drawitemobject;
  248.       p := p^.next;
  249.     end;
  250. end;
  251.  
  252.  
  253. procedure strobe;
  254. const
  255. { This is a hack procedure.  I didn't feel like doing the calcuation for CLC }
  256.   clc : array[0..30] of byte =
  257.         (15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
  258. var
  259.   d : integer;
  260. begin
  261.   setpageactive(1);
  262.   stx := (stx+5) mod 286;
  263.   line(14,14,299,14,0);
  264.   for d := 0 to 30 do
  265.     pset((stx+d) mod 286+14,14,176+clc[d]);
  266. end;
  267.  
  268.  
  269. procedure titlepage;
  270. begin
  271.   loadpcx(path+'rtitle.pcx');
  272.   fadein(200,zdc,rgb256);
  273.   clearbuffer;
  274.   repeat until ch<>#1;          { Notice there is nothing in the repeat until }
  275.                                 { I took over the Keyboard int }
  276.   clearbuffer;
  277.   fadeout(50,zdc,rgb256);
  278. end;
  279.  
  280.  
  281. procedure setup;
  282. var
  283.   fil : file;
  284. begin
  285.   writeln('Scott Ramsay presents:');
  286.   writeln('R-SQUID (unfinished, always will be)');
  287.   writeln;
  288.   writeln('This is a quick-and-dirty example of various effects PC ');
  289.   writeln('can do.  ');
  290.   writeln('Controls :');
  291.   writeln(' Arrows         -   Move Dude');
  292.   writeln('                    up    = jump, up elevators');
  293.   writeln('                    down  = down elevators');
  294.   writeln('                    right = take a guess');
  295.   writeln('                    left  = -(right)');
  296.   writeln(' SPACE          -   Fire shots');
  297.   writeln('   P            -   Pause screen');
  298.   writeln('   A            -   Add a nake');
  299.   writeln('   S            -   Add a simmer');
  300.   writeln('  -/+           -   Adjust brightness');
  301.   writeln('  ESC           -   Quit');
  302.   clearbuffer;
  303.   repeat until ch<>#1;
  304.   clearbuffer;
  305.   openmode(3); randomize;
  306.   oldexit := exitproc; exitproc := @cleanup;
  307.   loadvsp(path+'drols.vsp',drols); fsetcolors(zdc);
  308.   loadvsp(path+'girls.vsp',girls);
  309.   loadvsp(path+'nakes.vsp',nakes);
  310.   loadvsp(path+'simmers.vsp',simmers);
  311.   loadvsp(path+'rsmisc.vsp',rsmisc);
  312.   loadvsp(path+'rsquid.geo',gpic); geo_count := vspcnt;
  313.   loadvsp(path+'dr2.vsp',nummo);
  314.   loadcolors(path+'rsquid.pal',dac,255);
  315.   assign(fil,path+'rsquid.map'); reset(fil,1);
  316.   blockread(fil,map,filesize(fil)); close(fil);
  317.   setpageactive(3);
  318.   loadpcx(path+'fire.pcx');
  319.   setpageactive(1);
  320.   titlepage;
  321.   loadpcx(path+'dash.pcx');
  322.   fadein(60,zdc,dac);
  323. end;
  324.  
  325.  
  326. procedure setparms;
  327. var
  328.   d : integer;
  329.   p : plist;
  330. begin
  331.   MyCycle := new(PMyCycle,init(34,12));
  332.   MyMorph := new(PMyMorph,init(gmx,gmy,19,9,13,20));
  333.   warp := true; stx := 0; girls_out := 5;
  334.   kill := nil; paused := false; blv := 0;
  335.   nkbeg := nil; nkend := nil;
  336.   with player do
  337.     begin
  338.       lvls[0] := 16; lvls[1] := 10; lvls[2] := 22;
  339.       vx := 44; vy := 55; flip := 7; score := 0;
  340.       ovx := vx; ovy := vy; vdx := 0; vdy := 0; guys := 3;
  341.       drx := 0; turn := false; safe := 100; blown := false
  342.     end;
  343.   for d := 1 to 20 do
  344.     begin
  345.       new(p);
  346.       p^.item := new(pclod,init);
  347.       addp(nkbeg,nkend,p);
  348.     end;
  349.   for d := 1 to girls_out do
  350.     begin
  351.       new(p);
  352.       p^.item := new(pgirl,init);
  353.       addp(nkbeg,nkend,p);
  354.     end;
  355. end;
  356.  
  357.  
  358. procedure printscore;
  359. var
  360.   s : string;
  361.   d : byte;
  362. begin
  363.   s := lz(player.score,8);
  364.   setpageactive(1);
  365.   for d := 0 to length(s)-1 do
  366.     fastput(d*21+130,158,nummo[ord(s[d+1])-ord('0')]^);
  367.   setpageactive(2);
  368. end;
  369.  
  370.  
  371. function elevat(vx,vy:integer):boolean;
  372. var
  373.   cx,cy : integer;
  374.   d     : byte;
  375. begin
  376.   d := 0;
  377.   cx := (vx) shr 4; cy := (vy+15) shr 4;
  378.   if map[cy,cx] in [9,10]
  379.     then d := 1;
  380.   cx := (vx+9) shr 4; cy := (vy+15) shr 4;
  381.   if map[cy,cx] in [9,10]
  382.     then inc(d);
  383.   elevat := (d<>0);
  384. end;
  385.  
  386.  
  387. function canfall(vx,vy:integer): boolean;
  388. var
  389.   cx,cy : integer;
  390.   d     : byte;
  391. begin
  392.   d := 0;
  393.   cx := (vx) shr 4; cy := (vy+16) shr 4;
  394.   canchk := map[cy,cx];
  395.   if not (map[cy,cx] in [1,3,6,8])
  396.     then d := 1;
  397.   cx := (vx+9) shr 4; cy := (vy+16) shr 4;
  398.   if not (map[cy,cx] in [1,3,6,8])
  399.     then inc(d);
  400.   canchk := (canchk shl 8) or map[cy,cx];
  401.   canfall := (d=2);
  402. end;
  403.  
  404.  
  405. function canwalk(vx,vy:integer): boolean;
  406. var
  407.   cx,cy : integer;
  408.   d     : byte;
  409. begin
  410.   d := 0;
  411.   cx := (vx) shr 4; cy := (vy+16) shr 4;
  412.   canchk := map[cy,cx];
  413.   if map[cy,cx] in [1,3,5,6,8,10]
  414.     then d := 1;
  415.   cx := (vx+9) shr 4; cy := (vy+16) shr 4;
  416.   if map[cy,cx] in [1,3,5,6,8,10]
  417.     then inc(d);
  418.   canchk := (canchk shl 8) or map[cy,cx];
  419.   canwalk := (d=2);
  420. end;
  421.  
  422.  
  423. procedure zero(var valu:integer);
  424. begin
  425.   if valu<0
  426.     then inc(valu)
  427.     else
  428.       if valu>0
  429.         then dec(valu);
  430. end;
  431.  
  432.  
  433. procedure calcitems;
  434. var
  435.   p : plist;
  436. begin
  437.   p := nkbeg;
  438.   while p<>nil do
  439.     begin
  440.       p^.item^.calcitemobject;
  441.       p := p^.next;
  442.     end;
  443. end;
  444.  
  445.  
  446. procedure addfire;
  447. var
  448.   p : plist;
  449. begin
  450.   new(p);
  451.   p^.item := new(pshot,init);
  452.   p^.item^.powner := p;
  453.   addp(nkbeg,nkend,p);
  454. end;
  455.  
  456.  
  457. procedure addsimmers;
  458. var
  459.   p : plist;
  460. begin
  461.   new(p);
  462.   p^.item := new(psimm,init);
  463.   p^.item^.powner := p;
  464.   addp(nkbeg,nkend,p);
  465. end;
  466.  
  467.  
  468. procedure addnake;
  469. var
  470.   p : plist;
  471. begin
  472.   new(p);
  473.   p^.item := new(pnake,init);
  474.   p^.item^.powner := p;
  475.   addp(nkbeg,nkend,p);
  476. end;
  477.  
  478.  
  479. procedure finc(var i:byte;a:shortint);
  480. begin
  481.   if i+a<0
  482.     then i := 0
  483.     else
  484.       if i+a>63
  485.         then i := 63
  486.         else inc(i,a);
  487. end;
  488.  
  489.  
  490. procedure brightcheck;
  491. var
  492.   temp : RGBlist;
  493.   d    : integer;
  494. begin
  495.   if plus and (blv<20)
  496.     then
  497.       begin
  498.         inc(blv);
  499.         temp := dac;
  500.         for d := 0 to 255 do
  501.           with temp[d] do
  502.             begin
  503.               finc(red,blv);
  504.               finc(green,blv);
  505.               finc(blue,blv);
  506.             end;
  507.         fsetcolors(temp);
  508.       end;
  509.   if minus and (blv>-20)
  510.     then
  511.       begin
  512.         dec(blv);
  513.         temp := dac;
  514.         for d := 0 to 255 do
  515.           with temp[d] do
  516.             begin
  517.               finc(red,blv);
  518.               finc(green,blv);
  519.               finc(blue,blv);
  520.             end;
  521.         fsetcolors(temp);
  522.       end;
  523. end;
  524.  
  525.  
  526. procedure pause;
  527.   procedure dit;
  528.   begin
  529.     MyCycle^.docycle(3,2,2);
  530.     update; strobe;
  531.     brightcheck;
  532.   end;
  533. begin
  534.   paused := true;
  535.   repeat dit; until ch<>'P';
  536.   repeat dit; until (ch='P') and not funct;
  537.   repeat dit; until ch<>'P';
  538.   paused := false;
  539.   setpageactive(2);
  540. end;
  541.  
  542.  
  543. procedure checkotherkeys(var detwait:boolean);
  544. var
  545.   temp : RGBlist;
  546.   d    : integer;
  547. begin
  548.   if (ch='P') and not funct
  549.     then pause;
  550.   brightcheck;
  551.   if ch='A'
  552.     then addnake;
  553.   if ch='S'
  554.     then addsimmers;
  555. end;
  556.  
  557.  
  558. procedure getkey;
  559. var
  560.   up,ovx,ovy : integer;
  561.   detwait    : boolean;
  562. begin
  563.   with player do
  564.     begin
  565.       clearbuffer; up := 0; detwait := false;
  566.       repeat
  567.         checkotherkeys(detwait);
  568.         if blown
  569.           then
  570.             begin
  571.               inc(flip);
  572.               if flip=15
  573.                 then
  574.                   begin
  575.                     blown := false;
  576.                     lvls[0] := 16;
  577.                     lvls[1] := 10;
  578.                     lvls[2] := 22;
  579.                     safe := 100;
  580.                     flip := 7;
  581.                     drx := 0;
  582.                     dec(guys);
  583.                     {if guys=0 (**)
  584.                       then gameover; }
  585.                   end;
  586.               zero(vdx);
  587.             end
  588.           else
  589.             begin
  590.               case drx of
  591.                 0 : begin
  592.                       if safe>0
  593.                         then dec(safe);
  594.                       if np[7,2] or np[4,2] or np[1,2]
  595.                         then
  596.                           begin
  597.                             drx := 1; safe := 0;
  598.                             turn := true;
  599.                           end
  600.                         else
  601.                       if np[9,2] or np[6,2] or np[3,2]
  602.                         then
  603.                           begin
  604.                             drx := -1; safe := 0;
  605.                             turn := true;
  606.                           end;
  607.                     end;
  608.                 1 : if turn
  609.                       then
  610.                         if flip<14
  611.                           then inc(flip,2)
  612.                           else turn := false
  613.                       else
  614.                         begin
  615.                           if np[7,2] or np[4,2] or np[1,2]
  616.                             then flip := (flip+1)mod 16;
  617.                           if np[9,2] or np[6,2] or np[3,2]
  618.                             then
  619.                               begin
  620.                                 flip := 15; vdx := 0;
  621.                                 drx := -1; turn := true;
  622.                               end;
  623.                         end;
  624.                -1 : if turn
  625.                       then
  626.                         if flip>1
  627.                           then dec(flip,2)
  628.                           else turn := false
  629.                       else
  630.                         begin
  631.                           if np[9,2] or np[6,2] or np[3,2]
  632.                             then flip := (flip+1)mod 16;
  633.                           if np[7,2] or np[4,2] or np[1,2]
  634.                             then
  635.                               begin
  636.                                 flip := 0; vdx :=0;
  637.                                 drx := 1; turn := true;
  638.                               end;
  639.                         end;
  640.               end;
  641.               ovy := vy; ovx := vx;
  642.               if (np[7,2] or np[8,2] or np[9,2]) and elevat(vx,vy)
  643.                 then
  644.                   begin
  645.                     dec(vy);
  646.                     up := -1;
  647.                     vx := (vx+8) shr 4 shl 4;
  648.                   end
  649.                 else
  650.                   if (np[1,2] or np[2,2] or np[3,2]) and elevat(vx,vy+1)
  651.                     then
  652.                       begin
  653.                         inc(vy);
  654.                         vx := (vx+8) shr 4 shl 4;
  655.                         up := 1;
  656.                       end;
  657.               if (vx>0) and (np[7,2] or np[4,2] or np[1,2])
  658.                 then dec(vdx,1)
  659.                 else
  660.                   if (vx<smx) and (np[9,2] or np[6,2] or np[3,2])
  661.                     then inc(vdx,1)
  662.                     else zero(vdx);
  663.               if space and (drx<>0) and (lvls[2]>0)
  664.                 then
  665.                   begin
  666.                     addfire;
  667.                     dec(lvls[2],2);
  668.                   end
  669.                 else
  670.                   if (lvls[2]<22) and (random<0.2)
  671.                     then inc(lvls[2]);
  672.             end;
  673.         ifix(vdx,-10,10);
  674.         if canfall(vx,vy)
  675.           then
  676.             begin
  677.               if elevat(vx,vy) and (up=-1)
  678.                 then
  679.                   begin
  680.                     dec(vy);
  681.                     vy := vy shr 4 shl 4;
  682.                     vdy := 0;
  683.                   end
  684.                 else
  685.                   if (up=1) or ((up=0) and ((hi(canchk)<>10) or (lo(canchk)<>10)))
  686.                     then
  687.                       begin
  688.                         inc(vdy,3);
  689.                         if vdy>15
  690.                           then vdy := 15;
  691.                       end
  692.                     else up := 0;
  693.             end
  694.           else
  695.             begin
  696.               vy := vy shr 4 shl 4;
  697.               vdy := 0; up := 0;
  698.               if not blown and (np[7,2] or np[8,2] or np[9,2])
  699.                 then vdy := -abs(vdx);
  700.             end;
  701.         inc(vx,vdx); inc(vy,vdy);
  702.         if vx<16
  703.           then vx := ovx
  704.           else if vx>(gmx-2) shl 4
  705.                  then vx := ovx;
  706.         calcitems;
  707.         MyMorph^.drawmap(vx,vy,gpic);
  708.         update;
  709.         cleankill_list(kill,nkbeg,nkend);
  710.       until esc;
  711.     end;
  712. end;
  713.  
  714.  
  715. function checkallhit(hx,hy:integer) : boolean;
  716. var
  717.   p   : plist;
  718.   did : boolean;
  719. begin
  720.   p := nkbeg; did := false;
  721.   while (p<>nil) and not did do
  722.     begin
  723.       if p^.item^.id    { shots don't affect eachother (id=0) }
  724.         then did := p^.item^.checkhit(hx,hy);
  725.       p := p^.next;
  726.     end;
  727.   checkallhit := did;
  728. end;
  729.  
  730.  
  731. (**) { tshot Methods }
  732.  
  733. constructor tshot.init;
  734. begin
  735.   nx := player.vx+8; ny := player.vy; explo := false;
  736.   ndy := 0; ndx := -12*player.drx; id := false;
  737.   nrx := -player.drx; mapcolor := $fb; pointage := 0;
  738.   flp := 0; timeo := 15; overshow := false;
  739. end;
  740.  
  741.  
  742. procedure tshot.drawitemobject;
  743. begin
  744.   with player do
  745.     if range(nx,ny,vx-150,vy-80,vx+140,vy+80)
  746.       then fbitdraw(153+(nx-vx),84+(ny-vy),rsmisc[17]^);
  747. end;
  748.  
  749.  
  750. procedure tshot.calcitemobject;
  751. var
  752.   p : plist;
  753. begin
  754.   if random<0.8
  755.     then
  756.       if (nrx<0) and (ndx>-15)
  757.         then dec(ndx)
  758.         else
  759.          if (nrx>0) and (ndx<15)
  760.            then inc(ndx);
  761.   inc(nx,ndx); inc(ny,ndy); dec(timeo);
  762.   if timeo=0
  763.     then add2kill_list(kill,powner)
  764.     else
  765.       if checkallhit(nx,ny)
  766.         then add2kill_list(kill,powner);
  767. end;
  768.  
  769.  
  770. function tshot.checkhit(hx,hy:integer):boolean;
  771. begin
  772.   checkhit := false;
  773. end;
  774.  
  775. (**) { Tclod Methods }
  776.  
  777. constructor tclod.init;
  778. begin
  779.   mapcolor := 0; id := false;
  780.   overshow := true;
  781.   nx := random(gmx shl 4);
  782.   ny := random((gmy-6) shl 4);
  783.   repeat
  784.     ndx := random(7)-3;
  785.   until ndx<>0;
  786.   ndy := 0;
  787. end;
  788.  
  789.  
  790. procedure tclod.drawitemobject;
  791. begin
  792.   with player do
  793.     if range(nx,ny,vx-150,vy-90,vx+130,vy+80)
  794.       then fbitdraw(153+(nx-vx),89+(ny-vy),rsmisc[0]^);
  795. end;
  796.  
  797.  
  798. procedure tclod.calcitemobject;
  799. var
  800.   p : plist;
  801. begin
  802.   inc(nx,ndx); inc(ny,ndy);
  803.   if nx<-300
  804.     then nx := gmx shl 4+300
  805.     else
  806.       if nx>gmx shl 4+300
  807.         then nx := -300;
  808. end;
  809.  
  810. (**) { Tgirl Methods }
  811.  
  812. constructor tgirl.init;
  813. begin
  814.   mapcolor := 163; id := false; goup := false;
  815.   overshow := false; flp := 0; godown := false;
  816.   with player do
  817.     repeat
  818.       nx := random(gmx shl 4);
  819.       ny := random((gmy-4) shl 4);
  820.     until canwalk(nx,ny) and not range(nx,ny,vx-150,vy-90,vx+130,vy+80);
  821.   if random<0.4
  822.     then ndx := -4
  823.     else ndx := 4;
  824.   ndy := 0; nrx := ndx;
  825. end;
  826.  
  827.  
  828. procedure tgirl.checkplayertouch;
  829. var
  830.   dir : integer;
  831. begin
  832.   with player do
  833.     if not boolean(safe) and not blown and range(nx+9,ny,vx-40,vy,vx+80,vy+10)
  834.       then
  835.         begin
  836.           if ndx<>0
  837.             then nrx := ndx;
  838.           dir := (nx-vx);
  839.           if dir<-10
  840.             then ndx := 4
  841.             else
  842.               if dir>10
  843.                 then ndx := -4
  844.                 else ndx := 0;
  845.         end
  846.       else
  847.         if ndx=0
  848.           then ndx := nrx;
  849. end;
  850.  
  851.  
  852. procedure tgirl.calcitemobject;
  853. var
  854.   ox,oy,b : integer;
  855. begin
  856.   ox := nx; oy := ny;
  857.   if canfall(nx,ny)
  858.     then
  859.       begin
  860.         if ndy<16
  861.           then inc(ndy);
  862.       end
  863.     else
  864.       begin
  865.         ndy := 0;
  866.         ny := ny shr 4 shl 4;
  867.       end;
  868.   inc(nx,ndx); inc(ny,ndy);
  869.   if (nx<16) or (nx>(gmx-2)shl 4)
  870.     then
  871.       begin
  872.         nx := ox;
  873.         ndx := -ndx;
  874.       end;
  875.   if not canwalk(nx,ny) and canwalk(ox,oy) and (random<0.4)
  876.     then
  877.       begin
  878.         nx := ox;
  879.         ndx := -ndx;
  880.       end;
  881.   if not goup and not godown
  882.     then flp := (flp+1)mod 16;
  883. end;
  884.  
  885.  
  886. procedure tgirl.drawitemobject;
  887. begin
  888.   with player do
  889.     if range(nx,ny,vx-160,vy-80,vx+140,vy+80)
  890.       then
  891.         if ndx<0
  892.           then fbitdraw(153+(nx-vx),68+(ny-vy),girls[flp]^)
  893.           else
  894.         if ndx>0
  895.           then fbitdraw(153+(nx-vx),68+(ny-vy),girls[flp+16]^)
  896.           else
  897.         if (nx<vx)
  898.           then fbitdraw(153+(nx-vx),68+(ny-vy),girls[16]^)
  899.           else fbitdraw(153+(nx-vx),68+(ny-vy),girls[0]^);
  900. end;
  901.  
  902.  
  903. (**) { Tnake Methods }
  904.  
  905. constructor tnake.init;
  906. begin
  907.   repeat
  908.     nx := random(gmx shl 4);
  909.     ny := random(gmy-3) shl 4;
  910.   until canwalk(nx,ny); pointage := 125;
  911.   mapcolor := 99; id := true; explo := false;
  912.   repeat
  913.     ndx := random(11)-5;
  914.   until ndx<>0;
  915.   ndy := 0; overshow := false;
  916.   flp := 0; trn := false;
  917.   if ndx<0
  918.     then nrx := -1
  919.     else nrx := 1;
  920. end;
  921.  
  922.  
  923. function tnake.checkhit(hx,hy:integer):boolean;
  924. begin
  925.   if not explo and range(hx,hy,nx,ny,nx+12,ny+24)
  926.     then
  927.       begin
  928.         explo := true; flp := 0;
  929.         if player.vx<nx
  930.           then nrx := -1
  931.           else nrx := 1;
  932.         checkhit := true;
  933.         inc(player.score,pointage);
  934.         printscore;
  935.       end
  936.     else checkhit := false;
  937. end;
  938.  
  939.  
  940. procedure tnake.drawitemobject;
  941. begin
  942.   with player do
  943.     if range(nx,ny,vx-150,vy-80,vx+140,vy+80)
  944.       then
  945.         if explo
  946.           then
  947.             if ndx<0
  948.               then
  949.                 if nrx<0
  950.                   then fbitdraw(153+(nx-vx),72+(ny-vy),nakes[100+flp]^)
  951.                   else fbitdraw(153+(nx-vx),72+(ny-vy),nakes[83+flp]^)
  952.               else
  953.                 if nrx<0
  954.                   then fbitdraw(153+(nx-vx),72+(ny-vy),nakes[66+flp]^)
  955.                   else fbitdraw(153+(nx-vx),72+(ny-vy),nakes[49+flp]^)
  956.           else
  957.             if trn
  958.               then fbitdraw(153+(nx-vx),72+(ny-vy),nakes[flp+32]^)
  959.               else
  960.                 if ndx<0
  961.                   then fbitdraw(153+(nx-vx),72+(ny-vy),nakes[flp+16]^)
  962.                   else fbitdraw(153+(nx-vx),72+(ny-vy),nakes[flp]^);
  963. end;
  964.  
  965.  
  966. procedure tnake.checkplayertouch;
  967. begin
  968.   with player do
  969.     if not boolean(safe) and not blown and range(vx+9,vy+14,nx,ny,nx+24,ny+30)
  970.       then
  971.         begin
  972.           vdx := ndx; vdy := ndy;
  973.           if nrx=drx
  974.             then
  975.               begin
  976.                 drx := -drx;
  977.                 if drx<0
  978.                   then flip := 15
  979.                   else flip := 0;
  980.                 turn := true;
  981.               end;
  982.           if lvls[0]>0
  983.             then dec(lvls[0],1);
  984.           if lvls[0]=0
  985.             then
  986.               begin
  987.                 blown := true;
  988.                 flip := 0;
  989.               end;
  990.         end;
  991. end;
  992.  
  993.  
  994. procedure tnake.calcitemobject;
  995. var
  996.   ox,oy : integer;
  997. begin
  998.   ox := nx; oy := ny;
  999.   if not explo
  1000.     then
  1001.       begin
  1002.         inc(nx,ndx);
  1003.         inc(ny,ndy);
  1004.       end;
  1005.   if nx<16
  1006.     then nx := (gmx-2) shl 4
  1007.     else
  1008.       if nx>(gmx-2)shl 4
  1009.         then nx := 16;
  1010.   if not canwalk(nx,ny)
  1011.     then
  1012.       begin
  1013.         nx := ox; ndx := -ndx;
  1014.         trn := true;
  1015.         nrx := -nrx;
  1016.         if nrx<0
  1017.           then flp := 15
  1018.           else flp := 0;
  1019.       end;
  1020.   if not explo
  1021.     then checkplayertouch;
  1022.   if explo
  1023.     then
  1024.       begin
  1025.         inc(flp);
  1026.         if flp=15
  1027.           then add2kill_list(kill,powner)
  1028.       end
  1029.     else
  1030.      if trn
  1031.        then
  1032.          if nrx>0
  1033.            then
  1034.              begin
  1035.                inc(flp);
  1036.                if flp=15
  1037.                  then trn := false;
  1038.              end
  1039.            else
  1040.              begin
  1041.                dec(flp);
  1042.                if flp=0
  1043.                  then trn := false;
  1044.              end
  1045.        else flp := (flp+1) mod 16;
  1046. end;
  1047.  
  1048. (**) { Tsimm methods }
  1049.  
  1050. constructor tsimm.init;
  1051. begin
  1052.   repeat
  1053.     nx := random(gmx shl 4);
  1054.     ny := random(gmy-3) shl 4;
  1055.   until canwalk(nx,ny); pointage := 275;
  1056.   mapcolor := 0; id := true; explo := false;
  1057.   ndx := 5;
  1058.   nrx := 1;
  1059.   if random<0.4
  1060.     then
  1061.       begin
  1062.         ndx := -5;
  1063.         nrx := -1;
  1064.       end;
  1065.   ndy := 0; overshow := false;
  1066.   flp := 0; trn := false;
  1067. end;
  1068.  
  1069.  
  1070. procedure tsimm.drawitemobject;
  1071. begin
  1072.   with player do
  1073.     if range(nx,ny,vx-150,vy-80,vx+140,vy+80)
  1074.       then
  1075.         if explo
  1076.           then
  1077.             begin
  1078.             end
  1079.           else
  1080.             if trn
  1081.               then fbitdraw(153+(nx-vx),77+(ny-vy),simmers[flp]^)
  1082.               else
  1083.                 if ndx<0
  1084.                   then fbitdraw(153+(nx-vx),77+(ny-vy),simmers[0]^)
  1085.                   else fbitdraw(153+(nx-vx),77+(ny-vy),simmers[15]^);
  1086. end;
  1087.  
  1088.  
  1089. procedure tsimm.checkplayertouch;
  1090. begin
  1091.   with player do
  1092.     if not boolean(safe) and not blown and range(vx+9,vy+14,nx,ny,nx+24,ny+30)
  1093.       then
  1094.         begin
  1095.           vdx := ndx; vdy := ndy;
  1096.           if nrx=drx
  1097.             then
  1098.               begin
  1099.                 drx := -drx;
  1100.                 if drx<0
  1101.                   then flip := 15
  1102.                   else flip := 0;
  1103.                 turn := true;
  1104.               end;
  1105.           if lvls[0]>0
  1106.             then dec(lvls[0],1);
  1107.           if lvls[0]=0
  1108.             then
  1109.               begin
  1110.                 blown := true;
  1111.                 flip := 0;
  1112.               end;
  1113.         end;
  1114. end;
  1115.  
  1116. (**) { TMyCycle methods }
  1117.  
  1118. procedure TMyCycle.cycle_move;
  1119. begin
  1120.   if player.vdx<0
  1121.     then cyclex := (cyclex+319-(abs(player.vdx) shr 1))mod 320
  1122.     else
  1123.       if player.vdx>0
  1124.         then cyclex := (cyclex+(player.vdx shr 1))mod 320;
  1125. end;
  1126.  
  1127. (**) { TMyMorph methods }
  1128.  
  1129. function TMyMorph.geomap(x,y:integer):integer;
  1130. begin
  1131.   geomap := map[y,x];
  1132. end;
  1133.  
  1134.  
  1135. procedure TMyMorph.placegeo(x,y,geonum:integer;var geos);
  1136. begin
  1137.   if geonum in [1..geo_count]
  1138.     then fbitdraw(x,y,gpic[geonum-1]^);
  1139. end;
  1140.  
  1141.  
  1142. procedure TMyMorph.pre_map;
  1143. begin
  1144.   strobe;
  1145.   setpageActive(2);
  1146.   MyCycle^.docycle(3,2,2);
  1147.   drawitems(false);
  1148.   drawperson;
  1149. end;
  1150.  
  1151.  
  1152. procedure TMyMorph.post_map;
  1153. begin
  1154.   drawitems(true);
  1155. end;
  1156.  
  1157.  
  1158. begin
  1159.   setup;
  1160.   setparms;
  1161.   printscore;
  1162.   getkey;
  1163. end.