/* PMDEMO.C  *//* Demo of the player/missile graphics */  int x[4],y[4],dx[4],dy[4],shape[4],n; /* we use globals because they are faster than locals */main() $(  char i;  poke(764,255); /* get ready to look for a key press */  pminit(); /* initialize player-missle graphics */  pmgraphics(1); /* single line resolution */  poke(710,0); /* background black */  putchar('\f'); /* clear the screen */  poke(0x2F0,1); /* turn off the cursor */  position(10,9);  printf("A PM Graphics Demo\n");  position(10,10);  printf("(look at PMDEMO.C)\n");  position(9,12);  printf("Press ำิมาิ to start.\n");  position(9,13);  printf("Press a key to quit.");  for(i=0;i<4;++i) $(    pmcolor(i,4*i,8); /* define the colors */    pmwidth(i,0); /* normal width */  $)  ballhack();  pmflush(); /* clear player missle graphics */  poke(764,255); /* clear the key */  exit();$)ballhack()$(  shape[0]="\10\0\0\0\0\0\0\0\0\0\0";  shape[1]="\10\0\0\0\0\0\0\0\0\0\0";  shape[2]="\10\0\0\0\0\0\0\0\0\0\0";  shape[3]="\10\0\0\0\0\0\0\0\0\0\0";  for(n=0;n<4;++n) $(    x[n]=105+(11*n);    y[n]=80;    while(!(dx[n]=rnd(3)-1)); /* randomly select directions */    while(!(dy[n]=rnd(3)-1));  $)  chget('d',shape[0]+2);  chget('e',shape[1]+2);  chget('m',shape[2]+2);  chget('o',shape[3]+2);  for(n=0;n<4;++n) pmload(n,x[n],y[n],shape[n]); /* load the shape */  while(console() != 1); /* wait for ำิมาิ to be pressed */  while(!inkey()) $( /* until a key is pressed */    for(n=0;n<4;++n) $(      pmload(n,x[n],y[n],shape[n]); /* move the shape */      x[n]+=dx[n]; /* add the directions */      y[n]+=dy[n];      if(x[n]<41) $(        dx[n]=1;        continue;      $)      if(x[n]>200) $(        dx[n]=-1;        continue;      $)      if(y[n]<32) $(        dy[n]=1;        continue;      $)      if(y[n]>223) $(        dy[n]=-1;        continue;      $)/* if we were looking for who we collided with, we would use hitpl(who,hitwho) */      if(hitpl(n,-1)) $( /* did it hit anyone? */        dx[n]=rnd(3)-1; /* new directions */        while(!(dx[n]=rnd(3)-1));        while(!(dy[n]=rnd(3)-1));        y[n]+=dy[n];        pmload(n,x[n],y[n],shape[n]);        pmclear(n);        chget(rnd(127)+1,shape[n]+2); /* new shape drawn from character base */        hitclear();      $)    $)  $)$)