Sunday, April 26, 2020

PLAYDEMO.P

[Table of Contents]

PLAYDEMO.P is a demo program from the Kyan Pascal 2.x Advanced Graphics Toolkit disk.

It can be run by booting the Kyan Pascal 2.x Advanced Graphics Toolkit and choosing PlayDemo from the menu.

To compile this example program, the following include files need to be available to the compiler:


Source Code


#i pmsetup.i
program pmdemo(input,output);
    type
#i pmtypes.i
    var
        b    :pmarray;
        j,dis:integer;
        a    :integer;
        x,y  :array[1..100] of integer;
        i,step,z:real;
#i pmlib.i
    begin
        writeln(chr(125));
        writeln('This is a demo of smooth movement');
        writeln('of players in both horizontal and');
        writeln('vertical directions.');
        writeln;
        writeln('one moment please...');
        (*The b array contains the*)
        (*shape data for the ship.*)
        b[1]:=chr(66);
        b[2]:=chr(129);
        b[3]:=chr(153);
        b[4]:=chr(255);
        b[5]:=chr(255);
        b[6]:=chr(153);
        b[7]:=chr(129);
        b[8]:=chr(66);
        (*Now make a circle divided*)
        (*into 100 parts.          *)
        i:=0;
        j:=1;
        step:=0.062831853;
        while j<51 do begin
            a:=trunc(50*cos(i));
            z:=70*sin(i);

            x[j]:=120+a;
            y[j]:=120-trunc(z);
            x[j+50]:=120-a;
            y[j+50]:=trunc(120+z+0.5);
            i:=i+step;
            j:=j+1;
        end;
        pmstartup;
        (*save VBI vector*)
        pminitialize(1);
        (*set up for hires player*)
        (*missle graphics. Then  *)
        (*clear out the buffer   *)
        clear_pm_buffer(1);
        pmcolor(0,125);
        pmcolor(1,155);
        pmcolor(2,155);
        pmcolor(3,165);
        (*Give the players the *)
        (*colors which we want.*)
        (*Then put the ship in *)
        (*each player at offset*)
        (*120.  The ship is 8  *)
        (*bytes in length.     *)
        putshape(0,120,8,b);
        putshape(1,120,8,b);
        putshape(2,120,8,b);
        putshape(3,120,8,b);
        j:=2;
        a:=0;
        horiz_player_pos(2,120);
        while j<101 do begin
          dis:=y[j-1]-y[j];
          horiz_player_pos(0,x[j]);
          horiz_player_pos(1,255-x[j]);
          horiz_player_pos(3,x[j]);
          roll_player_buffer(0,dis);
          wait;
          (*The wait command will    *)
          (*suspend execution until  *)
          (*the vertical blank.  This*)
          (*will result in the roll  *)
          (*instruction executing.   *)
          roll_player_buffer(2,dis);
          (*This roll command will be*)
          (*executed in the next VBI *)
          (*which will occur before  *)
          (*the next roll instruction*)
          (*since arithmetic is time *)
          (*consuming.               *)
          j:=j+1;
          if (a<5) and (j=101) then
              begin
              a:=a+1;
              j:=2;
          end;
          (*The if makes the ship    *)
          (*circle 4 times the stop. *)
        end;
        (*This next command turns off*)
        (*PM graphics and revectors  *)
        (*the VBI to it's default.   *)
        pminitialize(0);
end.

Sample Run



No comments:

Post a Comment