home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the 3D Game Programming Gurus / gurus.iso / Articles / XtremeDebugging / monlist6.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-10  |  1.6 KB  |  70 lines

  1.  
  2. // INCLUDES /////////////////////////////////////////////////////////////////
  3.  
  4. #define WIN32_LEAN_AND_MEAN  // make sure certain headers are included correctly
  5. #include <windows.h>         // include the standard windows stuff
  6. #include <windowsx.h>        // include the 32 bit stuff
  7. #include <conio.h>
  8. #include <stdlib.h>
  9. #include <malloc.h>
  10. #include <string.h>
  11. #include <stdio.h>
  12. #include <math.h>
  13. #include <io.h>
  14. #include "mono.h"
  15.  
  16. // MAIN //////////////////////////////////////////////////////////////////////////
  17.  
  18. void main(void)
  19. {
  20. int done    =    0;                    // exit flag
  21. int ship_x    =    MONO_COLUMNS/2;        // initial position of debugger ship
  22.  
  23. mono_print debug;                    // create an instance of a debugger port
  24.  
  25. // clear the debugging display
  26. debug.clear();
  27.  
  28. // show instructions
  29. debug.print("Controls:\n\n<a> to move left\n<s> to move right.\n\nTo exit press <ESC>.");
  30. Sleep(5000);
  31.  
  32. // add variable to debugger display
  33. debug.add_watch("ship_x",&ship_x,MONO_WATCH_INT,0,0,8);
  34.  
  35. // loop until user hits keys other that 'a' and 's'
  36. while(!done)
  37.     {
  38.     // draw display
  39.     debug.draw(".",rand()%MONO_COLUMNS,24,((rand()%2) ? MONO_BRIGHT : MONO_DARK));
  40.     debug.scroll(1);
  41.  
  42.     // draw ship
  43.     debug.draw(" |-()-| ",ship_x,0,MONO_BRIGHT);
  44.  
  45.     // move ship
  46.     if (kbhit())
  47.         {
  48.         switch(getch())
  49.             {
  50.             case 'a':if ((ship_x-=2)<0) ship_x=0; break;
  51.             case 's':if ((ship_x+=2)>MONO_COLUMNS-7) ship_x=MONO_COLUMNS-7; break;
  52.             
  53.             default: done=1; break;
  54.  
  55.             } // end switch
  56.         } // end if
  57.  
  58.     // update debug display
  59.     debug.update_watches();
  60.     
  61.     // wait a sec
  62.     Sleep(100);
  63.  
  64.     } // end while
  65.  
  66. // clear the debugging display
  67. debug.clear();
  68.  
  69. } // end main
  70.