home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cons-010.zip / Console / examples / Pong.cmd < prev    next >
OS/2 REXX Batch file  |  1997-07-30  |  2KB  |  63 lines

  1. /* rexx */
  2.  
  3.  '@echo off'
  4.  
  5. /* modify this depending on your settings */
  6.  ScreenW = 640 /*1024*/;
  7.  ScreenH = 480 /*768*/;
  8.  
  9.  say 'This script will make current console window fly through the screen'
  10.  say 'however, you`ll get the best results on a reasonably fast computer'
  11.  say '(P5/133 and faster). On slower computers you`ll get only the main'
  12.  say 'idea behind this :-)'
  13.  say '--------------------------------------------------------------------'
  14.  say 'Don`t forget to modify ScreenW and ScreenH variables inside the'
  15.  say 'script since there is no way to query them from REXX...'
  16.  call charout , 'press Enter to continue...'
  17.  pull junk;
  18.  
  19.  line = querystat();
  20.  restcon = substr(line, 4);
  21.  
  22.  'console -s14,5 -b10,10 -f18,10 -of'
  23.  say 'Press [ESC]apekey to end    this mess...'
  24.  
  25.  cx = ScreenW/2; cy = ScreenH/2;
  26.  wx = cx/2; wy = cy/2;
  27.  dx = 0; dy = 0;
  28.  Visible = '+';
  29.  do while chars() = 0
  30.   if (wx < cx)
  31.    then dx = dx + 1
  32.    else dx = dx - 1;
  33.   if (wy < cy)
  34.    then dy = dy + 1
  35.    else dy = dy - 1;
  36.   wx = wx + dx; wy = wy + dy;
  37.   'console -p'wx','wy;
  38.  
  39.   if (Visible = '+') then n = random(0,100); else n = random(0,10);
  40.   if n = 1
  41.   then do
  42.         if Visible = '-' then Visible = '+'; else Visible = '-';
  43.         'Console -ov'Visible;
  44.        end;
  45.  end;
  46.  
  47.  /* Hide console temporarily */
  48.  'Console -ov-'
  49.  /* restore console at best we can... */
  50.  restcon' -of- -ov -ox'
  51. exit;
  52.  
  53. querystat:
  54.  procedure;
  55.  'console -p -f -q | rxqueue /lifo';
  56.  do i = 1 to 2
  57.   parse pull line;
  58.  end;
  59.  do while queued() > 0
  60.   pull junk;
  61.  end;
  62. return line;
  63.