home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / pascal / spx10.zip / SPX_DEMO.ZIP / DEMO1.PAS < prev    next >
Pascal/Delphi Source File  |  1993-05-01  |  2KB  |  94 lines

  1. Program Demo1;
  2.  
  3. { SPX library - Parallax demo  Copyright 1993 Scott D. Ramsay  }
  4.  
  5. Uses SPX_VGA,SPX_EFF,SPX_KEY,SPX_IMG;
  6.  
  7. const
  8.   path = '';
  9.  
  10. type
  11.   PMyCycle = ^TmyCycle;
  12.   TMyCycle = object(TCycle)
  13.                procedure cycle_move; virtual;
  14.              end;
  15.  
  16. var
  17.   MyCycle : PMyCycle;
  18.   nsize   : integer;
  19.  
  20. procedure setup;
  21. begin
  22.   openmode(2);
  23.   setpageactive(2);
  24.   loadpcx(path+'fire.pcx');
  25.   fsetcolors(rgb256);
  26.   nsize := 30;
  27.   MyCycle := new(PMyCycle,init(50,nsize));
  28. end;
  29.  
  30.  
  31. procedure animate;
  32. begin
  33.   repeat
  34.     if minus and (nsize>0)
  35.       then
  36.         begin
  37.           dec(nsize);
  38.           MyCycle^.changewave(50,nsize);
  39.         end
  40.       else
  41.     if plus and (nsize<100)
  42.       then
  43.         begin
  44.           inc(nsize);
  45.           MyCycle^.changewave(50,nsize);
  46.         end;
  47.     if space
  48.       then MyCycle^.docycle(2,1,1)
  49.       else MyCycle^.docycle(2,1,2);
  50.   until esc;
  51.   fadeout(40,rgb256);
  52. end;
  53.  
  54. (**) { TCycle Methods }
  55.  
  56. procedure TMyCycle.cycle_move;
  57. begin
  58.   if np[6,2] or np[9,2] or np[3,2]
  59.     then cyclex := (cyclex+1) mod 320
  60.     else
  61.       if np[4,2] or np[7,2] or np[1,2]
  62.         then cyclex := (cyclex+319) mod 320;
  63.   if np[8,2] or np[7,2] or np[9,2]
  64.     then cycley := (cycley+1) mod 200
  65.     else
  66.       if np[1,2] or np[2,2] or np[3,2]
  67.         then cycley := (cycley+199) mod 200;
  68. end;
  69.  
  70.  
  71. procedure showit;
  72. begin
  73.    writeln('SPX library - Parallax demo');
  74.    writeln('Copyright 1993 Scott D. Ramsay');
  75.    writeln;
  76.    writeln('Keys:');
  77.    writeln(' ESC          - quit demo');
  78.    writeln(' Arrow keys   - scroll background');
  79.    writeln(' +/-          - change amplitude');
  80.    writeln(' SPACE        - Still background');
  81.    writeln;
  82.    write('Press any key.');
  83.    clearbuffer;
  84.    repeat until anykey;
  85. end;
  86.  
  87.  
  88. begin
  89.   showit;
  90.   setup;
  91.   animate;
  92.   dispose(MyCycle,done);
  93.   closemode;
  94. end.